Closed
Description
If you accidentally write a bound like:
pub struct Foo<T, I: Iterator<T>> { /* ... */ }
The error message is:
err.rs:3:22: 3:33 error: wrong number of type arguments: expected 0, found 1
err.rs:3 pub struct Foo<T, I: Iterator<T>> { x: I }
^~~~~~~~~~~
The compiler could be more helpful in these cases where a trait takes 0 arguments but has an associated type and suggest something like: Iterator has an associated type. Did you mean: I: Iterator<Item=T>?
.
Activity
nikomatsakis commentedon Jan 12, 2015
cc @Manishearth this could be a good place for a custom error attribute like the one you recently implemented
Manishearth commentedon Jan 12, 2015
Ooh, this looks doable.
Unfortunately I don't see any opportunity for sharing much code here, but I can try to move some of the code out.
frewsxcv commentedon Sep 1, 2015
Visiting for triage: nothing has changed here
playpen link
birkenfeld commentedon May 2, 2016
Current situation: the original error hasn't changed, but we get a second one that complains about the missing
Item
associated type:... which should clear it up. (But probably not if the associated type has a default?)
estebank commentedon Oct 13, 2017
librustc_typeck/astconv.rs
, methodscreate_substs_for_ast_path
,check_type_argument_count
andconv_object_ty_poly_trait_ref
will need to be changed to not emit both errors, but rather condense them into one:Care should be taken when some type arguments and associated items are expected. In those case, it's probably better to keep the current output to avoid confusion with the tradeoff of verbosity.
2 remaining items