Skip to content

Commit

Permalink
Auto merge of rust-lang#126869 - matthiaskrgr:kaboom, r=jieyouxu
Browse files Browse the repository at this point in the history
crashes: add more tests
  • Loading branch information
bors committed Jun 30, 2024
2 parents ba1d7f4 + c59e7fd commit bf750f5
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/crashes/126646.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ known-bug: rust-lang/rust#126646
mod foo {
pub trait Callable {
type Output;
fn call() -> Self::Output;
}

impl<'a, V: ?Sized> Callable for &'a () {
type Output = ();
}
}
use foo::*;

fn test<'a>() -> impl Sized {
<&'a () as Callable>::call()
}

fn main() {}
8 changes: 8 additions & 0 deletions tests/crashes/126648.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: rust-lang/rust#126648
struct Outest(*const &'a ());

fn make() -> Outest {}

fn main() {
if let Outest("foo") = make() {}
}
18 changes: 18 additions & 0 deletions tests/crashes/126666.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ known-bug: rust-lang/rust#126666
#![feature(const_mut_refs)]
#![feature(const_refs_to_static)]
#![feature(object_safe_for_dispatch)]

struct Meh {
x: &'static dyn UnsafeCell,
}

const MUH: Meh = Meh {
x: &mut *(&READONLY as *const _ as *mut _),
};

static READONLY: i32 = 0;

trait UnsafeCell<'a> {}

pub fn main() {}
14 changes: 14 additions & 0 deletions tests/crashes/126667.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ known-bug: rust-lang/rust#126667
#![warn(rust_2021_compatibility)]

trait Static<'a> {}

struct Foo((u32, u32));

fn main() {
type T = impl Static;
let foo: T = Foo((1u32, 2u32));
let x = move || {
let Foo((a, b)) = foo;
};
}
21 changes: 21 additions & 0 deletions tests/crashes/126680.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//@ known-bug: rust-lang/rust#126680
//@ compile-flags: -Zvalidate-mir
#![feature(type_alias_impl_trait)]
type Bar = impl std::fmt::Display;

use std::path::Path;

struct A {
pub func: fn(check: Bar, b: Option<&Path>),
}
const MY_A: A = A {
func: |check, b| {
if check {
()
} else if let Some(_) = b.and_then(|p| p.parent()) {
()
}
},
};

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

fn can_double<const N: usize>(x: [(); N])
where
[(); N * 2]:,
{
x[0];
unimplemented!()
}

fn foo<const N: usize>()
where
[(); (N + 1) * 2]:,
{
can_double([(); { N + 1 }]);
// Adding an explicit constant generic causes the ICE to go away
// can_double::<{N + 1}>([(); { N + 1 }]);
}

fn main() {
foo::<1>();
}
20 changes: 20 additions & 0 deletions tests/crashes/126725.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//@ known-bug: rust-lang/rust#126725
trait Foo {
fn foo<'a>(&'a self) -> <&'a impl Sized as Bar>::Output;
}

trait Bar {
type Output;
}

struct X(i32);

impl<'a> Bar for &'a X {
type Output = &'a i32;
}

impl Foo for X {
fn foo<'a>(&'a self) -> <&'a Self as Bar>::Output {
&self.0
}
}
8 changes: 8 additions & 0 deletions tests/crashes/126744.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//@ known-bug: rust-lang/rust#126744
struct X {,}

fn main() {
|| {
if let X { x: 1,} = (X {}) {}
};
}
11 changes: 11 additions & 0 deletions tests/crashes/126850.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//@ known-bug: rust-lang/rust#126850
fn bug<T>() -> impl Iterator<
Item = [(); {
|found: &String| Some(false);
4
}],
> {
std::iter::empty()
}

fn main() {}

0 comments on commit bf750f5

Please sign in to comment.