This commit is contained in:
Matthias Krüger 2024-03-29 19:39:47 +01:00
parent a5932b1507
commit 98dd566033
31 changed files with 664 additions and 1 deletions

17
tests/crashes/100041.rs Normal file
View File

@ -0,0 +1,17 @@
//@ known-bug: #100041
pub trait WellUnformed {
type RequestNormalize;
}
impl<T: ?Sized> WellUnformed for T {
type RequestNormalize = ();
}
pub fn latent(_: &[<[[()]] as WellUnformed>::RequestNormalize; 0]) {}
pub fn bang() {
latent(&[]);
}
fn main() {}

11
tests/crashes/101962.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #101962
#![feature(core_intrinsics)]
pub fn wrapping<T: Copy>(a: T, b: T) {
let _z = core::intrinsics::wrapping_mul(a, b);
}
fn main() {
wrapping(1,2);
}

45
tests/crashes/102047.rs Normal file
View File

@ -0,0 +1,45 @@
//@ known-bug: #102047
struct Ty1;
struct Ty2;
pub trait Trait<T> {}
pub trait WithAssoc1<'a> {
type Assoc;
}
pub trait WithAssoc2<'a> {
type Assoc;
}
impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U)
where
T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>,
U: for<'a> WithAssoc2<'a>,
{
}
impl WithAssoc1<'_> for Ty1 {
type Assoc = ();
}
impl WithAssoc2<'_> for Ty1 {
type Assoc = i32;
}
impl WithAssoc1<'_> for Ty2 {
type Assoc = ();
}
impl WithAssoc2<'_> for Ty2 {
type Assoc = u32;
}
fn foo<T, U, V>()
where
T: for<'a> WithAssoc1<'a>,
U: for<'a> WithAssoc2<'a>,
(T, U): Trait<V>,
{
}
fn main() {
foo::<Ty1, Ty2, _>();
}

14
tests/crashes/102252.rs Normal file
View File

@ -0,0 +1,14 @@
//@ known-bug: #102252
#![feature(min_specialization, rustc_attrs)]
#[rustc_specialization_trait]
pub trait Trait {}
struct Struct
where
Self: Iterator<Item = <Self as Iterator>::Item>, {}
impl Trait for Struct {}
fn main() {}

27
tests/crashes/103899.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #103899
trait BaseWithAssoc {
type Assoc;
}
trait WrapperWithAssoc {
type BaseAssoc: BaseWithAssoc;
}
struct Wrapper<B> {
inner: B,
}
struct ProjectToBase<T: BaseWithAssoc> {
data_type_h: T::Assoc,
}
struct DoubleProject<L: WrapperWithAssoc> {
buffer: Wrapper<ProjectToBase<L::BaseAssoc>>,
}
fn trigger<L: WrapperWithAssoc<BaseAssoc = ()>>() -> DoubleProject<L> {
loop {}
}
fn main() {}

31
tests/crashes/105238-1.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #105238
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<const MAX_LENGTH: usize, CellIdx = Cond<{ MAX_LENGTH < 65535 }, u16, u32>>
where
CellIdx: Ret,
{
_idx: CellIdx::R,
}
fn main() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

31
tests/crashes/105238-2.rs Normal file
View File

@ -0,0 +1,31 @@
//@ known-bug: #105238
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
trait Ret {
type R;
}
struct Cond<const PRED: bool, U, V>(std::marker::PhantomData<U>, std::marker::PhantomData<V>);
impl<U, V> Ret for Cond<true, U, V> {
type R = U;
}
impl<U, V> Ret for Cond<false, U, V> {
type R = V;
}
struct RobinHashTable<
const MAX_LENGTH: usize,
CellIdx = <Cond<{ MAX_LENGTH < 65535 }, u16, u32> as Ret>::R,
> {
_idx: CellIdx,
}
fn main() {
use std::mem::size_of;
println!("{}", size_of::<RobinHashTable<1024>>());
println!("{}", size_of::<RobinHashTable<65536>>());
}

39
tests/crashes/105488.rs Normal file
View File

@ -0,0 +1,39 @@
//@ known-bug: #105488
pub trait MyFnOnce {
type Output;
fn call_my_fn_once(self) -> Self::Output;
}
pub struct WrapFnOnce<F>(F);
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for WrapFnOnce<F> {
type Output = D::Output;
fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self.0())
}
}
impl<F: FnOnce() -> D, D: MyFnOnce> MyFnOnce for F {
type Output = D::Output;
fn call_my_fn_once(self) -> Self::Output {
D::call_my_fn_once(self())
}
}
pub fn my_fn_1() -> impl MyFnOnce {
my_fn_2
}
pub fn my_fn_2() -> impl MyFnOnce {
WrapFnOnce(my_fn_1)
}
fn main() {
let v = my_fn_1();
let _ = v.call_my_fn_once();
}

9
tests/crashes/108814.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #108814
#![feature(non_lifetime_binders)]
fn take(_: impl for<T> FnOnce(T) -> T) {}
fn main() {
take(|x| x)
}

9
tests/crashes/109681.rs Normal file
View File

@ -0,0 +1,9 @@
//@ known-bug: #109681
#![crate_type="lib"]
#![feature(linkage)]
#[linkage = "common"]
pub static TEST3: bool = true;
fn main() {}

15
tests/crashes/110378.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #110378
// ignore-tidy-linelength
#![feature(generic_const_exprs)]
fn foo<const L: usize>(_a: [u8; L], _b: [u8; L]) -> [u8; L + 1] {
[0_u8; L + 1]
}
fn main() {
let baz = [[0_u8; 1]; 8];
let _: [u8; 4] = foo(foo(foo(baz[0], baz[1]), foo(baz[2], baz[3])), foo(foo(baz[4], baz[5]), foo(baz[6], baz[7])));
//let _: [u8; 3] = foo(foo(baz[0], baz[1]), foo(baz[2], baz[3]));
}

28
tests/crashes/110630.rs Normal file
View File

@ -0,0 +1,28 @@
//@ known-bug: #110630
#![feature(generic_const_exprs)]
use std::ops::Mul;
pub trait Indices<const N: usize> {
const NUM_ELEMS: usize = I::NUM_ELEMS * N;
}
pub trait Concat<J> {
type Output;
}
pub struct Tensor<I: Indices<N>, const N: usize>
where
[u8; I::NUM_ELEMS]: Sized, {}
impl<I: Indices<N>, J: Indices<N>, const N: usize> Mul<Tensor<J, N>> for Tensor<I, N>
where
I: Concat<T>,
<I as Concat<J>>::Output: Indices<N>,
[u8; I::NUM_ELEMS]: Sized,
[u8; J::NUM_ELEMS]: Sized,
[u8; <I as Concat<J>>::Output::NUM_ELEMS]: Sized,
{
type Output = Tensor<<I as Concat<J>>::Output, N>;
}

12
tests/crashes/111742.rs Normal file
View File

@ -0,0 +1,12 @@
//@ known-bug: #111742
// ignore-tidy-linelength
#![allow(incomplete_features)]
#![feature(generic_const_exprs)]
const CONST: u32 = 0;
struct Test<const N: u32, const M: u32 = { CONST/* Must be a const and not a Literal */ }> where [(); N as usize]: , ([u32; N as usize]);
fn main() {
let _: Test<1>;
}

19
tests/crashes/112201.rs Normal file
View File

@ -0,0 +1,19 @@
//@ known-bug: #112201
pub fn compose(
f1: impl FnOnce(f64) -> f64 + Clone,
f2: impl FnOnce(f64) -> f64 + Clone,
) -> impl FnOnce(f64) -> f64 + Clone {
move |x| f1(f2(x))
}
fn repeat_helper(
f: impl FnOnce(f64) -> f64 + Clone,
res: impl FnOnce(f64) -> f64 + Clone,
times: usize,
) -> impl FnOnce(f64) -> f64 + Clone {
return res;
repeat_helper(f.clone(), compose(f, res), times - 1)
}
fn main() {}

15
tests/crashes/113280.rs Normal file
View File

@ -0,0 +1,15 @@
//@ known-bug: #113280
#![feature(dyn_star, pointer_like_trait)]
#![allow(incomplete_features)]
use std::fmt::Debug;
use std::marker::PointerLike;
fn make_dyn_star<'a>(t: impl PointerLike + Debug + 'a) -> dyn* Debug + 'a {
f32::from_bits(0x1) as f64
}
fn main() {
println!("{:?}", make_dyn_star(Box::new(1i32)));
}

7
tests/crashes/113379.rs Normal file
View File

@ -0,0 +1,7 @@
//@ known-bug: #113379
async fn f999() -> Vec<usize> {
'b: {
continue 'b;
}
}

View File

@ -1,5 +1,5 @@
//@ compile-flags: -Zpolymorphize=on -Zinline-mir=yes
//@ known-bug: #12345
//@ known-bug: #122909
use std::sync::{Arc, Context, Weak};

6
tests/crashes/34127.rs Normal file
View File

@ -0,0 +1,6 @@
//@ compile-flags: -g -Copt-level=0
//@ known-bug: #34127
pub fn main() {
let _a = [(); 1 << 63];
}

21
tests/crashes/54888.rs Normal file
View File

@ -0,0 +1,21 @@
//@ known-bug: #54888
#![feature(unsize, coerce_unsized)]
use std::{
ops::CoerceUnsized,
marker::Unsize,
};
#[repr(C)]
struct Ptr<T: ?Sized>(Box<T>);
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
where
T: Unsize<U>,
{}
fn main() {
let foo = Ptr(Box::new(5)) as Ptr<dyn std::any::Any>;
}

11
tests/crashes/57276.rs Normal file
View File

@ -0,0 +1,11 @@
//@ known-bug: #57276
#![feature(arbitrary_self_types, dispatch_from_dyn)]
use std::ops::{Deref, DispatchFromDyn};
trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> {
fn foo(self: T) -> dyn Trait<T>;
}
fn main() {}

24
tests/crashes/74299.rs Normal file
View File

@ -0,0 +1,24 @@
//@ known-bug: #74299
#![feature(specialization)]
trait X {
type U;
fn f(&self) -> Self::U {
loop {}
}
}
impl<T> X for T {
default type U = ();
}
trait Y {
fn g(&self) {}
}
impl Y for <() as X>::U {}
impl Y for <i32 as X>::U {}
fn main() {
().f().g();
}

42
tests/crashes/74451.rs Normal file
View File

@ -0,0 +1,42 @@
//@ known-bug: #74451
//@ compile-flags: -Copt-level=0
#![feature(specialization)]
#![feature(unsize, coerce_unsized)]
#![allow(incomplete_features)]
#![crate_type = "lib"]
use std::ops::CoerceUnsized;
pub struct SmartassPtr<A: Smartass+?Sized>(A::Data);
pub trait Smartass {
type Data;
type Data2: CoerceUnsized<*const [u8]>;
}
pub trait MaybeObjectSafe {}
impl MaybeObjectSafe for () {}
impl<T> Smartass for T {
type Data = <Self as Smartass>::Data2;
default type Data2 = *const [u8; 0];
}
impl Smartass for () {
type Data2 = *const [u8; 1];
}
impl Smartass for dyn MaybeObjectSafe {
type Data = *const [u8];
type Data2 = *const [u8; 0];
}
impl<U: Smartass+?Sized, T: Smartass+?Sized> CoerceUnsized<SmartassPtr<T>> for SmartassPtr<U>
where <U as Smartass>::Data: std::ops::CoerceUnsized<<T as Smartass>::Data>
{}
pub fn conv(s: SmartassPtr<()>) -> SmartassPtr<dyn MaybeObjectSafe> {
s // This shouldn't coerce
}

16
tests/crashes/79409.rs Normal file
View File

@ -0,0 +1,16 @@
//@ known-bug: #79409
#![feature(extern_types)]
#![feature(unsized_locals)]
extern {
type Device;
}
unsafe fn make_device() -> Box<Device> {
Box::from_raw(0 as *mut _)
}
fn main() {
let d: Device = unsafe { *make_device() };
}

19
tests/crashes/79590.rs Normal file
View File

@ -0,0 +1,19 @@
//@ known-bug: #79590
trait Database: Restriction<Inner = u32> {}
trait Restriction {
type Inner;
}
struct Test {}
impl Database for Test {}
impl Restriction for Test {
type Inner = u32;
}
fn main() {
let t = Test {};
let x: &dyn Database<Inner = _> = &t;
}

4
tests/crashes/87577.rs Normal file
View File

@ -0,0 +1,4 @@
//@ known-bug: #87577
#[derive(Debug)]
struct S<#[cfg(feature = "alloc")] N: A<T>> {}

27
tests/crashes/88296.rs Normal file
View File

@ -0,0 +1,27 @@
//@ known-bug: #88296
#![feature(specialization)]
trait Foo {
type Bar;
}
impl<T> Foo for T {
default type Bar = u32;
}
impl Foo for i32 {
type Bar = i32;
}
extern "C" {
#[allow(unused)]
// OK as Foo::Bar is explicitly defined for i32
static OK: <i32 as Foo>::Bar;
#[allow(unused)]
// ICE in the improper_ctypes lint
// as Foo::Bar is only default implemented for ()
static ICE: <() as Foo>::Bar;
}
pub fn main() {}

57
tests/crashes/90110.rs Normal file
View File

@ -0,0 +1,57 @@
//@ known-bug: #90110
use std::fs::File;
use std::io::{BufReader, BufRead};
use std::str::Split;
use std::path::Path;
pub trait Parser<D>
where dyn Parser<D>: Sized
{
fn new(split_header: Split<&str>) -> Self where Self: Sized;
fn parse_line(&self, split_line: &Split<&str>) -> D;
}
pub struct CsvReader<D> {
parser: Box<dyn Parser<D>>,
reader: BufReader<File>,
buf: String, // Buffer we will read into. Avoids re-allocation on each line.
path: String, // Record this so we can return more informative error messages.
line: usize, // Same motivation for this.
}
impl<D> CsvReader<D>
where dyn Parser<D>: Sized
{
fn new<F>(path: &str, make_parser: F) -> CsvReader<D>
where F: Fn(Split<char>) -> dyn Parser<D> {
let file = match File::open(Path::new(path)) {
Err(err) => panic!("Couldn't read {}: {}", path, err),
Ok(file) => file,
};
let mut reader = BufReader::new(file);
let mut buf = String::new();
let parser = Box::new(match reader.read_line(&mut buf) {
Err(err) => panic!("Failed to read the header line from {}: {}", path, err),
Ok(_) => {
let split_header = buf.split(',');
make_parser(split_header)
},
});
CsvReader {
parser: parser,
reader,
buf,
path: path.to_string(),
line: 2,
}
}
}
pub fn main() {}

42
tests/crashes/91985.rs Normal file
View File

@ -0,0 +1,42 @@
//@ known-bug: #91985
#![feature(generic_associated_types)]
pub trait Trait1 {
type Associated: Ord;
}
pub trait Trait2 {
type Associated: Clone;
}
pub trait GatTrait {
type Gat<T: Clone>;
}
pub struct GatStruct;
impl GatTrait for GatStruct {
type Gat<T: Clone> = Box<T>;
}
pub struct OuterStruct<T1: Trait1, T2: Trait2> {
inner: InnerStruct<T2, GatStruct>,
t1: T1,
}
pub struct InnerStruct<T: Trait2, G: GatTrait> {
pub gat: G::Gat<T::Associated>,
}
impl<T1, T2> OuterStruct<T1, T2>
where
T1: Trait1,
T2: Trait2<Associated = T1::Associated>,
{
pub fn new() -> Self {
todo!()
}
}
pub fn main() {}

6
tests/crashes/96304.rs Normal file
View File

@ -0,0 +1,6 @@
//@ known-bug: #96304
#![feature(asm_sym)]
core::arch::global_asm!("/* {} */", sym<&'static ()>::clone);
pub fn main() {}

22
tests/crashes/97501.rs Normal file
View File

@ -0,0 +1,22 @@
//@ known-bug: #97501
#![feature(core_intrinsics)]
use std::intrinsics::wrapping_add;
#[derive(Clone, Copy)]
struct WrapInt8 {
value: u8
}
impl std::ops::Add for WrapInt8 {
type Output = WrapInt8;
fn add(self, other: WrapInt8) -> WrapInt8 {
wrapping_add(self, other)
}
}
fn main() {
let p = WrapInt8 { value: 123 };
let q = WrapInt8 { value: 234 };
println!("{}", (p + q).value);
}

37
tests/crashes/98322.rs Normal file
View File

@ -0,0 +1,37 @@
//@ known-bug: #98322
#![feature(generic_const_exprs)]
// Main function seems irrelevant
fn main() {}
// Constant must be provided via an associated constant in a trait
pub trait ConstTrait {
const ASSOC_CONST: usize;
}
// For some reason I find it's necessary to have an implementation of this trait that recurses
pub trait OtherTrait
{
fn comm(self);
}
// There must be a blanket impl here
impl<T> OtherTrait for T where
T: ConstTrait,
[();T::ASSOC_CONST]: Sized,
{
fn comm(self) {
todo!()
}
}
// The struct must be recursive
pub struct RecursiveStruct(Box<RecursiveStruct>);
// This implementation must exist, and it must recurse into its child
impl OtherTrait for RecursiveStruct {
fn comm(self) {
(self.0).comm();
}
}