Skip to content

Handle two edge cases in the unconditional recursion lint #26666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 30, 2015

Conversation

huonw
Copy link
Member

@huonw huonw commented Jun 29, 2015

This fixes two false positives for the unconditional recursion lint, when functions use themselves (or almost-themselves) internally, without actually being recursive.

fn main() { let _ = main; }
trait Bar {
    fn method<T: Bar>(&self, x: &T) {
        x.method(x)
    }
}

huonw added 2 commits June 29, 2015 15:59
Specifically, just mentioning the function name as a value is fine, as
long as it isn't called, e.g. `fn main() { let _ = main; }`.

Closes rust-lang#21705.
This catches the case when a trait defines a default method that calls
itself, but on a type that isn't necessarily `Self`, e.g. there's no
reason that `T = Self` in the following, so the call isn't necessarily
recursive (`T` may override the call).

    trait Bar {
        fn method<T: Bar>(&self, x: &T) {
            x.method(x)
        }
    }

Fixes rust-lang#26333.
@rust-highfive
Copy link
Contributor

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@huonw huonw changed the title Handle two edge cases in the unconditional recursion Handle two edge cases in the unconditional recursion lint Jun 29, 2015
@alexcrichton
Copy link
Member

@bors: r+ 900af2c

@bors
Copy link
Collaborator

bors commented Jun 30, 2015

⌛ Testing commit 900af2c with merge faa04a8...

bors added a commit that referenced this pull request Jun 30, 2015
This fixes two false positives for the unconditional recursion lint, when functions use themselves (or almost-themselves) internally, without actually being recursive.

````rust
fn main() { let _ = main; }
```
```rust
trait Bar {
    fn method<T: Bar>(&self, x: &T) {
        x.method(x)
    }
}
```
@bors bors merged commit 900af2c into rust-lang:master Jun 30, 2015
@huonw huonw deleted the unc-rec branch June 30, 2015 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants