-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #124176 - matthiaskrgr:tests_are_the_best, r=jieyouxu
add more known crashes tests r? `@jieyouxu`
- Loading branch information
Showing
11 changed files
with
169 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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!() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() {} |
18 changes: 18 additions & 0 deletions
18
tests/ui/const-generics/adt_const_params/index-oob-ice-83993.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// issue: rust-lang/rust/#83993 | ||
|
||
#![feature(adt_const_params)] | ||
//~^ WARN the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes | ||
fn bug<'a>() | ||
where | ||
for<'b> [(); { | ||
let x: &'b (); | ||
//~^ ERROR generic parameters may not be used in const operations | ||
0 | ||
}]: | ||
{} | ||
|
||
fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { } | ||
//~^ ERROR generic parameters may not be used in const operations | ||
fn good() where for<'b> [();{0}]: Sized { } | ||
|
||
pub fn main() {} |
29 changes: 29 additions & 0 deletions
29
tests/ui/const-generics/adt_const_params/index-oob-ice-83993.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
error: generic parameters may not be used in const operations | ||
--> $DIR/index-oob-ice-83993.rs:8:17 | ||
| | ||
LL | let x: &'b (); | ||
| ^^ cannot perform const operation using `'b` | ||
| | ||
= note: lifetime parameters may not be used in const expressions | ||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions | ||
|
||
error: generic parameters may not be used in const operations | ||
--> $DIR/index-oob-ice-83993.rs:14:36 | ||
| | ||
LL | fn bad() where for<'b> [();{let _:&'b (); 0}]: Sized { } | ||
| ^^ cannot perform const operation using `'b` | ||
| | ||
= note: lifetime parameters may not be used in const expressions | ||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions | ||
|
||
warning: the feature `adt_const_params` is incomplete and may not be safe to use and/or cause compiler crashes | ||
--> $DIR/index-oob-ice-83993.rs:3:12 | ||
| | ||
LL | #![feature(adt_const_params)] | ||
| ^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #95174 <https://github.com/rust-lang/rust/issues/95174> for more information | ||
= note: `#[warn(incomplete_features)]` on by default | ||
|
||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|