Skip to content

Commit 49f5f3f

Browse files
committed
crashes: couple more tests
1 parent c53af1c commit 49f5f3f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+569
-0
lines changed

tests/crashes/136138.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #136138
2+
#![feature(min_generic_const_args)]
3+
struct U;
4+
struct S<const N: U>()
5+
where
6+
S<{ U }>:;
7+
fn main() {}

tests/crashes/136175-2.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #136175
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
trait Trait {}
6+
7+
struct A<T>(T)
8+
where
9+
[(); std::mem::offset_of!((T,), 0)]:;
10+
11+
fn main() {
12+
let x: A<dyn Trait>;
13+
}

tests/crashes/136175.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//@ known-bug: #136175
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
trait Trait {}
6+
7+
struct A<T>(T)
8+
where
9+
[(); size_of::<T>()]:;
10+
11+
fn main() {
12+
let x: A<dyn Trait>;
13+
}

tests/crashes/136188.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #136188
2+
//@ compile-flags: --crate-type=lib -Znext-solver
3+
#![feature(type_alias_impl_trait)]
4+
5+
type Opaque = Box<impl Sized>;
6+
7+
fn define() -> Opaque { Box::new(()) }
8+
9+
impl Copy for Opaque {}

tests/crashes/136286.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
//@ known-bug: #136286
2+
//@ compile-flags: --edition=2024
3+
4+
#![feature(async_fn_in_dyn_trait)]
5+
trait A {
6+
async fn b(self: A);
7+
}

tests/crashes/136379.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #136379
2+
#![feature(min_generic_const_args)]
3+
pub struct S();
4+
5+
impl S {
6+
pub fn f() -> [u8; S] {
7+
[]
8+
}
9+
}
10+
11+
pub fn main() {}

tests/crashes/136381.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ known-bug: #136381
2+
//@ compile-flags: -Zvalidate-mir -Zmir-enable-passes=+GVN
3+
#![feature(trait_upcasting)]
4+
5+
trait A {}
6+
trait B: A {
7+
fn c(&self);
8+
}
9+
impl B for i32 {
10+
fn c(self) {
11+
todo!();
12+
}
13+
}
14+
15+
fn main() {
16+
let baz: &dyn B = &1;
17+
let bar: &dyn A = baz;
18+
}

tests/crashes/136416.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #136416
2+
#![feature(generic_const_exprs)]
3+
struct State<const S : usize = {}> where[(); S] :;
4+
5+
struct Foo;
6+
struct State2<const S: usize = Foo> where [(); S]:;

tests/crashes/136442.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #136442
2+
//@ compile-flags: -Copt-level=0 -Zmir-enable-passes=+Inline -Zmir-enable-passes=+JumpThreading --crate-type lib
3+
pub fn problem_thingy(items: &mut impl Iterator<Item = str>) {
4+
let mut peeker = items.peekable();
5+
match peeker.peek() {
6+
Some(_) => (),
7+
None => return (),
8+
}
9+
}

tests/crashes/136661.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//@ known-bug: #136661
2+
3+
#![allow(unused)]
4+
5+
trait Supertrait<T> {}
6+
7+
trait Other {
8+
fn method(&self) {}
9+
}
10+
11+
impl WithAssoc for &'static () {
12+
type As = ();
13+
}
14+
15+
trait WithAssoc {
16+
type As;
17+
}
18+
19+
trait Trait<P: WithAssoc>: Supertrait<P::As> {
20+
fn method(&self) {}
21+
}
22+
23+
fn hrtb<T: for<'a> Trait<&'a ()>>() {}
24+
25+
pub fn main() {}

tests/crashes/136666.rs

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//@ known-bug: #136666
2+
// Needed so that rust can infer that the A in what() is &()
3+
trait IsRef<T> {}
4+
struct Dummy;
5+
impl<'a> IsRef<&'a ()> for Dummy {}
6+
7+
trait WithLifetime {
8+
type Output<'a>;
9+
}
10+
impl<'t> WithLifetime for &'t () {
11+
type Output<'a> = &'a ();
12+
}
13+
14+
// Needed to prevent the two Foo impls from overlapping
15+
struct Wrap<A>(A);
16+
17+
trait Unimplemented {}
18+
19+
trait Foo {}
20+
impl<T> Foo for T where T: Unimplemented {}
21+
impl<A> Foo for Wrap<A>
22+
where
23+
Dummy: IsRef<A>,
24+
for<'a> A: WithLifetime<Output<'a> = A>,
25+
{
26+
}
27+
28+
fn what<A>()
29+
where
30+
Wrap<A>: Foo,
31+
{
32+
}
33+
34+
fn main() {
35+
what();
36+
}

tests/crashes/136678.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ known-bug: #136678
2+
#![feature(inherent_associated_types)]
3+
#![feature(generic_const_exprs)]
4+
#![allow(incomplete_features)]
5+
6+
struct B<const A: usize>;
7+
8+
struct Test<const A: usize>;
9+
10+
impl<const A: usize> Test<A> {
11+
type B = B<{ A }>;
12+
13+
fn test(a: Self::B) -> Self::B {
14+
a
15+
}
16+
}
17+
18+
pub fn main() {}

tests/crashes/136766.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #136766
2+
#![feature(generic_const_exprs)]
3+
trait A<const B: bool>{}
4+
impl A<true> for () {}
5+
fn c<const D: usize>(E: [u8; D * D]) where() : A<D>{}
6+
fn main() { c }

tests/crashes/136859.rs

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//@ known-bug: #136859
2+
#![feature(generic_const_exprs)]
3+
4+
trait If<const COND: bool> {}
5+
impl If<true> for () {}
6+
7+
trait IsZero<const N: u8> {
8+
type Answer;
9+
}
10+
11+
struct True;
12+
struct False;
13+
14+
impl<const N: u8> IsZero<N> for ()
15+
where (): If<{N == 0}> {
16+
type Msg = True;
17+
}
18+
19+
trait Foobar<const N: u8> {}
20+
21+
impl<const N: u8> Foobar<N> for ()
22+
where (): IsZero<N, Answer = True> {}
23+
24+
impl<const N: u8> Foobar<{{ N }}> for ()
25+
where (): IsZero<N, Answer = False> {}
26+
27+
fn main() {}

tests/crashes/136894.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@ known-bug: #136894
2+
#![feature(generic_const_exprs)]
3+
#![crate_type = "lib"]
4+
#![allow(incomplete_features, dead_code)]
5+
6+
struct X<T>([(); f::<T>()]) where [(); f::<T>()]:;
7+
8+
const fn f<T>() -> usize { panic!() }

tests/crashes/137049.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ known-bug: #137049
2+
//@ compile-flags: --crate-type=lib
3+
#![feature(type_alias_impl_trait)]
4+
5+
use std::marker::PhantomData;
6+
7+
trait Project1 {
8+
type Assoc1;
9+
}
10+
11+
impl<T> Project1 for T {
12+
type Assoc1 = ();
13+
}
14+
15+
trait Project2 {
16+
type Assoc2;
17+
}
18+
19+
impl<T: Project1<Assoc1 = ()>> Project2 for PhantomData<T> {
20+
type Assoc2 = ();
21+
}
22+
23+
type Alias<T> = impl Project2;
24+
25+
fn constrain<T>() -> Alias<T> {
26+
PhantomData::<T>
27+
}
28+
29+
struct AdtConstructor<T: Project1>(<Alias<T> as Project2>::Assoc2);

tests/crashes/137084.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #137084
2+
#![feature(min_generic_const_args)]
3+
fn a<const b: i32>() {}
4+
fn d(e: &String) {
5+
a::<d>
6+
}

tests/crashes/137187.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ known-bug: #137187
2+
use std::ops::Add;
3+
trait A where
4+
*const Self: Add,
5+
{
6+
const fn b(c: *const Self) -> <*const Self as Add>::Output {
7+
c + c
8+
}
9+
}

tests/crashes/137188.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@ known-bug: #137188
2+
#![feature(min_generic_const_args)]
3+
trait Trait {}
4+
impl Trait for [(); N] {}
5+
fn N<T>() {}
6+
pub fn main() {}

tests/crashes/137190-1.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: #137190
2+
//@ compile-flags: -Zmir-opt-level=2 -Zvalidate-mir
3+
trait A {
4+
fn b(&self);
5+
}
6+
trait C: A {}
7+
impl C for () {}
8+
fn main() {
9+
(&() as &dyn C as &dyn A).b();
10+
}

tests/crashes/137190-2.rs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//@ known-bug: #137190
2+
trait Supertrait<T> {
3+
fn method(&self) {}
4+
}
5+
6+
trait Trait<P>: Supertrait<()> {}
7+
8+
impl<P> Trait<P> for () {}
9+
10+
const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
11+
x
12+
}
13+
14+
const fn foo() -> &'static dyn Supertrait<()> {
15+
upcast::<()>(&())
16+
}
17+
18+
const _: &'static dyn Supertrait<()> = foo();

tests/crashes/137190-3.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//@ known-bug: #137190
2+
trait Supertrait {
3+
fn method(&self) {}
4+
}
5+
6+
trait Trait: Supertrait {}
7+
8+
impl Trait for () {}
9+
10+
const _: &dyn Supertrait = &() as &dyn Trait as &dyn Supertrait;

tests/crashes/137260.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ known-bug: #137260
2+
#![feature(generic_const_exprs)]
3+
#![allow(incomplete_features)]
4+
5+
trait Iter<const N: usize = { 1 + true }> {}
6+
7+
fn needs_iter<const N: usize, T: Iter<N>>() {}
8+
9+
fn test() {
10+
needs_iter::<1, dyn Iter<()>>();
11+
}

tests/crashes/137287.rs

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//@ known-bug: #137287
2+
3+
mod defining_scope {
4+
use super::*;
5+
pub type Alias<T> = impl Sized;
6+
7+
pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
8+
x
9+
}
10+
}
11+
12+
struct Container<T: Trait<U>, U> {
13+
x: <T as Trait<U>>::Assoc,
14+
}
15+
16+
trait Trait<T> {
17+
type Assoc;
18+
}
19+
20+
impl<T> Trait<T> for T {
21+
type Assoc = Box<u32>;
22+
}
23+
impl<T> Trait<T> for defining_scope::Alias<T> {
24+
type Assoc = usize;
25+
}
26+
27+
fn main() {
28+
let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
29+
}

tests/crashes/137467-1.rs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//@ known-bug: #137467
2+
//@ compile-flags: --edition=2021
3+
enum Camera {
4+
Normal { base_transform: i32 },
5+
Volume { transform: i32 },
6+
}
7+
8+
fn draw_ui(camera: &mut Camera) {
9+
|| {
10+
let (Camera::Normal {
11+
base_transform: _transform,
12+
}
13+
| Camera::Volume {
14+
transform: _transform,
15+
}) = camera;
16+
};
17+
}

0 commit comments

Comments
 (0)