crashes: add even more tests?!?

This commit is contained in:
Matthias Krüger 2024-04-17 01:01:07 +02:00
parent 468f115684
commit 06335c6532
27 changed files with 723 additions and 0 deletions

26
tests/crashes/112623.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: #112623
#![feature(const_trait_impl, effects)]
#[const_trait]
trait Value {
fn value() -> u32;
}
const fn get_value<T: ~const Value>() -> u32 {
T::value()
}
struct FortyTwo;
impl const Value for FortyTwo {
fn value() -> i64 {
42
}
}
const FORTY_TWO: u32 = get_value::<FortyTwo>();
fn main() {
assert_eq!(FORTY_TWO, 42);
}

15
tests/crashes/114198-2.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #114198
//@ compile-flags: -Zprint-mono-items=eager
impl Trait for <Ty as Owner>::Struct {}
trait Trait {
fn test(&self) {}
}
enum Ty {}
trait Owner { type Struct: ?Sized; }
impl Owner for Ty {
type Struct = dyn Trait + Send;
}
fn main() {}

13
tests/crashes/114198.rs Normal file
View File

@ -0,0 +1,13 @@
//@ known-bug: #114198
//@ compile-flags: -Zprint-mono-items=eager
#![feature(lazy_type_alias)]
impl Trait for Struct {}
trait Trait {
fn test(&self) {}
}
type Struct = dyn Trait + Send;
fn main() {}

26
tests/crashes/118185.rs Normal file
View File

@ -0,0 +1,26 @@
//@ known-bug: #118185
fn main() {
let target: Target = create_target();
target.get(0); // correct arguments work
target.get(10.0); // CRASH HERE
}
// must be generic
fn create_target<T>() -> T {
unimplemented!()
}
// unimplemented trait, but contains function with the same name
pub trait RandomTrait {
fn get(&mut self); // but less arguments
}
struct Target;
impl Target {
// correct function with arguments
pub fn get(&self, data: i32) {
unimplemented!()
}
}

12
tests/crashes/120421.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #120421
//@ compile-flags: -Zlint-mir
#![feature(never_patterns)]
enum Void {}
fn main() {
let res_void: Result<bool, Void> = Ok(true);
for (Ok(mut _x) | Err(!)) in [res_void] {}
}

25
tests/crashes/120792.rs Normal file
View File

@ -0,0 +1,25 @@
//@ known-bug: #120792
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
impl Trait<()> for () {
fn foo<'a, K>(self, _: (), _: K) {
todo!();
}
}
trait Foo<T> {}
impl<F, T> Foo<T> for F {
fn main() {
().foo((), ());
}
}
trait Trait<T> {
fn foo<'a, K>(self, _: T, _: K)
where
T: 'a,
K: 'a;
}
pub fn main() {}

27
tests/crashes/120811.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #120811
trait Container {
type Item<'a>;
}
impl Container for () {
type Item<'a> = ();
}
struct Exchange<C, F> {
_marker: std::marker::PhantomData<(C, F)>,
}
fn exchange<C, F>(_: F) -> Exchange<C, F>
where
C: Container,
for<'a> F: FnMut(&C::Item<'a>),
{
unimplemented!()
}
trait Parallelization<C> {}
impl<C, F> Parallelization<C> for Exchange<C, F> {}
fn unary_frontier<P: Parallelization<()>>(_: P) {}
fn main() {
let exchange = exchange(|_| ());
let _ = || {
unary_frontier(exchange);
};
}

20
tests/crashes/121063.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #121063
//@ compile-flags: -Zpolymorphize=on --edition=2021 -Zinline-mir=yes
use std::{
fmt, ops,
path::{Component, Path, PathBuf},
};
pub struct AbsPathBuf(PathBuf);
impl TryFrom<PathBuf> for AbsPathBuf {
type Error = PathBuf;
fn try_from(path: impl AsRef<Path>) -> Result<AbsPathBuf, PathBuf> {}
}
impl TryFrom<&str> for AbsPathBuf {
fn try_from(path: &str) -> Result<AbsPathBuf, PathBuf> {
AbsPathBuf::try_from(PathBuf::from(path))
}
}

22
tests/crashes/121127.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #121127
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
#![feature(specialization)]
pub trait Foo {
fn abc() -> u32;
}
pub trait Marker {}
impl<T> Foo for T {
default fn abc(f: fn(&T), t: &T) -> u32 {
16
}
}
impl<T: Marker> Foo for T {
fn def() -> u32 {
Self::abc()
}
}

16
tests/crashes/123456.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #123456
trait Project {
const SELF: Self;
}
fn take1(
_: Project<
SELF = {
j2.join().unwrap();
},
>,
) {
}
pub fn main() {}

5
tests/crashes/123461.rs Normal file
View File

@ -0,0 +1,5 @@
//@ known-bug: #123461
fn main() {
let _: [_; unsafe { std::mem::transmute(|o_b: Option<_>| {}) }];
}

278
tests/crashes/123690.rs Normal file
View File

@ -0,0 +1,278 @@
//@ known-bug: #123690
fn more_discriminant_overflow() {
pub enum Infallible {}
pub enum E1 {
V2 {},
V3,
V4,
}
#[repr(u8)]
pub enum E2<X> {
V1 { f: bool },
/*_00*/ _01(X),
_02(X),
_03(X),
_04(X),
_05(X),
_06(X),
_07(X),
_08(X),
_09(X),
_0A(X),
_0B(X),
_0C(X),
_0D(X),
_0E(X),
_0F(X),
_10(X),
_11(X),
_12(X),
_13(X),
_14(X),
_15(X),
_16(X),
_17(X),
_18(X),
_19(X),
_1A(X),
_1B(X),
_1C(X),
_1D(X),
_1E(X),
_1F(X),
_20(X),
_21(X),
_22(X),
_23(X),
_24(X),
_25(X),
_26(X),
_27(X),
_28(X),
_29(X),
_2A(X),
_2B(X),
_2C(X),
_2D(X),
_2E(X),
_2F(X),
_30(X),
_31(X),
_32(X),
_33(X),
_34(X),
_35(X),
_36(X),
_37(X),
_38(X),
_39(X),
_3A(X),
_3B(X),
_3C(X),
_3D(X),
_3E(X),
_3F(X),
_40(X),
_41(X),
_42(X),
_43(X),
_44(X),
_45(X),
_46(X),
_47(X),
_48(X),
_49(X),
_4A(X),
_4B(X),
_4C(X),
_4D(X),
_4E(X),
_4F(X),
_50(X),
_51(X),
_52(X),
_53(X),
_54(X),
_55(X),
_56(X),
_57(X),
_58(X),
_59(X),
_5A(X),
_5B(X),
_5C(X),
_5D(X),
_5E(X),
_5F(X),
_60(X),
_61(X),
_62(X),
_63(X),
_64(X),
_65(X),
_66(X),
_67(X),
_68(X),
_69(X),
_6A(X),
_6B(X),
_6C(X),
_6D(X),
_6E(X),
_6F(X),
_70(X),
_71(X),
_72(X),
_73(X),
_74(E1),
_75(X),
_76(X),
_77(X),
_78(X),
_79(X),
_7A(X),
_7B(X),
_7C(X),
_7D(X),
_7E(X),
_7F(X),
_80(X),
_81(X),
_82(X),
_83(X),
_84(X),
_85(X),
_86(X),
_87(X),
_88(X),
_89(X),
_8A(X),
_8B(X),
_8C(X),
_8D(X),
_8E(X),
_8F(X),
_90(X),
_91(X),
_92(X),
_93(X),
_94(X),
_95(X),
_96(X),
_97(X),
_98(X),
_99(X),
_9A(X),
_9B(X),
_9C(X),
_9D(X),
_9E(X),
_9F(X),
_A0(X),
_A1(X),
_A2(X),
_A3(X),
_A4(X),
_A5(X),
_A6(X),
_A7(X),
_A8(X),
_A9(X),
_AA(X),
_AB(X),
_AC(X),
_AD(X),
_AE(X),
_AF(X),
_B0(X),
_B1(X),
_B2(X),
_B3(X),
_B4(X),
_B5(X),
_B6(X),
_B7(X),
_B8(X),
_B9(X),
_BA(X),
_BB(X),
_BC(X),
_BD(X),
_BE(X),
_BF(X),
_C0(X),
_C1(X),
_C2(X),
_C3(X),
_C4(X),
_C5(X),
_C6(X),
_D8(X),
_C8(X),
_C9(X),
_CA(X),
_CB(X),
_CC(X),
_CD(X),
_CE(X),
_CF(X),
_D0(X),
_D1(X),
_D2(X),
_D3(X),
_D4(X),
_D5(X),
_D6(X),
_D7(X),
_D8(X),
_D9(X),
_DA(X),
_DB(X),
_DC(X),
_DD(X),
_DE(X),
_DF(X),
_E0(X),
_E1(X),
_E2(X),
_E3(X),
_E4(X),
_E5(X),
_E6(X),
_E7(X),
_E8(X),
_E9(X),
_EA(X),
_EB(X),
_EC(X),
_ED(X),
_EE(X),
_EF(i32, i32),
_F0(X),
_F1(X),
_F2(X),
_F3(X),
_F4(X),
_F5(X),
_F6(X),
_F7(X),
_F8(X),
_F9(X),
_FA(X),
_FB(X),
_FC(X),
_FD(X),
_FE(X),
_FF(X),
V3,
V4,
}
if let E2::V1 { .. } = E2::V3::<Infallible> {}
}

22
tests/crashes/123693.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #123693
#![feature(transmutability)]
mod assert {
use std::mem::{Assume, BikeshedIntrinsicFrom};
pub fn is_transmutable<Src, Dst>()
where
Dst: BikeshedIntrinsicFrom<Src, { Assume::NOTHING }>,
{
}
}
enum Lopsided {
Smol(()),
Lorg(bool),
}
fn should_pad_variants() {
assert::is_transmutable::<Lopsided, ()>();
}

17
tests/crashes/123710.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #123710
#[repr(packed)]
#[repr(u32)]
enum E {
A,
B,
C,
}
fn main() {
union InvalidTag {
int: u32,
e: E,
}
let _invalid_tag = InvalidTag { int: 4 };
}

4
tests/crashes/123809.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #123809
type Positive = std::pat::pattern_type!(std::pat:: is 0..);
pub fn main() {}

10
tests/crashes/123810.rs Normal file
View File

@ -0,0 +1,10 @@
//@ known-bug: #123810
//@ compile-flags: -Zlint-mir
fn temp() -> (String, i32) {
(String::from("Hello"), 1)
}
fn main() {
let f = if true { &temp() } else { &temp() };
}

6
tests/crashes/123863.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #123863
const fn concat_strs<const A: &'static str>() -> &'static str {
struct Inner<const A: &'static str>;
Inner::concat_strs::<"a">::A
}
pub fn main() {}

20
tests/crashes/123893.rs Normal file
View File

@ -0,0 +1,20 @@
//@ known-bug: #123893
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes -Zinline-mir-threshold=20
pub fn main() {
generic_impl::<bool>();
}
fn generic_impl<T>() {
trait MagicTrait {
const IS_BIG: bool;
}
impl<T> MagicTrait for T {
const IS_BIG: bool = true;
}
if T::IS_BIG {
big_impl::<i32>();
}
}
#[inline(never)]
fn big_impl<T>() {}

8
tests/crashes/123901.rs Normal file
View File

@ -0,0 +1,8 @@
//@ known-bug: #123901
//@ edition:2021
pub fn test(test: &u64, temp: &u64) {
async |check, a, b| {
temp.abs_diff(12);
};
}

16
tests/crashes/123911.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #123911
macro_rules! m {
($attr_path: path) => {
#[$attr_path]
fn f() {}
}
}
m!(inline<{
let a = CharCharFloat { a: 1 };
let b = rustrt::rust_dbg_abi_4(a);
println!("a: {}", b.a);
}>);
fn main() {}

15
tests/crashes/123912.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #123912
macro_rules! m {
($attr_path: path) => {
#[$attr_path]
fn f() {}
}
}
m!(inline<{
let a = CharCharFloat { a: 1 };
println!("a: {}", a);
}>);
fn main() {}

41
tests/crashes/123917.rs Normal file
View File

@ -0,0 +1,41 @@
//@ known-bug: #123917
//@ compile-flags: -Zmir-opt-level=5 -Zpolymorphize=on
use std::marker::PhantomData;
pub struct Id<'id>();
pub struct Item<'life, T> {
data: T,
}
pub struct Token<'life, 'borrow, 'compact, 'reborrow, T>
where
'life: 'reborrow,
T: Tokenize,
{
ptr: *mut <T as Tokenize>::Tokenized,
ptr: core::ptr::NonNull<T::Tokenized>,
_phantom: PhantomData<Id<'life>>,
}
impl<'life> Arena<'life> {
pub fn tokenize<'before, 'compact, 'borrow, 'reborrow, T, U>(
item: Item<'life, &'before mut T>,
) -> Token<'life, 'borrow, 'compact, 'reborrow, U>
where
T: Tokenize<'life, 'borrow, 'compact, 'reborrow, Untokenized = U>,
T::Untokenized: Tokenize<'life, 'borrow, 'compact, 'reborrow>,
{
let dst = item.data as *mut T as *mut T::Tokenized;
Token {
ptr: core::ptr::NonNull::new(dst as *mut _).unwrap(),
_phantom: PhantomData,
}
}
}
pub trait Tokenize {
type Tokenized;
type Untokenized;
}

5
tests/crashes/123959.rs Normal file
View File

@ -0,0 +1,5 @@
//@ known-bug: #123959
#![feature(generic_const_exprs)]
fn foo<T>(_: [(); std::mem::offset_of!((T,), 0)]) {}
pub fn main() {}

18
tests/crashes/124004.rs Normal file
View File

@ -0,0 +1,18 @@
//@ known-bug: #124004
#![feature(box_patterns)]
use std::ops::{ Deref };
struct X(dyn Iterator<Item = &'a ()>);
impl Deref for X {
type Target = isize;
fn deref(&self) -> &isize {
let &X(box ref x) = self;
x
}
}
fn main() {}

33
tests/crashes/124020.rs Normal file
View File

@ -0,0 +1,33 @@
//@ known-bug: #124020
//@ compile-flags: -Zpolymorphize=on --edition=2018 --crate-type=lib
#![feature(async_closure, noop_waker, async_fn_traits)]
use std::future::Future;
use std::pin::pin;
use std::task::*;
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
let mut fut = pin!(fut);
let ctx = &mut Context::from_waker(Waker::noop());
loop {
match fut.as_mut().poll(ctx) {
Poll::Pending => {}
Poll::Ready(t) => break t,
}
}
}
async fn call_once(f: impl async FnOnce(DropMe)) {
f(DropMe("world")).await;
}
struct DropMe(&'static str);
pub fn future() {
block_on(async {
let async_closure = async move |a: DropMe| {};
call_once(async_closure).await;
});
}

6
tests/crashes/124021.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #124021
type Opaque2<'a> = impl Sized + 'a;
fn test2() -> impl for<'a, 'b> Fn((&'a str, &'b str)) -> (Opaque2<'a>, Opaque2<'a>) {
|x| x
}

17
tests/crashes/124031.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #124031
trait Trait {
type RefTarget;
}
impl Trait for () {}
struct Other {
data: <() as Trait>::RefTarget,
}
fn main() {
unsafe {
std::mem::transmute::<Option<()>, Option<&Other>>(None);
}
}