Skip to content

Commit 6774856

Browse files
committed
add more crash tests
1 parent 4203c68 commit 6774856

21 files changed

+343
-0
lines changed

Diff for: tests/crashes/130956.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//@ known-bug: #130956
2+
3+
mod impl_trait_mod {
4+
use super::*;
5+
pub type OpaqueBlock = impl Trait;
6+
pub type OpaqueIf = impl Trait;
7+
8+
pub struct BlockWrapper(OpaqueBlock);
9+
pub struct IfWrapper(pub OpaqueIf);
10+
11+
pub fn if_impl() -> Parser<OpaqueIf> {
12+
bind(option(block()), |_| block())
13+
}
14+
}
15+
use impl_trait_mod::*;
16+
17+
pub trait Trait {
18+
type Assoc;
19+
}
20+
pub struct Parser<P>(P);
21+
pub struct Bind<P, F>(P, F);
22+
impl<P, F> Trait for Bind<P, F> { type Assoc = (); }
23+
impl Trait for BlockWrapper { type Assoc = (); }
24+
impl Trait for IfWrapper { type Assoc = (); }
25+
26+
pub fn block() -> Parser<BlockWrapper> {
27+
loop {}
28+
}
29+
pub fn option<P: Trait>(arg: Parser<P>) -> Parser<impl Trait> {
30+
bind(arg, |_| block())
31+
}
32+
fn bind<P: Trait, P2, F: Fn(P::Assoc) -> Parser<P2>>(_: Parser<P>, _: F) -> Parser<Bind<P, F>>
33+
{ loop {} }
34+
35+
fn main() {
36+
if_impl().0;
37+
}

Diff for: tests/crashes/130967.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #130967
2+
3+
trait Producer {
4+
type Produced;
5+
fn make_one() -> Self::Produced;
6+
}
7+
8+
impl<E: ?Sized> Producer for () {
9+
type Produced = Option<E>;
10+
fn make_one() -> Self::Produced {
11+
loop {}
12+
}
13+
}

Diff for: tests/crashes/131046.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//@ known-bug: #131046
2+
3+
trait Owner {
4+
const C<const N: u32>: u32;
5+
}
6+
7+
impl Owner for () {
8+
const C<const N: u32>: u32 = N;
9+
}
10+
11+
fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
12+
13+
fn main() {
14+
take0::<128>(());
15+
}

Diff for: tests/crashes/131048.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #131048
2+
3+
impl<A> std::ops::CoerceUnsized<A> for A {}
4+
5+
fn main() {
6+
format_args!("Hello, world!");
7+
}

Diff for: tests/crashes/131050.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #131050
2+
//@ compile-flags: --edition=2021
3+
4+
fn query_as<D>() {}
5+
6+
async fn create_user() {
7+
query_as();
8+
}
9+
10+
async fn post_user_filter() -> impl Filter {
11+
AndThen(&(), || async { create_user().await })
12+
}
13+
14+
async fn get_app() -> impl Send {
15+
post_user_filter().await
16+
}
17+
18+
trait Filter {}
19+
20+
struct AndThen<T, F>(T, F);
21+
22+
impl<T, F, R> Filter for AndThen<T, F>
23+
where
24+
F: Fn() -> R,
25+
R: Send,
26+
{
27+
}

Diff for: tests/crashes/131052.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #131052
2+
#![feature(adt_const_params)]
3+
4+
struct ConstBytes<const T: &'static [*mut u8; 3]>;
5+
6+
pub fn main() {
7+
let _: ConstBytes<b"AAA"> = ConstBytes::<b"BBB">;
8+
}

Diff for: tests/crashes/131101.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #131101
2+
trait Foo<const N: u8> {
3+
fn do_x(&self) -> [u8; N];
4+
}
5+
6+
struct Bar;
7+
8+
impl Foo<const 3> for Bar {
9+
fn do_x(&self) -> [u8; 3] {
10+
[0u8; 3]
11+
}
12+
}

Diff for: tests/crashes/131102.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
//@ known-bug: #131102
2+
pub struct Blorb<const N: u16>([String; N]);
3+
pub struct Wrap(Blorb<0>);
4+
pub const fn i(_: Wrap) {}

Diff for: tests/crashes/131103.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #131103
2+
struct Struct<const N: i128>(pub [u8; N]);
3+
4+
pub fn function(value: Struct<3>) -> u8 {
5+
value.0[0]
6+
}

Diff for: tests/crashes/131190.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ known-bug: #131190
2+
//@ compile-flags: -Cinstrument-coverage --edition=2018
3+
4+
use std::future::Future;
5+
6+
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {}
7+
8+
async fn call_once(f: impl async FnOnce(DropMe)) {
9+
f(DropMe("world")).await;
10+
}
11+
12+
struct DropMe(&'static str);
13+
14+
pub fn main() {
15+
block_on(async {
16+
let async_closure = async move |a: DropMe| {};
17+
call_once(async_closure).await;
18+
});
19+
}

Diff for: tests/crashes/131227.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #131227
2+
//@ compile-flags: -Zmir-opt-level=3
3+
4+
static mut G: () = ();
5+
6+
fn myfunc() -> i32 {
7+
let var = &raw mut G;
8+
if var.is_null() {
9+
return 0;
10+
}
11+
0
12+
}
13+
14+
fn main() {
15+
myfunc();
16+
}

Diff for: tests/crashes/131292.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #131292
2+
//@ only-x86_64
3+
use std::arch::asm;
4+
5+
unsafe fn f6() {
6+
asm!(concat!(r#"lJ𐏿Æ�.𐏿�"#, "{}/day{:02}.txt"));
7+
}

Diff for: tests/crashes/131294-2.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ known-bug: #131294
2+
//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always
3+
4+
// https://github.com/rust-lang/rust/issues/131294#issuecomment-2395088049 second comment
5+
struct Rows;
6+
7+
impl Iterator for Rows {
8+
type Item = String;
9+
10+
fn next() -> Option<String> {
11+
let args = format_args!("Hello world");
12+
13+
{
14+
match args.as_str() {
15+
Some(t) => t.to_owned(),
16+
None => String::new(),
17+
}
18+
}
19+
.into()
20+
}
21+
}
22+
23+
fn main() {
24+
Rows.next();
25+
}

Diff for: tests/crashes/131294.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #131294
2+
//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir -Zcross-crate-inline-threshold=always
3+
4+
struct Rows;
5+
6+
impl Iterator for Rows {
7+
type Item = String;
8+
9+
fn next() -> Option<Self::Item> {
10+
std::fmt::format(format_args!("Hello world")).into()
11+
}
12+
}
13+
14+
fn main() {
15+
Rows.next();
16+
}

Diff for: tests/crashes/131295.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #131295
2+
3+
#![feature(generic_const_exprs)]
4+
5+
async fn foo<'a>() -> [(); {
6+
let _y: &'a ();
7+
4
8+
}] {
9+
}

Diff for: tests/crashes/131298.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #131298
2+
3+
fn dyn_hoops<T>() -> *const dyn Iterator<Item = impl Captures> {
4+
loop {}
5+
}
6+
7+
mod typeck {
8+
type Opaque = impl Sized;
9+
fn define() -> Opaque {
10+
let _: Opaque = super::dyn_hoops::<u8>();
11+
}
12+
}

Diff for: tests/crashes/131342-2.rs

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//@ known-bug: #131342
2+
// see also: 131342.rs
3+
4+
fn main() {
5+
problem_thingy(Once);
6+
}
7+
8+
struct Once;
9+
10+
impl Iterator for Once {
11+
type Item = ();
12+
}
13+
14+
fn problem_thingy(items: impl Iterator) {
15+
let peeker = items.peekable();
16+
problem_thingy(&peeker);
17+
}
18+
19+
trait Iterator {
20+
type Item;
21+
22+
fn peekable(self) -> Peekable<Self>
23+
where
24+
Self: Sized,
25+
{
26+
loop {}
27+
}
28+
}
29+
30+
struct Peekable<I: Iterator> {
31+
_peeked: I::Item,
32+
}
33+
34+
impl<I: Iterator> Iterator for Peekable<I> {
35+
type Item = I::Item;
36+
}
37+
38+
impl<I: Iterator + ?Sized> Iterator for &I {
39+
type Item = I::Item;
40+
}

Diff for: tests/crashes/131342.rs

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #131342
2+
// see also: 131342-2.rs
3+
4+
fn main() {
5+
let mut items = vec![1, 2, 3, 4, 5].into_iter();
6+
problem_thingy(&mut items);
7+
}
8+
9+
fn problem_thingy(items: &mut impl Iterator<Item = u8>) {
10+
let mut peeker = items.peekable();
11+
match peeker.peek() {
12+
Some(_) => (),
13+
None => return (),
14+
}
15+
problem_thingy(&mut peeker);
16+
}

Diff for: tests/crashes/131347.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #131347
2+
//@ compile-flags: -Zmir-opt-level=5 -Zvalidate-mir
3+
4+
struct S;
5+
static STUFF: [i8] = [0; S::N];
6+
7+
fn main() {
8+
assert_eq!(STUFF, [0; 63]);
9+
}

Diff for: tests/crashes/131373.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//@ known-bug: #131373
2+
3+
trait LockReference: 'static {
4+
type Ref<'a>;
5+
}
6+
7+
struct SliceRef<'a, T: ?Sized> {
8+
_x: &'a T,
9+
}
10+
11+
impl<'a, T: ?Sized, SR: LockReference> IntoIterator for SliceRef<'a, T>
12+
where
13+
&'a T: IntoIterator<Item = &'a SR>,
14+
{
15+
type Item = SR::Ref<'a>;
16+
type IntoIter = std::iter::Map<<&'a T as IntoIterator>::IntoIter,
17+
for<'c> fn(&'c SR) -> SR::Ref<'c>>;
18+
fn into_iter(self) -> Self::IntoIter {
19+
loop {}
20+
}
21+
}
22+
23+
impl LockReference for () {
24+
type Ref<'a> = ();
25+
}
26+
27+
fn locked() -> SliceRef<'static, [()]> {
28+
loop {}
29+
}
30+
31+
fn main() {
32+
let _ = locked().into_iter();
33+
}

Diff for: tests/crashes/131406.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #131406
2+
3+
trait Owner {
4+
const C<const N: u32>: u32 = N;
5+
}
6+
7+
impl Owner for () {}
8+
fn take0<const N: u64>(_: impl Owner<C<N> = { N }>) {}
9+
10+
fn main() {
11+
take0::<128>(());
12+
}

0 commit comments

Comments
 (0)