diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-03 12:08:54 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-03 12:08:54 +0100 |
| commit | 625264329f8019013172c158cec2068f6b162acc (patch) | |
| tree | 78f6924bec05d90e5327407723e88f5ba1267706 | |
| parent | a7a0586618ab7b14f3ffeb95b14e90670ae42e00 (diff) | |
| parent | b9196757a0c2c9ddbbca4372ca272b0e1fec077f (diff) | |
| download | rust-625264329f8019013172c158cec2068f6b162acc.tar.gz rust-625264329f8019013172c158cec2068f6b162acc.zip | |
Rollup merge of #132523 - ranger-ross:test-issue-117446, r=compiler-errors
Added regression test for generics index out of bounds Added a regression test for #117446 This ICE was fixed in Rust 1.75 but a regression test was never added. This PR adds a UI test with a reduced version of the original bug report that does not rely on external crates.
| -rw-r--r-- | tests/ui/traits/ice-index-out-of-bounds-issue-117446.rs | 24 | ||||
| -rw-r--r-- | tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr | 33 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/traits/ice-index-out-of-bounds-issue-117446.rs b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.rs new file mode 100644 index 00000000000..fa31d8b820c --- /dev/null +++ b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.rs @@ -0,0 +1,24 @@ +//@ check-fail +// +// Regression for https://github.com/rust-lang/rust/issues/117446 + +pub struct Repeated<T>(Vec<T>); + +trait Foo<'a> { + fn outer<D>() -> Option<()>; +} + +impl<'a, T> Foo<'a> for Repeated<T> { + fn outer() -> Option<()> { + //~^ ERROR associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter [E0049] + //~^^ ERROR mismatched types [E0308] + fn inner<Q>(value: Option<()>) -> Repeated<Q> { + match value { + _ => Self(unimplemented!()), + //~^ ERROR can't reference `Self` constructor from outer item [E0401] + } + } + } +} + +fn main() {} diff --git a/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr new file mode 100644 index 00000000000..ad33a70ed3b --- /dev/null +++ b/tests/ui/traits/ice-index-out-of-bounds-issue-117446.stderr @@ -0,0 +1,33 @@ +error[E0049]: associated function `outer` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:13 + | +LL | fn outer<D>() -> Option<()>; + | - expected 1 type parameter +... +LL | fn outer() -> Option<()> { + | ^ found 0 type parameters + +error[E0308]: mismatched types + --> $DIR/ice-index-out-of-bounds-issue-117446.rs:12:19 + | +LL | fn outer() -> Option<()> { + | ----- ^^^^^^^^^^ expected `Option<()>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected enum `Option<()>` + found unit type `()` + +error[E0401]: can't reference `Self` constructor from outer item + --> $DIR/ice-index-out-of-bounds-issue-117446.rs:17:22 + | +LL | impl<'a, T> Foo<'a> for Repeated<T> { + | ----------------------------------- the inner item doesn't inherit generics from this impl, so `Self` is invalid to reference +... +LL | _ => Self(unimplemented!()), + | ^^^^ help: replace `Self` with the actual type: `Repeated` + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0049, E0308, E0401. +For more information about an error, try `rustc --explain E0049`. |
