From e5d100363ad5bb72037d56093f794de4e10a99bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sat, 25 May 2024 12:05:49 +0200 Subject: [PATCH 1/2] crashes: increment the number of tracked ones --- tests/crashes/123255.rs | 13 +++++++++++++ tests/crashes/123276.rs | 25 +++++++++++++++++++++++++ tests/crashes/123887.rs | 15 +++++++++++++++ tests/crashes/125013-1.rs | 5 +++++ tests/crashes/125013-2.rs | 16 ++++++++++++++++ tests/crashes/125014.rs | 17 +++++++++++++++++ tests/crashes/125059.rs | 12 ++++++++++++ tests/crashes/125323.rs | 6 ++++++ tests/crashes/125370.rs | 16 ++++++++++++++++ tests/crashes/125432.rs | 17 +++++++++++++++++ tests/crashes/125476.rs | 3 +++ tests/crashes/125512.rs | 10 ++++++++++ tests/crashes/125520.rs | 16 ++++++++++++++++ 13 files changed, 171 insertions(+) create mode 100644 tests/crashes/123255.rs create mode 100644 tests/crashes/123276.rs create mode 100644 tests/crashes/123887.rs create mode 100644 tests/crashes/125013-1.rs create mode 100644 tests/crashes/125013-2.rs create mode 100644 tests/crashes/125014.rs create mode 100644 tests/crashes/125059.rs create mode 100644 tests/crashes/125323.rs create mode 100644 tests/crashes/125370.rs create mode 100644 tests/crashes/125432.rs create mode 100644 tests/crashes/125476.rs create mode 100644 tests/crashes/125512.rs create mode 100644 tests/crashes/125520.rs diff --git a/tests/crashes/123255.rs b/tests/crashes/123255.rs new file mode 100644 index 0000000000000..a94a2a0422e7e --- /dev/null +++ b/tests/crashes/123255.rs @@ -0,0 +1,13 @@ +//@ known-bug: rust-lang/rust#123255 +//@ edition:2021 +#![crate_type = "lib"] + +pub fn a() {} + +mod handlers { + pub struct C(&()); + pub fn c() -> impl Fn() -> C { + let a1 = (); + || C((crate::a(), a1).into()) + } +} diff --git a/tests/crashes/123276.rs b/tests/crashes/123276.rs new file mode 100644 index 0000000000000..d2246f595838d --- /dev/null +++ b/tests/crashes/123276.rs @@ -0,0 +1,25 @@ +//@ known-bug: rust-lang/rust#123276 +//@ edition:2021 + +async fn create_task() { + _ = Some(async { bind(documentation_filter()) }); +} + +async fn bind>(_: F) {} + +fn documentation_filter() -> impl Filter { + AndThen +} + +trait Filter { + type Future; +} + +struct AndThen; + +impl Filter for AndThen +where + Foo: Filter, +{ + type Future = (); +} diff --git a/tests/crashes/123887.rs b/tests/crashes/123887.rs new file mode 100644 index 0000000000000..68e2fb0325c3d --- /dev/null +++ b/tests/crashes/123887.rs @@ -0,0 +1,15 @@ +//@ known-bug: rust-lang/rust#123887 +//@ compile-flags: -Clink-dead-code + +#![feature(extern_types)] +#![feature(unsized_fn_params)] + +extern "C" { + pub type ExternType; +} + +impl ExternType { + pub fn f(self) {} +} + +pub fn main() {} diff --git a/tests/crashes/125013-1.rs b/tests/crashes/125013-1.rs new file mode 100644 index 0000000000000..ae66d7a146698 --- /dev/null +++ b/tests/crashes/125013-1.rs @@ -0,0 +1,5 @@ +//@ known-bug: rust-lang/rust#125013 +//@ edition:2021 +use io::{self as std}; +use std::ops::Deref::{self as io}; +pub fn main() {} diff --git a/tests/crashes/125013-2.rs b/tests/crashes/125013-2.rs new file mode 100644 index 0000000000000..a14c8a76b63ee --- /dev/null +++ b/tests/crashes/125013-2.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#125013 +//@ edition:2021 +mod a { + pub mod b { + pub mod c { + pub trait D {} + } + } +} + +use a::*; + +use e as b; +use b::c::D as e; + +fn main() { } diff --git a/tests/crashes/125014.rs b/tests/crashes/125014.rs new file mode 100644 index 0000000000000..b29042ee5983a --- /dev/null +++ b/tests/crashes/125014.rs @@ -0,0 +1,17 @@ +//@ known-bug: rust-lang/rust#125014 +//@ compile-flags: -Znext-solver=coherence +#![feature(specialization)] + +trait Foo {} + +impl Foo for ::Output {} + +impl Foo for u32 {} + +trait Assoc { + type Output; +} +impl Output for u32 {} +impl Assoc for ::Output { + default type Output = bool; +} diff --git a/tests/crashes/125059.rs b/tests/crashes/125059.rs new file mode 100644 index 0000000000000..7e9f7414816e8 --- /dev/null +++ b/tests/crashes/125059.rs @@ -0,0 +1,12 @@ +//@ known-bug: rust-lang/rust#125059 +#![feature(deref_patterns)] +#![allow(incomplete_features)] + +fn simple_vec(vec: Vec) -> u32 { + (|| match Vec::::new() { + deref!([]) => 100, + _ => 2000, + })() +} + +fn main() {} diff --git a/tests/crashes/125323.rs b/tests/crashes/125323.rs new file mode 100644 index 0000000000000..180b7bbad097d --- /dev/null +++ b/tests/crashes/125323.rs @@ -0,0 +1,6 @@ +//@ known-bug: rust-lang/rust#125323 +fn main() { + for _ in 0..0 { + [(); loop {}]; + } +} diff --git a/tests/crashes/125370.rs b/tests/crashes/125370.rs new file mode 100644 index 0000000000000..8640d88a5d7f9 --- /dev/null +++ b/tests/crashes/125370.rs @@ -0,0 +1,16 @@ +//@ known-bug: rust-lang/rust#125370 + +type Field3 = i64; + +#[repr(C)] +union DummyUnion { + field3: Field3, +} + +const UNION: DummyUnion = loop {}; + +const fn read_field2() -> Field2 { + const FIELD2: Field2 = loop { + UNION.field3 + }; +} diff --git a/tests/crashes/125432.rs b/tests/crashes/125432.rs new file mode 100644 index 0000000000000..659bb3ce21dea --- /dev/null +++ b/tests/crashes/125432.rs @@ -0,0 +1,17 @@ +//@ known-bug: rust-lang/rust#125432 + +fn separate_arms() { + // Here both arms perform assignments, but only one is illegal. + + let mut x = None; + match x { + None => { + // It is ok to reassign x here, because there is in + // fact no outstanding loan of x! + x = Some(0); + } + Some(right) => consume(right), + } +} + +fn main() {} diff --git a/tests/crashes/125476.rs b/tests/crashes/125476.rs new file mode 100644 index 0000000000000..c6cb4db7d231b --- /dev/null +++ b/tests/crashes/125476.rs @@ -0,0 +1,3 @@ +//@ known-bug: rust-lang/rust#125476 +pub struct Data([u8; usize::MAX >> 16]); +const _: &'static [Data] = &[]; diff --git a/tests/crashes/125512.rs b/tests/crashes/125512.rs new file mode 100644 index 0000000000000..1672b24a11437 --- /dev/null +++ b/tests/crashes/125512.rs @@ -0,0 +1,10 @@ +//@ known-bug: rust-lang/rust#125512 +//@ edition:2021 +#![feature(object_safe_for_dispatch)] +trait B { + fn f(a: A) -> A; +} +trait A { + fn concrete(b: B) -> B; +} +fn main() {} diff --git a/tests/crashes/125520.rs b/tests/crashes/125520.rs new file mode 100644 index 0000000000000..c6756053c210a --- /dev/null +++ b/tests/crashes/125520.rs @@ -0,0 +1,16 @@ +//@ known-bug: #125520 +#![feature(generic_const_exprs)] + +struct Outer(); +impl Outer +where + [(); A + (B * 2)]:, +{ + fn i() -> Self { + Self + } +} + +fn main() { + Outer::<1, 1>::o(); +} From bae945201f72cf548b3b2d8cfd545812cccfae4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Mon, 27 May 2024 17:58:43 +0200 Subject: [PATCH 2/2] remove fixed crashes, add fixed crashes to tests, add new cashed found in the meantime --- tests/crashes/125370.rs | 16 --- tests/crashes/125432.rs | 17 --- tests/crashes/125476.rs | 1 + tests/crashes/125520.rs | 16 --- tests/crashes/125553.rs | 15 +++ tests/crashes/125556.rs | 14 ++ ...-125520-layout-mismatch-mulwithoverflow.rs | 27 ++++ ...520-layout-mismatch-mulwithoverflow.stderr | 125 ++++++++++++++++++ .../ui/const-generics/issues/issue-105821.rs | 2 +- 9 files changed, 183 insertions(+), 50 deletions(-) delete mode 100644 tests/crashes/125370.rs delete mode 100644 tests/crashes/125432.rs delete mode 100644 tests/crashes/125520.rs create mode 100644 tests/crashes/125553.rs create mode 100644 tests/crashes/125556.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs create mode 100644 tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr diff --git a/tests/crashes/125370.rs b/tests/crashes/125370.rs deleted file mode 100644 index 8640d88a5d7f9..0000000000000 --- a/tests/crashes/125370.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: rust-lang/rust#125370 - -type Field3 = i64; - -#[repr(C)] -union DummyUnion { - field3: Field3, -} - -const UNION: DummyUnion = loop {}; - -const fn read_field2() -> Field2 { - const FIELD2: Field2 = loop { - UNION.field3 - }; -} diff --git a/tests/crashes/125432.rs b/tests/crashes/125432.rs deleted file mode 100644 index 659bb3ce21dea..0000000000000 --- a/tests/crashes/125432.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ known-bug: rust-lang/rust#125432 - -fn separate_arms() { - // Here both arms perform assignments, but only one is illegal. - - let mut x = None; - match x { - None => { - // It is ok to reassign x here, because there is in - // fact no outstanding loan of x! - x = Some(0); - } - Some(right) => consume(right), - } -} - -fn main() {} diff --git a/tests/crashes/125476.rs b/tests/crashes/125476.rs index c6cb4db7d231b..aa9a081388d91 100644 --- a/tests/crashes/125476.rs +++ b/tests/crashes/125476.rs @@ -1,3 +1,4 @@ //@ known-bug: rust-lang/rust#125476 +//@ only-x86_64 pub struct Data([u8; usize::MAX >> 16]); const _: &'static [Data] = &[]; diff --git a/tests/crashes/125520.rs b/tests/crashes/125520.rs deleted file mode 100644 index c6756053c210a..0000000000000 --- a/tests/crashes/125520.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ known-bug: #125520 -#![feature(generic_const_exprs)] - -struct Outer(); -impl Outer -where - [(); A + (B * 2)]:, -{ - fn i() -> Self { - Self - } -} - -fn main() { - Outer::<1, 1>::o(); -} diff --git a/tests/crashes/125553.rs b/tests/crashes/125553.rs new file mode 100644 index 0000000000000..142c06775bb87 --- /dev/null +++ b/tests/crashes/125553.rs @@ -0,0 +1,15 @@ +//@ known-bug: rust-lang/rust#125553 +//@ edition:2021 + +#[derive(Copy, Clone)] +struct Foo((u32, u32)); + +fn main() { + type T = impl Copy(Copy, Clone) + let foo: T = Foo((1u32, 1u32)); + let x = move || { + let derive = move || { + let Foo((a, b)) = foo; + }; + }; +} diff --git a/tests/crashes/125556.rs b/tests/crashes/125556.rs new file mode 100644 index 0000000000000..f2e2a991b11ec --- /dev/null +++ b/tests/crashes/125556.rs @@ -0,0 +1,14 @@ +//@ known-bug: rust-lang/rust#125556 +//@ compile-flags: -Znext-solver=coherence + +#![feature(generic_const_exprs)] + +pub struct A {} + +impl A<2> { + pub const fn B() {} +} + +impl A<2> { + pub const fn B() {} +} diff --git a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs new file mode 100644 index 0000000000000..cd2dc3f4fe85d --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.rs @@ -0,0 +1,27 @@ +// issue: rust-lang/rust#125520 +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + +struct Outer(); +impl Outer +//~^ ERROR the constant `A` is not of type `i64` +//~| ERROR the constant `B` is not of type `i64` +//~| ERROR mismatched types +//~| ERROR mismatched types +where + [(); A + (B * 2)]:, +{ + fn i() -> Self { + //~^ ERROR the constant `A` is not of type `i64` + //~| ERROR the constant `B` is not of type `i64` + Self + //~^ ERROR mismatched types + //~| ERROR the constant `A` is not of type `i64` + //~| ERROR the constant `B` is not of type `i64` + } +} + +fn main() { + Outer::<1, 1>::o(); + //~^ ERROR no function or associated item named `o` found for struct `Outer` in the current scope +} diff --git a/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr new file mode 100644 index 0000000000000..2dbd69fd3bc14 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/ice-125520-layout-mismatch-mulwithoverflow.stderr @@ -0,0 +1,125 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:2:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 for more information + = note: `#[warn(incomplete_features)]` on by default + +error: the constant `A` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:38 + | +LL | impl Outer + | ^^^^^^^^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error: the constant `B` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:38 + | +LL | impl Outer + | ^^^^^^^^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error: the constant `A` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:14:15 + | +LL | fn i() -> Self { + | ^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error: the constant `B` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:14:15 + | +LL | fn i() -> Self { + | ^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error[E0308]: mismatched types + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 + | +LL | struct Outer(); + | ---------------------------------------- `Outer` defines a struct constructor here, which should be called +... +LL | fn i() -> Self { + | ---- expected `Outer` because of return type +... +LL | Self + | ^^^^ expected `Outer`, found struct constructor + | + = note: expected struct `Outer` + found struct constructor `fn() -> Outer {Outer::}` +help: use parentheses to construct this tuple struct + | +LL | Self() + | ++ + +error: the constant `A` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 + | +LL | Self + | ^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:14 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error: the constant `B` is not of type `i64` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:17:9 + | +LL | Self + | ^^^^ expected `i64`, found `usize` + | +note: required by a bound in `Outer` + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:5:28 + | +LL | struct Outer(); + | ^^^^^^^^^^^^ required by this bound in `Outer` + +error[E0599]: no function or associated item named `o` found for struct `Outer` in the current scope + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:25:20 + | +LL | struct Outer(); + | ---------------------------------------- function or associated item `o` not found for this struct +... +LL | Outer::<1, 1>::o(); + | ^ function or associated item not found in `Outer<1, 1>` + +error[E0308]: mismatched types + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:44 + | +LL | impl Outer + | ^ expected `i64`, found `usize` + +error[E0308]: mismatched types + --> $DIR/ice-125520-layout-mismatch-mulwithoverflow.rs:6:47 + | +LL | impl Outer + | ^ expected `i64`, found `usize` + +error: aborting due to 10 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0308, E0599. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/issues/issue-105821.rs b/tests/ui/const-generics/issues/issue-105821.rs index 282cbe9249d96..e55da461605e3 100644 --- a/tests/ui/const-generics/issues/issue-105821.rs +++ b/tests/ui/const-generics/issues/issue-105821.rs @@ -1,5 +1,5 @@ //@ failure-status: 101 -//@ known-bug: unknown +//@ known-bug: rust-lang/rust#125451 //@ normalize-stderr-test "note: .*\n\n" -> "" //@ normalize-stderr-test "thread 'rustc' panicked.*\n.*\n" -> "" //@ normalize-stderr-test "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: "