Skip to content

Commit f1bff1f

Browse files
committed
Auto merge of #124176 - matthiaskrgr:tests_are_the_best, r=jieyouxu
add more known crashes tests r? `@jieyouxu`
2 parents 9c7b1f4 + b015f61 commit f1bff1f

File tree

11 files changed

+169
-0
lines changed

11 files changed

+169
-0
lines changed

tests/crashes/103708.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #103708
2+
#![feature(min_specialization)]
3+
4+
trait MySpecTrait {
5+
fn f();
6+
}
7+
8+
impl<'a, T: ?Sized> MySpecTrait for T {
9+
default fn f() {}
10+
}
11+
12+
impl<'a, T: ?Sized> MySpecTrait for &'a T {
13+
fn f() {}
14+
}
15+
16+
fn main() {}

tests/crashes/104685.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #104685
2+
//@ compile-flags: -Zextra-const-ub-checks
3+
#![feature(extern_types)]
4+
5+
extern {
6+
pub type ExternType;
7+
}
8+
9+
extern "C" {
10+
pub static EXTERN: ExternType;
11+
}
12+
13+
pub static EMPTY: () = unsafe { &EXTERN; };
14+
15+
fn main() {}

tests/crashes/105249.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #105249
2+
//@ compile-flags: -Zpolymorphize=on
3+
4+
trait Foo<T> {
5+
fn print<'a>(&'a self) where T: 'a { println!("foo"); }
6+
}
7+
8+
impl<'a> Foo<&'a ()> for () { }
9+
10+
trait Bar: for<'a> Foo<&'a ()> { }
11+
12+
impl Bar for () {}
13+
14+
fn main() {
15+
(&() as &dyn Bar).print(); // Segfault
16+
}

tests/crashes/115994.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: #115994
2+
//@ compile-flags: -Cdebuginfo=2 --crate-type lib
3+
4+
// To prevent "overflow while adding drop-check rules".
5+
use std::mem::ManuallyDrop;
6+
7+
pub enum Foo<U> {
8+
Leaf(U),
9+
10+
Branch(BoxedFoo<BoxedFoo<U>>),
11+
}
12+
13+
pub type BoxedFoo<U> = ManuallyDrop<Box<Foo<U>>>;
14+
15+
pub fn test() -> Foo<usize> {
16+
todo!()
17+
}

tests/crashes/116721.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #116721
2+
//@ compile-flags: -Zmir-opt-level=3 --emit=mir
3+
fn hey<T>(it: &[T])
4+
where
5+
[T]: Clone,
6+
{
7+
}
8+
9+
fn main() {}

tests/crashes/118244.rs

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ known-bug: #118244
2+
//@ compile-flags: -Cdebuginfo=2
3+
4+
#![allow(incomplete_features)]
5+
#![feature(generic_const_exprs)]
6+
struct Inner<const N: usize, const M: usize>;
7+
impl<const N: usize, const M: usize> Inner<N, M> where [(); N + M]: {
8+
fn i() -> Self {
9+
Self
10+
}
11+
}
12+
13+
struct Outer<const A: usize, const B: usize>(Inner<A, { B * 2 }>) where [(); A + (B * 2)]:;
14+
impl<const A: usize, const B: usize> Outer<A, B> where [(); A + (B * 2)]: {
15+
fn o() -> Self {
16+
Self(Inner::i())
17+
}
18+
}
19+
20+
fn main() {
21+
Outer::<1, 1>::o();
22+
}

tests/crashes/124083.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #124083
2+
3+
struct Outest(&'a ());
4+
5+
fn make() -> Outest {}
6+
7+
fn main() {
8+
if let Outest("foo") = make() {}
9+
}

tests/crashes/124151.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #124151
2+
#![feature(generic_const_exprs)]
3+
4+
use std::ops::Add;
5+
6+
pub struct Dimension;
7+
8+
pub struct Quantity<S, const D: Dimension>(S);
9+
10+
impl<const D: Dimension, LHS, RHS> Add<LHS, D> for Quantity<LHS, { Dimension }> {}
11+
12+
pub fn add<const U: Dimension>(x: Quantity<f32, U>) -> Quantity<f32, U> {
13+
x + y
14+
}

tests/crashes/124164.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ known-bug: #124164
2+
static S_COUNT: = std::sync::atomic::AtomicUsize::new(0);
3+
4+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// issue: rust-lang/rust/#83993
2+
3+
#![feature(adt_const_params)]
4+
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
5+
fn bug<'a>()
6+
where
7+
for<'b> [(); {
8+
let x: &'b ();
9+
//~^ ERROR generic parameters may not be used in const operations
10+
0
11+
}]:
12+
{}
13+
14+
fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { }
15+
//~^ ERROR generic parameters may not be used in const operations
16+
fn good() where for<'b> [();{0}]: Sized { }
17+
18+
pub fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error: generic parameters may not be used in const operations
2+
--> $DIR/index-oob-ice-83993.rs:8:17
3+
|
4+
LL | let x: &'b ();
5+
| ^^ cannot perform const operation using `'b`
6+
|
7+
= note: lifetime parameters may not be used in const expressions
8+
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
9+
10+
error: generic parameters may not be used in const operations
11+
--> $DIR/index-oob-ice-83993.rs:14:36
12+
|
13+
LL | fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { }
14+
| ^^ cannot perform const operation using `'b`
15+
|
16+
= note: lifetime parameters may not be used in const expressions
17+
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions
18+
19+
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes
20+
--> $DIR/index-oob-ice-83993.rs:3:12
21+
|
22+
LL | #![feature(adt_const_params)]
23+
| ^^^^^^^^^^^^^^^^
24+
|
25+
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information
26+
= note: `#[warn(incomplete_features)]` on by default
27+
28+
error: aborting due to 2 previous errors; 1 warning emitted
29+

0 commit comments

Comments
 (0)