about summary refs log tree commit diff
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2024-07-22 16:44:06 +0800
committerGitHub <noreply@github.com>2024-07-22 16:44:06 +0800
commitf4d6d997e33d34676e5bc273f24712201f85fccb (patch)
treea1f44cfa5217b4fa0f7d4238b7cfa177b9a88c8e
parent7d81e092a1f9f37005e5129bd31dd31b32e1d616 (diff)
parent95f091693f7d7c2613e5a7980989dff37dc3b18b (diff)
downloadrust-f4d6d997e33d34676e5bc273f24712201f85fccb.tar.gz
rust-f4d6d997e33d34676e5bc273f24712201f85fccb.zip
Rollup merge of #128035 - tiif:issue-125837, r=lcnr
Add test for #125837

Fixes #125837
-rw-r--r--tests/ui/mir/ice-mir-const-qualif-125837.rs17
-rw-r--r--tests/ui/mir/ice-mir-const-qualif-125837.stderr41
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/ui/mir/ice-mir-const-qualif-125837.rs b/tests/ui/mir/ice-mir-const-qualif-125837.rs
new file mode 100644
index 00000000000..a0f57caaba4
--- /dev/null
+++ b/tests/ui/mir/ice-mir-const-qualif-125837.rs
@@ -0,0 +1,17 @@
+// Test for ICE: mir_const_qualif: index out of bounds: the len is 0 but the index is 0
+// https://github.com/rust-lang/rust/issues/125837
+
+use std::fmt::Debug;
+
+trait Foo<Item> {}
+
+impl<Item, D: Debug + Clone> Foo for D {
+//~^ ERROR missing generics for trait `Foo`
+    fn foo<'a>(&'a self) -> impl Debug {
+    //~^ ERROR method `foo` is not a member of trait `Foo`
+        const { return }
+//~^ ERROR return statement outside of function body
+    }
+}
+
+pub fn main() {}
diff --git a/tests/ui/mir/ice-mir-const-qualif-125837.stderr b/tests/ui/mir/ice-mir-const-qualif-125837.stderr
new file mode 100644
index 00000000000..003b327210b
--- /dev/null
+++ b/tests/ui/mir/ice-mir-const-qualif-125837.stderr
@@ -0,0 +1,41 @@
+error[E0407]: method `foo` is not a member of trait `Foo`
+  --> $DIR/ice-mir-const-qualif-125837.rs:10:5
+   |
+LL | /     fn foo<'a>(&'a self) -> impl Debug {
+LL | |
+LL | |         const { return }
+LL | |
+LL | |     }
+   | |_____^ not a member of trait `Foo`
+
+error[E0107]: missing generics for trait `Foo`
+  --> $DIR/ice-mir-const-qualif-125837.rs:8:30
+   |
+LL | impl<Item, D: Debug + Clone> Foo for D {
+   |                              ^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `Item`
+  --> $DIR/ice-mir-const-qualif-125837.rs:6:7
+   |
+LL | trait Foo<Item> {}
+   |       ^^^ ----
+help: add missing generic argument
+   |
+LL | impl<Item, D: Debug + Clone> Foo<Item> for D {
+   |                                 ++++++
+
+error[E0572]: return statement outside of function body
+  --> $DIR/ice-mir-const-qualif-125837.rs:12:17
+   |
+LL | /     fn foo<'a>(&'a self) -> impl Debug {
+LL | |
+LL | |         const { return }
+   | |               --^^^^^^-- the return is part of this body...
+LL | |
+LL | |     }
+   | |_____- ...not the enclosing function body
+
+error: aborting due to 3 previous errors
+
+Some errors have detailed explanations: E0107, E0407, E0572.
+For more information about an error, try `rustc --explain E0107`.