Skip to content

Commit 8cd77da

Browse files
committed
Auto merge of #124038 - matthiaskrgr:one_or_two_more_tests, r=jieyouxu
crashes: add a couple more ice tests
2 parents 5260893 + ce73f55 commit 8cd77da

18 files changed

+335
-0
lines changed

tests/crashes/100618.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #100618
2+
//@ compile-flags: -Cdebuginfo=2
3+
4+
//@ only-x86_64
5+
enum Foo<T: 'static> {
6+
Value(T),
7+
Recursive(&'static Foo<Option<T>>),
8+
}
9+
10+
fn main() {
11+
let _x = Foo::Value(());
12+
}

tests/crashes/105299.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ known-bug: #105299
2+
3+
pub trait Foo: Clone {}
4+
5+
pub struct Bar<'a, T: Clone> {
6+
pub cow: std::borrow::Cow<'a, [T]>,
7+
8+
pub THIS_CAUSES_ICE: (), // #1
9+
}
10+
11+
impl<T> Bar<'_, T>
12+
where
13+
T: Clone,
14+
[T]: Foo,
15+
{
16+
pub fn MOVES_SELF(self) {} // #2
17+
}
18+
19+
pub fn main() {}

tests/crashes/107362.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
//@ known-bug: #107362
2+
//@ compile-flags: -Cdebuginfo=2
3+
4+
pub trait Functor
5+
{
6+
type With<T>: Functor;
7+
}
8+
9+
pub struct IdFunctor<T>(T);
10+
impl<T> Functor for IdFunctor<T> {
11+
type With<T2> = IdFunctor<T2>;
12+
}
13+
14+
impl<T> Functor for Vec<T> {
15+
type With<T2> = Vec<T2> ;
16+
}
17+
18+
19+
pub struct Compose<F1, F2, T>(F1::With<F2::With<T>>)
20+
where
21+
F1: Functor + ?Sized,
22+
F2: Functor + ?Sized;
23+
24+
impl<F1, F2, T> Functor for Compose<F1, F2, T>
25+
where
26+
F1: Functor + ?Sized,
27+
F2: Functor + ?Sized
28+
{
29+
type With<T2> = F1::With<F2::With<T2>> ;
30+
}
31+
32+
pub enum Value<F>
33+
where
34+
F: Functor + ?Sized,
35+
{
36+
SignedInt(*mut F::With<i64>),
37+
Array(*mut Value<Compose<F, Vec<()>, ()>>),
38+
39+
}
40+
41+
fn main() {
42+
let x: Value<IdFunctor<()>> = Value::SignedInt(&mut IdFunctor(1));
43+
}

tests/crashes/108499.rs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//@ known-bug: #108499
2+
3+
// at lower recursion limits the recursion limit is reached before the bug happens
4+
#![recursion_limit = "2000"]
5+
6+
// this will try to calculate 3↑↑3=3^(3^3)
7+
type Test = <() as Op<((), ()), [[[(); 0]; 0]; 0], [[[(); 0]; 0]; 0],
8+
[[[[(); 0]; 0]; 0]; 0]>>::Result;
9+
10+
use std::default::Default;
11+
12+
fn main() {
13+
// force the compiler to actually evaluate `Test`
14+
println!("{}", Test::default());
15+
}
16+
17+
trait Op<X, A, B, C> {
18+
type Result;
19+
}
20+
21+
// this recursive function defines the hyperoperation sequence,
22+
// a canonical example of the type of recursion which produces the issue
23+
// the problem seems to be caused by having two recursive calls, the second
24+
// of which depending on the first
25+
impl<
26+
X: Op<(X, Y), A, [B; 0], [C; 0]>,
27+
Y: Op<(X, Y), A, X::Result, C>,
28+
A, B, C,
29+
> Op<(X, Y), A, [[B; 0]; 0], [C; 0]> for () {
30+
type Result = Y::Result;
31+
}
32+
33+
// base cases
34+
impl<X, A, B> Op<X, A, B, ()> for () {
35+
type Result = [B; 0];
36+
}
37+
38+
impl<X, A> Op<X, A, [(); 0], [(); 0]> for () {
39+
type Result = [A; 0];
40+
}
41+
42+
impl<X, A, C> Op<X, A, [(); 0], [[C; 0]; 0]> for () {
43+
type Result = A;
44+
}

tests/crashes/114160.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
//@ known-bug: #114160
2+
//@ compile-flags: -Zsanitizer=cfi -Clto -Zvalidate-mir -Ccodegen-units=1
3+
struct Cursor {}
4+
struct TokenTree {}
5+
6+
impl Iterator for Cursor {
7+
type Item = TokenTree;
8+
9+
fn next(&mut self) -> Option<TokenTree> {
10+
None
11+
}
12+
}
13+
14+
fn tokenstream_probably_equal_for_proc_macro() {
15+
fn break_tokens(_tree: TokenTree) -> impl Iterator {
16+
let token_trees: Vec<TokenTree> = vec![];
17+
token_trees.into_iter()
18+
}
19+
20+
let c1 = Cursor {};
21+
let c2 = Cursor {};
22+
23+
let mut t1 = c1.flat_map(break_tokens);
24+
let mut t2 = c2.flat_map(break_tokens);
25+
26+
for (_t1, _t2) in t1.by_ref().zip(t2.by_ref()) {}
27+
}
28+
29+
fn main() {
30+
tokenstream_probably_equal_for_proc_macro();
31+
}

tests/crashes/114920.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//@ known-bug: #114920
2+
#![core::prelude::v1::test]

tests/crashes/118185-2.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//@ known-bug: #118185
2+
3+
fn main() {
4+
let target: Target = create_target();
5+
target.get(0); // correct arguments work
6+
target.get(10.0); // CRASH HERE
7+
}
8+
9+
// must be generic
10+
fn create_target<T>() -> T {
11+
unimplemented!()
12+
}
13+
14+
// unimplemented trait, but contains function with the same name
15+
pub trait RandomTrait {
16+
fn get(&mut self); // but less arguments
17+
}
18+
19+
struct Target;
20+
21+
impl Target {
22+
// correct function with arguments
23+
pub fn get(&self, data: i32) {
24+
unimplemented!()
25+
}
26+
}

tests/crashes/118545.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #118545
2+
#![feature(generic_const_exprs)]
3+
4+
struct Checked<const F: fn()>;
5+
6+
fn foo() {}
7+
const _: Checked<foo> = Checked::<foo>;
8+
pub fn main() {}

tests/crashes/118590.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #118590
2+
3+
fn main() {
4+
recurse(std::iter::empty::<()>())
5+
}
6+
7+
fn recurse(nums: impl Iterator) {
8+
if true { return }
9+
10+
recurse(nums.skip(42).peekable())
11+
}

tests/crashes/119381.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #119381
2+
3+
#![feature(with_negative_coherence)]
4+
trait Trait {}
5+
impl<const N: u8> Trait for [(); N] {}
6+
impl<const N: i8> Trait for [(); N] {}

0 commit comments

Comments
 (0)