about summary refs log tree commit diff
path: root/src/test
diff options
context:
space:
mode:
authorkadmin <julianknodt@gmail.com>2022-02-02 16:42:37 +0000
committerkadmin <julianknodt@gmail.com>2022-02-03 15:17:51 +0000
commit2dfd77d67555ab9a5a76002bb47749a795f3a5bf (patch)
tree79ebd4003c143deb2e9e696b057ea95ffbc712a8 /src/test
parentd5f9c40e6a9ecc62432e71e886cef83a4c2c9b98 (diff)
downloadrust-2dfd77d67555ab9a5a76002bb47749a795f3a5bf.tar.gz
rust-2dfd77d67555ab9a5a76002bb47749a795f3a5bf.zip
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.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/ui/associated-consts/shadowed-const.rs23
-rw-r--r--src/test/ui/associated-consts/shadowed-const.stderr8
2 files changed, 31 insertions, 0 deletions
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
+