diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-11 07:48:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-11 07:48:08 +0100 |
| commit | a59d312280d7fdc5537a9216c2d4eff2594b8515 (patch) | |
| tree | 8ed1149fbe630834213696d428c56149dc04fdab | |
| parent | ddba967855d8795c37d7690fa1586a42af2923b6 (diff) | |
| parent | 6bc28c82c4bf729d6d0ad98df01b53653443b6fc (diff) | |
| download | rust-a59d312280d7fdc5537a9216c2d4eff2594b8515.tar.gz rust-a59d312280d7fdc5537a9216c2d4eff2594b8515.zip | |
Rollup merge of #93861 - JulianKnodt:notraitace, r=wesleywiser
Fix ICE if no trait assoc const eq Fixes #93835
| -rw-r--r-- | compiler/rustc_typeck/src/collect/type_of.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/associated-consts/issue-93835.rs | 10 | ||||
| -rw-r--r-- | src/test/ui/associated-consts/issue-93835.stderr | 66 |
3 files changed, 79 insertions, 2 deletions
diff --git a/compiler/rustc_typeck/src/collect/type_of.rs b/compiler/rustc_typeck/src/collect/type_of.rs index 912a16ffb8a..471cd2e6ccb 100644 --- a/compiler/rustc_typeck/src/collect/type_of.rs +++ b/compiler/rustc_typeck/src/collect/type_of.rs @@ -508,8 +508,9 @@ pub(super) fn type_of(tcx: TyCtxt<'_>, def_id: DefId) -> Ty<'_> { }) }) => { - // FIXME(associated_const_equality) when does this unwrap fail? I have no idea what case it would. - let trait_def_id = trait_ref.trait_def_id().unwrap(); + let Some(trait_def_id) = trait_ref.trait_def_id() else { + return tcx.ty_error_with_message(DUMMY_SP, "Could not find trait"); + }; let assoc_items = tcx.associated_items(trait_def_id); let assoc_item = assoc_items.find_by_name_and_kind( tcx, binding.ident, ty::AssocKind::Const, def_id.to_def_id(), diff --git a/src/test/ui/associated-consts/issue-93835.rs b/src/test/ui/associated-consts/issue-93835.rs new file mode 100644 index 00000000000..5c7b065983e --- /dev/null +++ b/src/test/ui/associated-consts/issue-93835.rs @@ -0,0 +1,10 @@ +fn e() { + p:a<p:p<e=6>> + //~^ ERROR comparison operators + //~| ERROR cannot find value + //~| ERROR associated const equality + //~| ERROR associated const equality + //~| ERROR associated type bounds +} + +fn main() {} diff --git a/src/test/ui/associated-consts/issue-93835.stderr b/src/test/ui/associated-consts/issue-93835.stderr new file mode 100644 index 00000000000..12df0e4381d --- /dev/null +++ b/src/test/ui/associated-consts/issue-93835.stderr @@ -0,0 +1,66 @@ +error: comparison operators cannot be chained + --> $DIR/issue-93835.rs:2:8 + | +LL | fn e() { + | - while parsing this struct +LL | p:a<p:p<e=6>> + | ^ ^ + | + = help: use `::<...>` instead of `<...>` to specify lifetime, type, or const arguments + = help: or use `(...)` if you meant to specify fn arguments + +error[E0425]: cannot find value `p` in this scope + --> $DIR/issue-93835.rs:2:5 + | +LL | p:a<p:p<e=6>> + | ^ not found in this scope + | +help: you might have meant to write a `struct` literal + | +LL ~ fn e() { SomeStruct { +LL | p:a<p:p<e=6>> +LL | +LL | +LL | +LL | + ... +help: maybe you meant to write a path separator here + | +LL | p::a<p:p<e=6>> + | ~~ +help: maybe you meant to write an assignment here + | +LL | let p:a<p:p<e=6>> + | ~~~~~ + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-93835.rs:2:13 + | +LL | p:a<p:p<e=6>> + | ^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0658]: associated const equality is incomplete + --> $DIR/issue-93835.rs:2:13 + | +LL | p:a<p:p<e=6>> + | ^^^ + | + = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information + = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/issue-93835.rs:2:9 + | +LL | p:a<p:p<e=6>> + | ^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0425, E0658. +For more information about an error, try `rustc --explain E0425`. |
