Skip to content

Commit a59d312

Browse files
authored
Rollup merge of #93861 - JulianKnodt:notraitace, r=wesleywiser
Fix ICE if no trait assoc const eq Fixes #93835
2 parents ddba967 + 6bc28c8 commit a59d312

File tree

3 files changed

+79
-2
lines changed

3 files changed

+79
-2
lines changed

compiler/rustc_typeck/src/collect/type_of.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> {
508508
})
509509
}) =>
510510
{
511-
// FIXME(associated_const_equality) when does this unwrap fail? I have no idea what case it would.
512-
let trait_def_id = trait_ref.trait_def_id().unwrap();
511+
let Some(trait_def_id) = trait_ref.trait_def_id() else {
512+
return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait");
513+
};
513514
let assoc_items = tcx.associated_items(trait_def_id);
514515
let assoc_item = assoc_items.find_by_name_and_kind(
515516
tcx, binding.ident, ty::AssocKind::Const, def_id.to_def_id(),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
fn e() {
2+
p:a<p:p<e=6>>
3+
//~^ ERROR comparison operators
4+
//~| ERROR cannot find value
5+
//~| ERROR associated const equality
6+
//~| ERROR associated const equality
7+
//~| ERROR associated type bounds
8+
}
9+
10+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
error: comparison operators cannot be chained
2+
--> $DIR/issue-93835.rs:2:8
3+
|
4+
LL | fn e() {
5+
| - while parsing this struct
6+
LL | p:a<p:p<e=6>>
7+
| ^ ^
8+
|
9+
= help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments
10+
= help: or use `(...)` if you meant to specify fn arguments
11+
12+
error[E0425]: cannot find value `p` in this scope
13+
--> $DIR/issue-93835.rs:2:5
14+
|
15+
LL | p:a<p:p<e=6>>
16+
| ^ not found in this scope
17+
|
18+
help: you might have meant to write a `struct` literal
19+
|
20+
LL ~ fn e() { SomeStruct {
21+
LL | p:a<p:p<e=6>>
22+
LL |
23+
LL |
24+
LL |
25+
LL |
26+
...
27+
help: maybe you meant to write a path separator here
28+
|
29+
LL | p::a<p:p<e=6>>
30+
| ~~
31+
help: maybe you meant to write an assignment here
32+
|
33+
LL | let p:a<p:p<e=6>>
34+
| ~~~~~
35+
36+
error[E0658]: associated const equality is incomplete
37+
--> $DIR/issue-93835.rs:2:13
38+
|
39+
LL | p:a<p:p<e=6>>
40+
| ^^^
41+
|
42+
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
43+
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
44+
45+
error[E0658]: associated const equality is incomplete
46+
--> $DIR/issue-93835.rs:2:13
47+
|
48+
LL | p:a<p:p<e=6>>
49+
| ^^^
50+
|
51+
= note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
52+
= help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
53+
54+
error[E0658]: associated type bounds are unstable
55+
--> $DIR/issue-93835.rs:2:9
56+
|
57+
LL | p:a<p:p<e=6>>
58+
| ^^^^^^^^
59+
|
60+
= note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information
61+
= help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable
62+
63+
error: aborting due to 5 previous errors
64+
65+
Some errors have detailed explanations: E0425, E0658.
66+
For more information about an error, try `rustc --explain E0425`.

0 commit comments

Comments
 (0)