Skip to content

Don't compute name of associated item if it's an RPITIT #139981

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -487,14 +487,14 @@ impl<'a, 'tcx> WrongNumberOfGenericArgs<'a, 'tcx> {
items
.in_definition_order()
.filter(|item| item.is_type())
.filter(|item| !item.is_impl_trait_in_trait())
.filter(|item| {
!self
.gen_args
.constraints
.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 {
Expand Down
12 changes: 12 additions & 0 deletions tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
trait Foo {
fn rpitit() -> impl Sized;
}

// Ensure that we don't try to probe the name of the RPITIT when looking for
// fixes to suggest for the redundant generic below.

fn test<T: Foo<i32, Assoc = i32>>() {}
//~^ ERROR trait takes 0 generic arguments but 1 generic argument was supplied
//~| ERROR associated type `Assoc` not found for `Foo`

fn main() {}
24 changes: 24 additions & 0 deletions tests/ui/impl-trait/in-trait/dont-probe-missing-item-name-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied
--> $DIR/dont-probe-missing-item-name-2.rs:8:12
|
LL | fn test<T: Foo<i32, Assoc = i32>>() {}
| ^^^------------------ help: remove the unnecessary generics
| |
| expected 0 generic arguments
|
note: trait defined here, with 0 generic parameters
--> $DIR/dont-probe-missing-item-name-2.rs:1:7
|
LL | trait Foo {
| ^^^

error[E0220]: associated type `Assoc` not found for `Foo`
--> $DIR/dont-probe-missing-item-name-2.rs:8:21
|
LL | fn test<T: Foo<i32, Assoc = i32>>() {}
| ^^^^^ associated type `Assoc` not found

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0107, E0220.
For more information about an error, try `rustc --explain E0107`.
Loading