-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests/crashes: add ICEs from matthiaskrgr/glacier2
- Loading branch information
1 parent
98dd566
commit 7d826ae
Showing
133 changed files
with
2,620 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//@ known-bug: #101036 | ||
#![feature(generic_const_exprs)] | ||
|
||
const fn t<const N: usize>() -> u8 { | ||
N as u8 | ||
} | ||
|
||
#[repr(u8)] | ||
enum T<const N: u8 = { T::<0>::A as u8 + T::<0>::B as u8 }> | ||
where | ||
[(); N as usize]: | ||
{ | ||
A = t::<N>() as u8, B | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
//@ known-bug: #101557 | ||
#![feature(generic_const_exprs)] | ||
use std::marker::PhantomData; | ||
|
||
trait Trait { | ||
const CONST: usize; | ||
} | ||
|
||
struct A<T: Trait> { | ||
_marker: PhantomData<T>, | ||
} | ||
|
||
impl<const N: usize> Trait for [i8; N] { | ||
const CONST: usize = N; | ||
} | ||
|
||
impl<const N: usize> From<usize> for A<[i8; N]> { | ||
fn from(_: usize) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
impl<T: Trait> From<A<[i8; T::CONST]>> for A<T> { | ||
fn from(_: A<[i8; T::CONST]>) -> Self { | ||
todo!() | ||
} | ||
} | ||
|
||
fn f<T: Trait>() -> A<T> | ||
where | ||
[(); T::CONST]:, | ||
{ | ||
// Usage of `0` is arbitrary | ||
let a = A::<[i8; T::CONST]>::from(0); | ||
A::<T>::from(a) | ||
} | ||
|
||
fn main() { | ||
// Usage of `1` is arbitrary | ||
f::<[i8; 1]>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ known-bug: #105275 | ||
//@ compile-flags: -Copt-level=0 | ||
|
||
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { | ||
if n > 15 { | ||
encode_num(n / 16, &mut writer)?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub trait ExampleWriter { | ||
type Error; | ||
} | ||
|
||
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T { | ||
type Error = T::Error; | ||
} | ||
|
||
struct Error; | ||
|
||
impl ExampleWriter for Error { | ||
type Error = (); | ||
} | ||
|
||
fn main() { | ||
encode_num(69, &mut Error).unwrap(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//@ known-bug: #105937 | ||
//@ compile-flags: -Copt-level=0 | ||
|
||
pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { | ||
if n > 15 { | ||
encode_num(n / 16, &mut writer)?; | ||
} | ||
Ok(()) | ||
} | ||
|
||
pub trait ExampleWriter { | ||
type Error; | ||
} | ||
|
||
impl<'a, T: ExampleWriter> ExampleWriter for &'a mut T { | ||
type Error = T::Error; | ||
} | ||
|
||
struct Error; | ||
|
||
impl ExampleWriter for Error { | ||
type Error = (); | ||
} | ||
|
||
fn main() { | ||
encode_num(69, &mut Error).unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ known-bug: #106473 | ||
#![feature(generic_const_exprs)] | ||
|
||
const DEFAULT: u32 = 1; | ||
|
||
struct V<const U: usize = DEFAULT> | ||
where | ||
[(); U]:; | ||
|
||
trait Tr {} | ||
|
||
impl Tr for V {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
//@ known-bug: #110534 | ||
//@ edition:2021 | ||
use core::cell::Ref; | ||
|
||
struct System; | ||
|
||
trait IntoSystem { | ||
fn into_system(self) -> System; | ||
} | ||
|
||
impl IntoSystem for fn(Ref<'_, u32>) { | ||
fn into_system(self) -> System { System } | ||
} | ||
|
||
impl<A> IntoSystem for fn(A) | ||
where | ||
// n.b. No `Ref<'_, u32>` can satisfy this bound | ||
A: 'static + for<'x> MaybeBorrowed<'x, Output = A>, | ||
{ | ||
fn into_system(self) -> System { System } | ||
} | ||
|
||
//--------------------------------------------------- | ||
|
||
trait MaybeBorrowed<'a> { | ||
type Output: 'a; | ||
} | ||
|
||
// If you comment this out you'll see the compiler chose to look at the | ||
// fn(A) implementation of IntoSystem above | ||
impl<'a, 'b> MaybeBorrowed<'a> for Ref<'b, u32> { | ||
type Output = Ref<'a, u32>; | ||
} | ||
|
||
// --------------------------------------------- | ||
|
||
fn main() { | ||
fn sys_ref(_age: Ref<u32>) {} | ||
let _sys_c = (sys_ref as fn(_)).into_system(); | ||
// properly fails | ||
// let _sys_c = (sys_ref as fn(Ref<'static, u32>)).into_system(); | ||
// properly succeeds | ||
// let _sys_c = (sys_ref as fn(Ref<'_, u32>)).into_system(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
//@ known-bug: #110627 | ||
#![feature(non_lifetime_binders)] | ||
|
||
fn take(id: impl for<T> Fn(T) -> T) {} | ||
|
||
fn main() { | ||
take(|x| x) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
//@ known-bug: #111419 | ||
#![allow(incomplete_features)] | ||
#![feature(generic_const_exprs, generic_arg_infer)] | ||
|
||
pub trait Example<const X: usize, const Y: usize, const Z: usize = { X + Y }> | ||
where | ||
[(); X + Y]:, | ||
{} | ||
|
||
impl<const X: usize, const Y: usize> Example<X, Y> for Value {} | ||
|
||
pub struct Value; | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//@ known-bug: #111699 | ||
#![feature(core_intrinsics)] | ||
use std::intrinsics::offset; | ||
|
||
fn main() { | ||
let a = [1u8, 2, 3]; | ||
let ptr: *const u8 = a.as_ptr(); | ||
|
||
unsafe { | ||
assert_eq!(*offset(ptr, 0), 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//@ known-bug: #111709 | ||
//@ edition: 2021 | ||
|
||
use core::arch::asm; | ||
|
||
extern "C" fn test<T>() {} | ||
|
||
fn uwu() { | ||
unsafe { | ||
asm!( | ||
"/* {0} */", | ||
sym test::<&mut ()> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//@ known-bug: #111709 | ||
//@ edition:2021 | ||
|
||
use core::arch::asm; | ||
|
||
struct TrapFrame; | ||
|
||
unsafe extern "C" fn _rust_abi_shim1<A, R>(arg: A, f: fn(A) -> R) -> R { | ||
f(arg) | ||
} | ||
|
||
unsafe extern "C" fn _start_trap() { | ||
extern "Rust" { | ||
fn interrupt(tf: &mut TrapFrame); | ||
} | ||
asm!( | ||
" | ||
la a1, {irq} | ||
call {shim} | ||
", | ||
shim = sym crate::_rust_abi_shim1::<&mut TrapFrame, ()>, | ||
irq = sym interrupt, | ||
options(noreturn) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
//@ known-bug: #111883 | ||
#![crate_type = "lib"] | ||
#![feature(arbitrary_self_types, no_core, lang_items)] | ||
#![no_core] | ||
|
||
#[lang = "sized"] | ||
trait Sized {} | ||
#[lang = "copy"] | ||
trait Copy {} | ||
#[lang = "receiver"] | ||
trait Receiver {} | ||
#[lang = "dispatch_from_dyn"] | ||
trait DispatchFromDyn<T> {} | ||
impl<'a, T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<&'a U> for &'a T {} | ||
#[lang = "unsize"] | ||
trait Unsize<T: ?Sized> {} | ||
#[lang = "coerce_unsized"] | ||
pub trait CoerceUnsized<T: ?Sized> {} | ||
impl<'a, 'b: 'a, T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} | ||
|
||
#[lang = "drop_in_place"] | ||
fn drop_in_place_fn<T>(a: &dyn Trait2<T>) {} | ||
|
||
pub trait Trait1 { | ||
fn foo(&self); | ||
} | ||
|
||
pub struct Type1; | ||
|
||
impl Trait1 for Type1 { | ||
fn foo(&self) {} | ||
} | ||
|
||
pub trait Trait2<T> {} | ||
|
||
pub fn bar1() { | ||
let a = Type1; | ||
let b = &a as &dyn Trait1; | ||
b.foo(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//@ known-bug: #113272 | ||
trait Trait { | ||
type RefTarget; | ||
} | ||
|
||
impl Trait for () where Missing: Trait {} | ||
|
||
struct Other { | ||
data: <() as Trait>::RefTarget, | ||
} | ||
|
||
fn main() { | ||
unsafe { | ||
std::mem::transmute::<Option<()>, Option<&Other>>(None); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//@ known-bug: #113846 | ||
trait Www { | ||
type W; | ||
} | ||
|
||
trait Xxx: Www<W = Self::X> { | ||
type X; | ||
} | ||
|
||
trait Yyy: Xxx {} | ||
|
||
trait Zzz<'a>: Yyy + Xxx<X = Self::Z> { | ||
type Z; | ||
} | ||
|
||
trait Aaa { | ||
type Y: Yyy; | ||
} | ||
|
||
trait Bbb: Aaa<Y = Self::B> { | ||
type B: for<'a> Zzz<'a>; | ||
} | ||
|
||
impl<T> Bbb for T | ||
where | ||
T: Aaa, | ||
T::Y: for<'a> Zzz<'a>, | ||
{ | ||
type B = T::Y; | ||
} | ||
|
||
pub fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
//@ known-bug: #114212 | ||
#![allow(incomplete_features)] | ||
#![feature(generic_const_exprs)] | ||
|
||
const SOME_CONST: usize = 1; | ||
|
||
struct UwU< | ||
// have a const generic with a default that's from another const item | ||
// (associated consts work, a const declared in a block here, inline_const, etc) | ||
const N: usize = SOME_CONST, | ||
// use the previous const in a type generic | ||
A = [(); N], | ||
> { | ||
// here to suppress "unused generic" error if the code stops ICEing | ||
_x: core::marker::PhantomData<A>, | ||
} |
Oops, something went wrong.