Skip to content

Commit 55b4ee7

Browse files
authored
Rollup merge of #131447 - matthiaskrgr:morecrashtests, r=compiler-errors
add more crash tests r? `@jieyouxu`
2 parents 8630de3 + 6774856 commit 55b4ee7

21 files changed

+343
-0
lines changed

tests/crashes/130956.rs

Lines changed: 37 additions & 0 deletions
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+
}

tests/crashes/130967.rs

Lines changed: 13 additions & 0 deletions
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+
}

tests/crashes/131046.rs

Lines changed: 15 additions & 0 deletions
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+
}

tests/crashes/131048.rs

Lines changed: 7 additions & 0 deletions
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+
}

tests/crashes/131050.rs

Lines changed: 27 additions & 0 deletions
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+
}

tests/crashes/131052.rs

Lines changed: 8 additions & 0 deletions
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+
}

tests/crashes/131101.rs

Lines changed: 12 additions & 0 deletions
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+
}

tests/crashes/131102.rs

Lines changed: 4 additions & 0 deletions
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) {}

tests/crashes/131103.rs

Lines changed: 6 additions & 0 deletions
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+
}

tests/crashes/131190.rs

Lines changed: 19 additions & 0 deletions
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+
}

0 commit comments

Comments
 (0)