Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashes: couple more tests #138192

Merged
merged 1 commit into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/crashes/136138.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: #136138
#![feature(min_generic_const_args)]
struct U;
struct S<const N: U>()
where
S<{ U }>:;
fn main() {}
13 changes: 13 additions & 0 deletions tests/crashes/136175-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #136175
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

trait Trait {}

struct A<T>(T)
where
[(); std::mem::offset_of!((T,), 0)]:;

fn main() {
let x: A<dyn Trait>;
}
13 changes: 13 additions & 0 deletions tests/crashes/136175.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@ known-bug: #136175
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

trait Trait {}

struct A<T>(T)
where
[(); size_of::<T>()]:;

fn main() {
let x: A<dyn Trait>;
}
9 changes: 9 additions & 0 deletions tests/crashes/136188.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #136188
//@ compile-flags: --crate-type=lib -Znext-solver
#![feature(type_alias_impl_trait)]

type Opaque = Box<impl Sized>;

fn define() -> Opaque { Box::new(()) }

impl Copy for Opaque {}
7 changes: 7 additions & 0 deletions tests/crashes/136286.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ known-bug: #136286
//@ compile-flags: --edition=2024

#![feature(async_fn_in_dyn_trait)]
trait A {
async fn b(self: A);
}
11 changes: 11 additions & 0 deletions tests/crashes/136379.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: #136379
#![feature(min_generic_const_args)]
pub struct S();

impl S {
pub fn f() -> [u8; S] {
[]
}
}

pub fn main() {}
18 changes: 18 additions & 0 deletions tests/crashes/136381.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ known-bug: #136381
//@ compile-flags: -Zvalidate-mir -Zmir-enable-passes=+GVN
#![feature(trait_upcasting)]

trait A {}
trait B: A {
fn c(&self);
}
impl B for i32 {
fn c(self) {
todo!();
}
}

fn main() {
let baz: &dyn B = &1;
let bar: &dyn A = baz;
}
6 changes: 6 additions & 0 deletions tests/crashes/136416.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #136416
#![feature(generic_const_exprs)]
struct State<const S : usize = {}> where[(); S] :;

struct Foo;
struct State2<const S: usize = Foo> where [(); S]:;
9 changes: 9 additions & 0 deletions tests/crashes/136442.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #136442
//@ compile-flags: -Copt-level=0 -Zmir-enable-passes=+Inline -Zmir-enable-passes=+JumpThreading --crate-type lib
pub fn problem_thingy(items: &mut impl Iterator<Item = str>) {
let mut peeker = items.peekable();
match peeker.peek() {
Some(_) => (),
None => return (),
}
}
25 changes: 25 additions & 0 deletions tests/crashes/136661.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//@ known-bug: #136661

#![allow(unused)]

trait Supertrait<T> {}

trait Other {
fn method(&self) {}
}

impl WithAssoc for &'static () {
type As = ();
}

trait WithAssoc {
type As;
}

trait Trait<P: WithAssoc>: Supertrait<P::As> {
fn method(&self) {}
}

fn hrtb<T: for<'a> Trait<&'a ()>>() {}

pub fn main() {}
36 changes: 36 additions & 0 deletions tests/crashes/136666.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//@ known-bug: #136666
// Needed so that rust can infer that the A in what() is &()
trait IsRef<T> {}
struct Dummy;
impl<'a> IsRef<&'a ()> for Dummy {}

trait WithLifetime {
type Output<'a>;
}
impl<'t> WithLifetime for &'t () {
type Output<'a> = &'a ();
}

// Needed to prevent the two Foo impls from overlapping
struct Wrap<A>(A);

trait Unimplemented {}

trait Foo {}
impl<T> Foo for T where T: Unimplemented {}
impl<A> Foo for Wrap<A>
where
Dummy: IsRef<A>,
for<'a> A: WithLifetime<Output<'a> = A>,
{
}

fn what<A>()
where
Wrap<A>: Foo,
{
}

fn main() {
what();
}
18 changes: 18 additions & 0 deletions tests/crashes/136678.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ known-bug: #136678
#![feature(inherent_associated_types)]
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

struct B<const A: usize>;

struct Test<const A: usize>;

impl<const A: usize> Test<A> {
type B = B<{ A }>;

fn test(a: Self::B) -> Self::B {
a
}
}

pub fn main() {}
6 changes: 6 additions & 0 deletions tests/crashes/136766.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #136766
#![feature(generic_const_exprs)]
trait A<const B: bool>{}
impl A<true> for () {}
fn c<const D: usize>(E: [u8; D * D]) where() : A<D>{}
fn main() { c }
27 changes: 27 additions & 0 deletions tests/crashes/136859.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//@ known-bug: #136859
#![feature(generic_const_exprs)]

trait If<const COND: bool> {}
impl If<true> for () {}

trait IsZero<const N: u8> {
type Answer;
}

struct True;
struct False;

impl<const N: u8> IsZero<N> for ()
where (): If<{N == 0}> {
type Msg = True;
}

trait Foobar<const N: u8> {}

impl<const N: u8> Foobar<N> for ()
where (): IsZero<N, Answer = True> {}

impl<const N: u8> Foobar<{{ N }}> for ()
where (): IsZero<N, Answer = False> {}

fn main() {}
8 changes: 8 additions & 0 deletions tests/crashes/136894.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: #136894
#![feature(generic_const_exprs)]
#![crate_type = "lib"]
#![allow(incomplete_features, dead_code)]

struct X<T>([(); f::<T>()]) where [(); f::<T>()]:;

const fn f<T>() -> usize { panic!() }
29 changes: 29 additions & 0 deletions tests/crashes/137049.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ known-bug: #137049
//@ compile-flags: --crate-type=lib
#![feature(type_alias_impl_trait)]

use std::marker::PhantomData;

trait Project1 {
type Assoc1;
}

impl<T> Project1 for T {
type Assoc1 = ();
}

trait Project2 {
type Assoc2;
}

impl<T: Project1<Assoc1 = ()>> Project2 for PhantomData<T> {
type Assoc2 = ();
}

type Alias<T> = impl Project2;

fn constrain<T>() -> Alias<T> {
PhantomData::<T>
}

struct AdtConstructor<T: Project1>(<Alias<T> as Project2>::Assoc2);
6 changes: 6 additions & 0 deletions tests/crashes/137084.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #137084
#![feature(min_generic_const_args)]
fn a<const b: i32>() {}
fn d(e: &String) {
a::<d>
}
9 changes: 9 additions & 0 deletions tests/crashes/137187.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//@ known-bug: #137187
use std::ops::Add;
trait A where
*const Self: Add,
{
const fn b(c: *const Self) -> <*const Self as Add>::Output {
c + c
}
}
6 changes: 6 additions & 0 deletions tests/crashes/137188.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//@ known-bug: #137188
#![feature(min_generic_const_args)]
trait Trait {}
impl Trait for [(); N] {}
fn N<T>() {}
pub fn main() {}
10 changes: 10 additions & 0 deletions tests/crashes/137190-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ known-bug: #137190
//@ compile-flags: -Zmir-opt-level=2 -Zvalidate-mir
trait A {
fn b(&self);
}
trait C: A {}
impl C for () {}
fn main() {
(&() as &dyn C as &dyn A).b();
}
18 changes: 18 additions & 0 deletions tests/crashes/137190-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ known-bug: #137190
trait Supertrait<T> {
fn method(&self) {}
}

trait Trait<P>: Supertrait<()> {}

impl<P> Trait<P> for () {}

const fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> {
x
}

const fn foo() -> &'static dyn Supertrait<()> {
upcast::<()>(&())
}

const _: &'static dyn Supertrait<()> = foo();
10 changes: 10 additions & 0 deletions tests/crashes/137190-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//@ known-bug: #137190
trait Supertrait {
fn method(&self) {}
}

trait Trait: Supertrait {}

impl Trait for () {}

const _: &dyn Supertrait = &() as &dyn Trait as &dyn Supertrait;
11 changes: 11 additions & 0 deletions tests/crashes/137260.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: #137260
#![feature(generic_const_exprs)]
#![allow(incomplete_features)]

trait Iter<const N: usize = { 1 + true }> {}

fn needs_iter<const N: usize, T: Iter<N>>() {}

fn test() {
needs_iter::<1, dyn Iter<()>>();
}
29 changes: 29 additions & 0 deletions tests/crashes/137287.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//@ known-bug: #137287

mod defining_scope {
use super::*;
pub type Alias<T> = impl Sized;

pub fn cast<T>(x: Container<Alias<T>, T>) -> Container<T, T> {
x
}
}

struct Container<T: Trait<U>, U> {
x: <T as Trait<U>>::Assoc,
}

trait Trait<T> {
type Assoc;
}

impl<T> Trait<T> for T {
type Assoc = Box<u32>;
}
impl<T> Trait<T> for defining_scope::Alias<T> {
type Assoc = usize;
}

fn main() {
let x: Box<u32> = defining_scope::cast::<()>(Container { x: 0 }).x;
}
17 changes: 17 additions & 0 deletions tests/crashes/137467-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//@ known-bug: #137467
//@ compile-flags: --edition=2021
enum Camera {
Normal { base_transform: i32 },
Volume { transform: i32 },
}

fn draw_ui(camera: &mut Camera) {
|| {
let (Camera::Normal {
base_transform: _transform,
}
| Camera::Volume {
transform: _transform,
}) = camera;
};
}
Loading
Loading