mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Filter out RPITITs when suggesting unconstrained assoc type on too many generics
This commit is contained in:
parent
a6434ef9c0
commit
88d7ea36e9
@ -495,6 +495,7 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
|
||||
.iter()
|
||||
.any(|constraint| constraint.ident.name == item.name)
|
||||
})
|
||||
.filter(|item| !item.is_impl_trait_in_trait())
|
||||
.map(|item| self.tcx.item_ident(item.def_id).to_string())
|
||||
.collect()
|
||||
} else {
|
||||
|
@ -0,0 +1,14 @@
|
||||
// There's a suggestion that turns `Iterator<u32>` into `Iterator<Item = u32>`
|
||||
// if we have more generics than the trait wants. Let's not consider RPITITs
|
||||
// for this, since that makes no sense right now.
|
||||
|
||||
trait Foo {
|
||||
fn bar(self) -> impl Sized;
|
||||
}
|
||||
|
||||
impl Foo<u8> for () {
|
||||
//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied
|
||||
fn bar(self) -> impl Sized {}
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,17 @@
|
||||
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
|
||||
--> $DIR/dont-consider-unconstrained-rpitits.rs:9:6
|
||||
|
|
||||
LL | impl Foo<u8> for () {
|
||||
| ^^^---- help: remove the unnecessary generics
|
||||
| |
|
||||
| expected 0 generic arguments
|
||||
|
|
||||
note: trait defined here, with 0 generic parameters
|
||||
--> $DIR/dont-consider-unconstrained-rpitits.rs:5:7
|
||||
|
|
||||
LL | trait Foo {
|
||||
| ^^^
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0107`.
|
Loading…
Reference in New Issue
Block a user