Skip to content

Commit

Permalink
add more known-crashes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Apr 19, 2024
1 parent e0586a6 commit b015f61
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/crashes/103708.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@ known-bug: #103708
#![feature(min_specialization)]

trait MySpecTrait {
fn f();
}

impl<'a, T: ?Sized> MySpecTrait for T {
default fn f() {}
}

impl<'a, T: ?Sized> MySpecTrait for &'a T {
fn f() {}
}

fn main() {}
15 changes: 15 additions & 0 deletions tests/crashes/104685.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ known-bug: #104685
//@ compile-flags: -Zextra-const-ub-checks
#![feature(extern_types)]

extern {
pub type ExternType;
}

extern "C" {
pub static EXTERN: ExternType;
}

pub static EMPTY: () = unsafe { &EXTERN; };

fn main() {}
16 changes: 16 additions & 0 deletions tests/crashes/105249.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//@ known-bug: #105249
//@ compile-flags: -Zpolymorphize=on

trait Foo<T> {
fn print<'a>(&'a self) where T: 'a { println!("foo"); }
}

impl<'a> Foo<&'a ()> for () { }

trait Bar: for<'a> Foo<&'a ()> { }

impl Bar for () {}

fn main() {
(&() as &dyn Bar).print(); // Segfault
}
17 changes: 17 additions & 0 deletions tests/crashes/115994.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ known-bug: #115994
//@ compile-flags: -Cdebuginfo=2 --crate-type lib

// To prevent "overflow while adding drop-check rules".
use std::mem::ManuallyDrop;

pub enum Foo<U> {
Leaf(U),

Branch(BoxedFoo<BoxedFoo<U>>),
}

pub type BoxedFoo<U> = ManuallyDrop<Box<Foo<U>>>;

pub fn test() -> Foo<usize> {
todo!()
}
9 changes: 9 additions & 0 deletions tests/crashes/116721.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #116721
//@ compile-flags: -Zmir-opt-level=3 --emit=mir
fn hey<T>(it: &[T])
where
[T]: Clone,
{
}

fn main() {}
22 changes: 22 additions & 0 deletions tests/crashes/118244.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ known-bug: #118244
//@ compile-flags: -Cdebuginfo=2

#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
struct Inner<const N: usize, const M: usize>;
impl<const N: usize, const M: usize> Inner<N, M> where [(); N + M]: {
fn i() -> Self {
Self
}
}

struct Outer<const A: usize, const B: usize>(Inner<A, { B * 2 }>) where [(); A + (B * 2)]:;
impl<const A: usize, const B: usize> Outer<A, B> where [(); A + (B * 2)]: {
fn o() -> Self {
Self(Inner::i())
}
}

fn main() {
Outer::<1, 1>::o();
}
9 changes: 9 additions & 0 deletions tests/crashes/124083.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #124083

struct Outest(&'a ());

fn make() -> Outest {}

fn main() {
if let Outest("foo") = make() {}
}
14 changes: 14 additions & 0 deletions tests/crashes/124151.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ known-bug: #124151
#![feature(generic_const_exprs)]

use std::ops::Add;

pub struct Dimension;

pub struct Quantity<S, const D: Dimension>(S);

impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}

pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
x + y
}
4 changes: 4 additions & 0 deletions tests/crashes/124164.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//@ known-bug: #124164
static S_COUNT: = std::sync::atomic::AtomicUsize::new(0);

fn main() {}

0 comments on commit b015f61

Please sign in to comment.