Skip to content

Commit 1ac2051

Browse files
committed
fix #137508
rename ui tests
1 parent bdc97d1 commit 1ac2051

File tree

3 files changed

+47
-7
lines changed

3 files changed

+47
-7
lines changed

compiler/rustc_hir_analysis/src/hir_ty_lowering/errors.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -789,13 +789,15 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
789789

790790
Some(args.constraints.iter().filter_map(|constraint| {
791791
let ident = constraint.ident;
792-
let trait_def = path.res.def_id();
793-
let assoc_item = tcx.associated_items(trait_def).find_by_name_and_kind(
794-
tcx,
795-
ident,
796-
ty::AssocKind::Type,
797-
trait_def,
798-
);
792+
let trait_def = path.res.opt_def_id();
793+
let assoc_item = trait_def.and_then(|trait_def_id| {
794+
tcx.associated_items(trait_def_id).find_by_name_and_kind(
795+
tcx,
796+
ident,
797+
ty::AssocKind::Type,
798+
trait_def_id,
799+
)
800+
});
799801

800802
Some((ident.name, assoc_item?))
801803
}))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
trait Tr {
2+
type Item;
3+
}
4+
5+
fn main() {
6+
let _: dyn Tr + ?Foo();
7+
//~^ ERROR: `?Trait` is not permitted in trait object types
8+
//~| ERROR: cannot find trait `Foo` in this scope
9+
//~| ERROR: the value of the associated type `Item` in `Tr` must be specifi
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
error[E0658]: `?Trait` is not permitted in trait object types
2+
--> $DIR/issue-137508.rs:6:21
3+
|
4+
LL | let _: dyn Tr + ?Foo();
5+
| ^^^^^^
6+
|
7+
= help: add `#![feature(more_maybe_bounds)]` to the crate attributes to enable
8+
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
9+
10+
error[E0405]: cannot find trait `Foo` in this scope
11+
--> $DIR/issue-137508.rs:6:22
12+
|
13+
LL | let _: dyn Tr + ?Foo();
14+
| ^^^ not found in this scope
15+
16+
error[E0191]: the value of the associated type `Item` in `Tr` must be specified
17+
--> $DIR/issue-137508.rs:6:16
18+
|
19+
LL | type Item;
20+
| --------- `Item` defined here
21+
...
22+
LL | let _: dyn Tr + ?Foo();
23+
| ^^ help: specify the associated type: `Tr<Item = Type>`
24+
25+
error: aborting due to 3 previous errors
26+
27+
Some errors have detailed explanations: E0191, E0405, E0658.
28+
For more information about an error, try `rustc --explain E0191`.

0 commit comments

Comments
 (0)