fix #137508
rename ui tests check if res is trait def fix typo regression test for #137554
This commit is contained in:
parent
bdc97d1046
commit
b7a549725c
5 changed files with 78 additions and 1 deletions
|
@ -789,7 +789,11 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
||||||
|
|
||||||
Some(args.constraints.iter().filter_map(|constraint| {
|
Some(args.constraints.iter().filter_map(|constraint| {
|
||||||
let ident = constraint.ident;
|
let ident = constraint.ident;
|
||||||
let trait_def = path.res.def_id();
|
|
||||||
|
let Res::Def(DefKind::Trait, trait_def) = path.res else {
|
||||||
|
return None;
|
||||||
|
};
|
||||||
|
|
||||||
let assoc_item = tcx.associated_items(trait_def).find_by_name_and_kind(
|
let assoc_item = tcx.associated_items(trait_def).find_by_name_and_kind(
|
||||||
tcx,
|
tcx,
|
||||||
ident,
|
ident,
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
// Regression test for <https://github.com/rust-lang/rust/issues/137554>.
|
||||||
|
|
||||||
|
fn main() -> dyn Iterator + ?Iterator::advance_by(usize) {
|
||||||
|
//~^ ERROR `?Trait` is not permitted in trait object types
|
||||||
|
//~| ERROR expected trait, found associated function `Iterator::advance_by`
|
||||||
|
//~| ERROR the value of the associated type `Item` in `Iterator` must be specified
|
||||||
|
todo!()
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
error[E0658]: `?Trait` is not permitted in trait object types
|
||||||
|
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:29
|
||||||
|
|
|
||||||
|
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0404]: expected trait, found associated function `Iterator::advance_by`
|
||||||
|
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:30
|
||||||
|
|
|
||||||
|
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not a trait
|
||||||
|
|
||||||
|
error[E0191]: the value of the associated type `Item` in `Iterator` must be specified
|
||||||
|
--> $DIR/missing-associated_item_or_field_def_ids.rs:3:18
|
||||||
|
|
|
||||||
|
LL | fn main() -> dyn Iterator + ?Iterator::advance_by(usize) {
|
||||||
|
| ^^^^^^^^ help: specify the associated type: `Iterator<Item = Type>`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0191, E0404, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0191`.
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Fix for <https://github.com/rust-lang/rust/issues/137508>.
|
||||||
|
|
||||||
|
trait Tr {
|
||||||
|
type Item;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: dyn Tr + ?Foo<Assoc = ()>;
|
||||||
|
//~^ ERROR: `?Trait` is not permitted in trait object types
|
||||||
|
//~| ERROR: cannot find trait `Foo` in this scope
|
||||||
|
//~| ERROR: the value of the associated type `Item` in `Tr` must be specified
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
error[E0658]: `?Trait` is not permitted in trait object types
|
||||||
|
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:21
|
||||||
|
|
|
||||||
|
LL | let _: dyn Tr + ?Foo<Assoc = ()>;
|
||||||
|
| ^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
|
||||||
|
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||||
|
|
||||||
|
error[E0405]: cannot find trait `Foo` in this scope
|
||||||
|
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:22
|
||||||
|
|
|
||||||
|
LL | let _: dyn Tr + ?Foo<Assoc = ()>;
|
||||||
|
| ^^^ not found in this scope
|
||||||
|
|
||||||
|
error[E0191]: the value of the associated type `Item` in `Tr` must be specified
|
||||||
|
--> $DIR/avoid-getting-associated-items-of-undefined-trait.rs:8:16
|
||||||
|
|
|
||||||
|
LL | type Item;
|
||||||
|
| --------- `Item` defined here
|
||||||
|
...
|
||||||
|
LL | let _: dyn Tr + ?Foo<Assoc = ()>;
|
||||||
|
| ^^ help: specify the associated type: `Tr<Item = Type>`
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
Some errors have detailed explanations: E0191, E0405, E0658.
|
||||||
|
For more information about an error, try `rustc --explain E0191`.
|
Loading…
Add table
Add a link
Reference in a new issue