From 2dfd77d67555ab9a5a76002bb47749a795f3a5bf Mon Sep 17 00:00:00 2001 From: kadmin Date: Wed, 2 Feb 2022 16:42:37 +0000 Subject: Fix ret > 1 bound if shadowed by const Prior to a change, it would only look at types in bounds. When it started looking for consts, shadowing type variables with a const would cause an ICE, so now defer looking at consts only if there are no types present. --- src/test/ui/associated-consts/shadowed-const.rs | 23 ++++++++++++++++++++++ .../ui/associated-consts/shadowed-const.stderr | 8 ++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/test/ui/associated-consts/shadowed-const.rs create mode 100644 src/test/ui/associated-consts/shadowed-const.stderr (limited to 'src') diff --git a/src/test/ui/associated-consts/shadowed-const.rs b/src/test/ui/associated-consts/shadowed-const.rs new file mode 100644 index 00000000000..cfdb391d39d --- /dev/null +++ b/src/test/ui/associated-consts/shadowed-const.rs @@ -0,0 +1,23 @@ +// Checking that none of these ICE, which was introduced in +// https://github.com/rust-lang/rust/issues/93553 +trait Foo { + type Bar; +} + +trait Baz: Foo { + const Bar: Self::Bar; +} + +trait Baz2: Foo { + const Bar: u32; + + fn foo() -> Self::Bar; +} + +trait Baz3 { + const BAR: usize; + const QUX: Self::BAR; + //~^ ERROR found associated const +} + +fn main() {} diff --git a/src/test/ui/associated-consts/shadowed-const.stderr b/src/test/ui/associated-consts/shadowed-const.stderr new file mode 100644 index 00000000000..fe21d2aec00 --- /dev/null +++ b/src/test/ui/associated-consts/shadowed-const.stderr @@ -0,0 +1,8 @@ +error: found associated const `BAR` when type was expected + --> $DIR/shadowed-const.rs:19:14 + | +LL | const QUX: Self::BAR; + | ^^^^^^^^^ + +error: aborting due to previous error + -- cgit 1.4.1-3-g733a5