-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.
Description
This code
struct Alpha;
impl<'a, T> Alpha {
fn yeah(arg: &'a T) {}
}Should generate two lint warnings on the impl line
- The lifetime
'ais not needed by the struct. - The type
Tis not needed by the struct.
This should apply similarly to trait impls where the lifetime / types are not needed by either the trait or struct.
Update as of rustc 1.0.0-dev (82cc57b6a 2015-01-13 09:54:08 -0800)
Type parameters now have a warning like "the type parameter T is not constrained by the impl trait, self type, or predicates", so that part is good. I think we still want something for lifetimes.
Original report below
$ rustc --version=verbose
rustc 0.13.0-dev (3327ecca4 2014-11-01 22:41:48 +0000)
binary: rustc
commit-hash: 3327ecca422046699315122345c6c050ab73804b
commit-date: 2014-11-01 22:41:48 +0000
host: x86_64-apple-darwin
release: 0.13.0-dev
This code (playpen link)
struct Parser;
impl<Z> Parser {
fn parse_item(&self) {}
fn parse_items(&self) {
self.parse_item();
}
}
fn main() {}Fails to compile:
$ rustc --test repro.rs
repro.rs:7:9: 7:26 error: unable to infer enough type information about `_`; type annotations required
repro.rs:7 self.parse_item();
^~~~~~~~~~~~~~~~~
Removing the <Z> allows the code to compile. This is a reduced example from my full app, where the type parameter is actually used. 😀
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.