Skip to content

Commit fc35c23

Browse files
committed
add crashtests
1 parent 1676160 commit fc35c23

14 files changed

Lines changed: 231 additions & 0 deletions

File tree

tests/crashes/147719.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//@ known-bug: #147719
2+
//@ edition: 2024
3+
trait NodeImpl {}
4+
struct Wrap<F, P>(F, P);
5+
impl<F, P> Wrap<F, P> {
6+
fn new(_: F) -> Self {
7+
loop {}
8+
}
9+
}
10+
trait Arg {}
11+
impl<F, A> NodeImpl for Wrap<F, A> where A: Arg {}
12+
impl<F, Fut, A> NodeImpl for Wrap<F, (A,)> where F: Fn(&(), A) -> Fut {}
13+
fn trigger_ice() {
14+
let _: &dyn NodeImpl = &Wrap::<_, (i128,)>::new(async |_: &(), i128| 0);
15+
}
16+
fn main() {}

tests/crashes/148511.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//@ known-bug: #148511
2+
//@ edition: 2021
3+
use std::any::Any;
4+
5+
fn main() {
6+
use_service(make_service());
7+
let _future = async {};
8+
}
9+
10+
fn make_service() -> impl FooService<Box<dyn Any>, Response: Body> {}
11+
12+
fn use_service<S, R>(_service: S)
13+
where
14+
S: FooService<R>,
15+
<S::Response as Body>::Data: Any,
16+
{
17+
}
18+
19+
trait Service<Request> {
20+
type Response: Body;
21+
}
22+
23+
impl<T, Request> Service<Request> for T {
24+
type Response = ();
25+
}
26+
27+
trait FooService<Request>: Service<Request> {}
28+
29+
impl<T, Request, Resp> FooService<Request> for T
30+
where
31+
T: Service<Request, Response = Resp>,
32+
Resp: Body,
33+
{
34+
}
35+
36+
trait Body {
37+
type Data;
38+
}
39+
40+
impl<T> Body for T {
41+
type Data = ();
42+
}

tests/crashes/148629.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #148629
2+
#![feature(with_negative_coherence)]
3+
trait Foo {
4+
type AssociatedType;
5+
}
6+
7+
impl<const N: usize> Foo for [(); N] {}
8+
9+
pub struct Happy;
10+
11+
impl Foo for Happy {}
12+
13+
impl<const N: usize> Foo for Happy where <[(); N] as Foo>::AssociatedType: Clone {}

tests/crashes/148630.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #148630
2+
#![feature(unboxed_closures)]
3+
4+
trait Tr {}
5+
trait Foo {
6+
fn foo() -> impl Sized
7+
where
8+
for<'a> <() as FnOnce<&'a i32>>::Output: Tr,
9+
{
10+
}
11+
}
12+
13+
fn main() {}

tests/crashes/148632.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: #148632
2+
trait D<C> {}
3+
4+
trait Project {
5+
const SELF: dyn D<Self>;
6+
}
7+
8+
fn main() {
9+
let _: &dyn Project<SELF = { 0 }>;
10+
}

tests/crashes/148890.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #148890
2+
impl std::ops::Neg for u128 {}
3+
4+
fn foo(-128..=127: u128) {}
5+
6+
fn main() {}

tests/crashes/148891.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ known-bug: #148891
2+
macro_rules! values {
3+
($inner:ty) => {
4+
#[derive(Debug)]
5+
pub enum TokenKind {
6+
#[cfg(test)]
7+
STRING ([u8; $inner]),
8+
}
9+
};
10+
}
11+
12+
values!(String);
13+
14+
pub fn main() {}

tests/crashes/149162.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//@ known-bug: #149162
2+
use std::marker::PhantomData;
3+
pub trait ViewArgument {
4+
type Params<'a>;
5+
}
6+
7+
impl ViewArgument for () {
8+
type Params<'a> = ();
9+
}
10+
11+
pub trait View {}
12+
13+
pub fn buttons() -> Option<impl View> {
14+
Some(()).map(|()| text_button(|()| {}))
15+
}
16+
pub fn text_button<State: ViewArgument>(
17+
_: impl Fn(<State as ViewArgument>::Params<'_>),
18+
) -> Button<State, impl Fn()> {
19+
Button {
20+
callback: || (),
21+
phantom: PhantomData,
22+
}
23+
}
24+
pub struct Button<State, F> {
25+
pub callback: F,
26+
pub phantom: PhantomData<State>,
27+
}
28+
29+
impl<F> View for Button<(), F> {}
30+
fn main() {}

tests/crashes/149703.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ known-bug: #149703
2+
#![feature(const_trait_impl)]
3+
trait Z {
4+
type Assoc;
5+
}
6+
struct A;
7+
impl<T: const FnOnce()> Z for T {
8+
type Assoc = ();
9+
}
10+
impl<T> From<<A as Z>::Assoc> for T {}
11+
12+
fn main() {}

tests/crashes/152205.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//@ known-bug: #152205
2+
#![deny(rust_2021_incompatible_closure_captures)]
3+
struct Foo;
4+
struct S;
5+
impl Drop for S {
6+
fn drop(&mut self) {}
7+
}
8+
struct U(<Foo as NewTrait>::Assoc);
9+
fn test_precise_analysis_long_path(u: U) {
10+
let _ = || {
11+
let _x = u.0.0;
12+
};
13+
}
14+
trait NewTrait {
15+
type Assoc;
16+
}
17+
impl NewTrait for Foo {
18+
type Assoc = (S,);
19+
}
20+
fn main(){}

0 commit comments

Comments
 (0)