Skip to content

Commit

Permalink
Auto merge of rust-lang#124038 - matthiaskrgr:one_or_two_more_tests, …
Browse files Browse the repository at this point in the history
…r=jieyouxu

crashes: add a couple more ice tests
  • Loading branch information
bors committed Apr 19, 2024
2 parents e3181b0 + 1d45b7a commit fa0068b
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/crashes/100618.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #100618
//@ compile-flags: -Cdebuginfo=2

//@ only-x86_64
enum Foo<T: 'static> {
Value(T),
Recursive(&'static Foo<Option<T>>),
}

fn main() {
let _x = Foo::Value(());
}
19 changes: 19 additions & 0 deletions tests/crashes/105299.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//@ known-bug: #105299

pub trait Foo: Clone {}

pub struct Bar<'a, T: Clone> {
pub cow: std::borrow::Cow<'a, [T]>,

pub THIS_CAUSES_ICE: (), // #1
}

impl<T> Bar<'_, T>
where
T: Clone,
[T]: Foo,
{
pub fn MOVES_SELF(self) {} // #2
}

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

pub trait Functor
{
type With<T>: Functor;
}

pub struct IdFunctor<T>(T);
impl<T> Functor for IdFunctor<T> {
type With<T2> = IdFunctor<T2>;
}

impl<T> Functor for Vec<T> {
type With<T2> = Vec<T2> ;
}


pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>)
where
F1: Functor + ?Sized,
F2: Functor + ?Sized;

impl<F1, F2, T> Functor for Compose<F1, F2, T>
where
F1: Functor + ?Sized,
F2: Functor + ?Sized
{
type With<T2> = F1::With<F2::With<T2>> ;
}

pub enum Value<F>
where
F: Functor + ?Sized,
{
SignedInt(*mut F::With<i64>),
Array(*mut Value<Compose<F, Vec<()>, ()>>),

}

fn main() {
let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
}
44 changes: 44 additions & 0 deletions tests/crashes/108499.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//@ known-bug: #108499

// at lower recursion limits the recursion limit is reached before the bug happens
#![recursion_limit = "2000"]

// this will try to calculate 3↑↑3=3^(3^3)
type Test = <() as Op<((), ()), [[[(); 0]; 0]; 0], [[[(); 0]; 0]; 0],
[[[[(); 0]; 0]; 0]; 0]>>::Result;

use std::default::Default;

fn main() {
// force the compiler to actually evaluate `Test`
println!("{}", Test::default());
}

trait Op<X, A, B, C> {
type Result;
}

// this recursive function defines the hyperoperation sequence,
// a canonical example of the type of recursion which produces the issue
// the problem seems to be caused by having two recursive calls, the second
// of which depending on the first
impl<
X: Op<(X, Y), A, [B; 0], [C; 0]>,
Y: Op<(X, Y), A, X::Result, C>,
A, B, C,
> Op<(X, Y), A, [[B; 0]; 0], [C; 0]> for () {
type Result = Y::Result;
}

// base cases
impl<X, A, B> Op<X, A, B, ()> for () {
type Result = [B; 0];
}

impl<X, A> Op<X, A, [(); 0], [(); 0]> for () {
type Result = [A; 0];
}

impl<X, A, C> Op<X, A, [(); 0], [[C; 0]; 0]> for () {
type Result = A;
}
2 changes: 2 additions & 0 deletions tests/crashes/114920.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
//@ known-bug: #114920
#![core::prelude::v1::test]
26 changes: 26 additions & 0 deletions tests/crashes/118185-2.rs
Original file line number Diff line number Diff line change
@@ -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!()
}
}
8 changes: 8 additions & 0 deletions tests/crashes/118545.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #118545
#![feature(generic_const_exprs)]

struct Checked<const F: fn()>;

fn foo() {}
const _: Checked<foo> = Checked::<foo>;
pub fn main() {}
11 changes: 11 additions & 0 deletions tests/crashes/118590.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: #118590

fn main() {
recurse(std::iter::empty::<()>())
}

fn recurse(nums: impl Iterator) {
if true { return }

recurse(nums.skip(42).peekable())
}
6 changes: 6 additions & 0 deletions tests/crashes/119381.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #119381

#![feature(with_negative_coherence)]
trait Trait {}
impl<const N: u8> Trait for [(); N] {}
impl<const N: i8> Trait for [(); N] {}
14 changes: 14 additions & 0 deletions tests/crashes/120033.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ known-bug: #120033
#![feature(non_lifetime_binders)]

pub trait Foo<T: ?Sized> {
type Bar<K: ?Sized>;
}

pub struct Bar<T: ?AutoTrait> {}

pub fn f<T1, T2>()
where
T1: for<T> Foo<usize, Bar = Bar<T>>,
T2: for<L, T> Foo<usize, Bar<T> = T1::Bar<T>>,
{}
24 changes: 24 additions & 0 deletions tests/crashes/120254.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//@ known-bug: #120254

trait Dbg {}

struct Foo<I, E> {
input: I,
errors: E,
}

trait Bar: Offset<<Self as Bar>::Checkpoint> {
type Checkpoint;
}

impl<I: Bar, E: Dbg> Bar for Foo<I, E> {
type Checkpoint = I::Checkpoint;
}

trait Offset<Start = Self> {}

impl<I: Bar, E: Dbg> Offset<<Foo<I, E> as Bar>::Checkpoint> for Foo<I, E> {}

impl<I: Bar, E> Foo<I, E> {
fn record_err(self, _: <Self as Bar>::Checkpoint) -> () {}
}
9 changes: 9 additions & 0 deletions tests/crashes/121363.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #121363
//@ compile-flags: -Zmir-opt-level=5 --crate-type lib

#![feature(trivial_bounds)]

#[derive(Debug)]
struct TwoStrs(str, str)
where
str: Sized;
30 changes: 30 additions & 0 deletions tests/crashes/121538.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//@ known-bug: #121538
//@ compile-flags: -Cdebuginfo=2

use std::marker::PhantomData;

struct Digit<T> {
elem: T
}

struct Node<T:'static> { m: PhantomData<&'static T> }

enum FingerTree<T:'static> {
Single(T),

Deep(
Digit<T>,
Node<FingerTree<Node<T>>>,
)
}

enum Wrapper<T:'static> {
Simple,
Other(FingerTree<T>),
}

fn main() {
let w =
Some(Wrapper::Simple::<u32>);

}
12 changes: 12 additions & 0 deletions tests/crashes/122259.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ known-bug: #122259

#![feature(unsized_fn_params)]

#[derive(Copy, Clone)]
struct Target(str);

fn w(t: &Target) {
x(*t);
}

fn x(t: Target) {}
22 changes: 22 additions & 0 deletions tests/crashes/122630.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ known-bug: #122630
//@ compile-flags: -Zvalidate-mir

use std::ops::Coroutine;

const FOO_SIZE: usize = 1024;
struct Foo([u8; FOO_SIZE]);

impl Drop for Foo {
fn move_before_yield_with_noop() -> impl Coroutine<Yield = ()> {}
}

fn overlap_move_points() -> impl Coroutine<Yield = ()> {
static || {
let first = Foo([0; FOO_SIZE]);
yield;
let second = first;
yield;
let second = first;
yield;
}
}
15 changes: 15 additions & 0 deletions tests/crashes/97006.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//@ known-bug: #97006
//@ compile-flags: -Zunpretty=hir

#![allow(unused)]

macro_rules! m {
($attr_path: path) => {
#[$attr_path]
fn f() {}
}
}

m!(inline<u8>); //~ ERROR: unexpected generic arguments in path

fn main() {}

0 comments on commit fa0068b

Please sign in to comment.