From c59e7fd95b985cb3622cdbf46cf31b7b250a0342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 23 Jun 2024 18:14:44 +0200 Subject: [PATCH] crashes: add more tests --- tests/crashes/126646.rs | 18 ++++++++++++++++++ tests/crashes/126648.rs | 8 ++++++++ tests/crashes/126666.rs | 18 ++++++++++++++++++ tests/crashes/126667.rs | 14 ++++++++++++++ tests/crashes/126680.rs | 21 +++++++++++++++++++++ tests/crashes/126696.rs | 24 ++++++++++++++++++++++++ tests/crashes/126725.rs | 20 ++++++++++++++++++++ tests/crashes/126744.rs | 8 ++++++++ tests/crashes/126850.rs | 11 +++++++++++ 9 files changed, 142 insertions(+) create mode 100644 tests/crashes/126646.rs create mode 100644 tests/crashes/126648.rs create mode 100644 tests/crashes/126666.rs create mode 100644 tests/crashes/126667.rs create mode 100644 tests/crashes/126680.rs create mode 100644 tests/crashes/126696.rs create mode 100644 tests/crashes/126725.rs create mode 100644 tests/crashes/126744.rs create mode 100644 tests/crashes/126850.rs diff --git a/tests/crashes/126646.rs b/tests/crashes/126646.rs new file mode 100644 index 00000000000..24e3530320a --- /dev/null +++ b/tests/crashes/126646.rs @@ -0,0 +1,18 @@ +//@ known-bug: rust-lang/rust#126646 +mod foo { + pub trait Callable { + type Output; + fn call() -> Self::Output; + } + + impl<'a, V: ?Sized> Callable for &'a () { + type Output = (); + } +} +use foo::*; + +fn test<'a>() -> impl Sized { + <&'a () as Callable>::call() +} + +fn main() {} diff --git a/tests/crashes/126648.rs b/tests/crashes/126648.rs new file mode 100644 index 00000000000..1cf3e44bba9 --- /dev/null +++ b/tests/crashes/126648.rs @@ -0,0 +1,8 @@ +//@ known-bug: rust-lang/rust#126648 +struct Outest(*const &'a ()); + +fn make() -> Outest {} + +fn main() { + if let Outest("foo") = make() {} +} diff --git a/tests/crashes/126666.rs b/tests/crashes/126666.rs new file mode 100644 index 00000000000..58526707c9a --- /dev/null +++ b/tests/crashes/126666.rs @@ -0,0 +1,18 @@ +//@ known-bug: rust-lang/rust#126666 +#![feature(const_mut_refs)] +#![feature(const_refs_to_static)] +#![feature(object_safe_for_dispatch)] + +struct Meh { + x: &'static dyn UnsafeCell, +} + +const MUH: Meh = Meh { + x: &mut *(&READONLY as *const _ as *mut _), +}; + +static READONLY: i32 = 0; + +trait UnsafeCell<'a> {} + +pub fn main() {} diff --git a/tests/crashes/126667.rs b/tests/crashes/126667.rs new file mode 100644 index 00000000000..27b170d6da5 --- /dev/null +++ b/tests/crashes/126667.rs @@ -0,0 +1,14 @@ +//@ known-bug: rust-lang/rust#126667 +#![warn(rust_2021_compatibility)] + +trait Static<'a> {} + +struct Foo((u32, u32)); + +fn main() { + type T = impl Static; + let foo: T = Foo((1u32, 2u32)); + let x = move || { + let Foo((a, b)) = foo; + }; +} diff --git a/tests/crashes/126680.rs b/tests/crashes/126680.rs new file mode 100644 index 00000000000..b1566d5e6be --- /dev/null +++ b/tests/crashes/126680.rs @@ -0,0 +1,21 @@ +//@ known-bug: rust-lang/rust#126680 +//@ compile-flags: -Zvalidate-mir +#![feature(type_alias_impl_trait)] +type Bar = impl std::fmt::Display; + +use std::path::Path; + +struct A { + pub func: fn(check: Bar, b: Option<&Path>), +} +const MY_A: A = A { + func: |check, b| { + if check { + () + } else if let Some(_) = b.and_then(|p| p.parent()) { + () + } + }, +}; + +fn main() {} diff --git a/tests/crashes/126696.rs b/tests/crashes/126696.rs new file mode 100644 index 00000000000..51dcf6cf294 --- /dev/null +++ b/tests/crashes/126696.rs @@ -0,0 +1,24 @@ +//@ known-bug: rust-lang/rust#126696 +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn can_double(x: [(); N]) +where + [(); N * 2]:, +{ + x[0]; + unimplemented!() +} + +fn foo() +where + [(); (N + 1) * 2]:, +{ + can_double([(); { N + 1 }]); + // Adding an explicit constant generic causes the ICE to go away + // can_double::<{N + 1}>([(); { N + 1 }]); +} + +fn main() { + foo::<1>(); +} diff --git a/tests/crashes/126725.rs b/tests/crashes/126725.rs new file mode 100644 index 00000000000..d7a7d21ae42 --- /dev/null +++ b/tests/crashes/126725.rs @@ -0,0 +1,20 @@ +//@ known-bug: rust-lang/rust#126725 +trait Foo { + fn foo<'a>(&'a self) -> <&'a impl Sized as Bar>::Output; +} + +trait Bar { + type Output; +} + +struct X(i32); + +impl<'a> Bar for &'a X { + type Output = &'a i32; +} + +impl Foo for X { + fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output { + &self.0 + } +} diff --git a/tests/crashes/126744.rs b/tests/crashes/126744.rs new file mode 100644 index 00000000000..ed562c86e61 --- /dev/null +++ b/tests/crashes/126744.rs @@ -0,0 +1,8 @@ +//@ known-bug: rust-lang/rust#126744 +struct X {,} + +fn main() { + || { + if let X { x: 1,} = (X {}) {} + }; +} diff --git a/tests/crashes/126850.rs b/tests/crashes/126850.rs new file mode 100644 index 00000000000..0ddc24c8bb1 --- /dev/null +++ b/tests/crashes/126850.rs @@ -0,0 +1,11 @@ +//@ known-bug: rust-lang/rust#126850 +fn bug() -> impl Iterator< + Item = [(); { + |found: &String| Some(false); + 4 + }], +> { + std::iter::empty() +} + +fn main() {}