Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit fc37139

Browse files
authored
Merge pull request #168 from Alexendoo/added
Add some more ICEs
2 parents 7d48de2 + d1e888a commit fc37139

Some content is hidden

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

57 files changed

+742
-0
lines changed

fixed/59353.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pub struct Node<NodeRef = Box<Self>>(NodeRef);
2+
3+
pub struct Foo(Node);
4+
5+
fn main() {}

fixed/59956-1.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
use std::marker::PhantomData;
2+
3+
struct Invariant<'id, I = Self> {
4+
lifetime: PhantomData<*mut &'id I>,
5+
}
6+
7+
trait Contract<'s> {
8+
type Item: for<'r> Contract<'r>;
9+
}
10+
11+
impl <'a, 'b> Contract<'b> for Invariant<'a> {
12+
type Item = Invariant<'b>;
13+
}
14+
15+
fn main() {}

fixed/59956-2.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct Bug<B = Self>;
2+
impl Bug {}
3+
4+
fn main() {}

ices/41073.rs

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![feature(untagged_unions)]
2+
3+
union Test {
4+
a: A,
5+
b: B
6+
}
7+
8+
#[derive(Debug)]
9+
struct A(i32);
10+
impl Drop for A {
11+
fn drop(&mut self) { println!("A"); }
12+
}
13+
14+
#[derive(Debug)]
15+
struct B(f32);
16+
impl Drop for B {
17+
fn drop(&mut self) { println!("B"); }
18+
}
19+
20+
fn main() {
21+
let mut test = Test { a: A(3) };
22+
println!("{:?}", unsafe { test.b });
23+
unsafe { test.b = B(0.5); }
24+
}

ices/43037.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_type = "lib"]
2+
#![feature(specialization)] // comment this line to get the expected behavior
3+
trait X {}
4+
trait Y: X {}
5+
trait Z { type Assoc: Y; }
6+
struct A<T>(T);
7+
8+
impl<T> Y for T where T: X {}
9+
impl<T: X> Z for A<T> { type Assoc = T; }
10+
11+
// this impl is invalid, but causes an ICE anyway
12+
impl<T> From<<A<T> as Z>::Assoc> for T {}
13+
14+
fn main() {}

ices/43924.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(associated_type_defaults)]
2+
trait Foo < T : Default + ToString >
3+
{
4+
type Out : Default + ToString = ToString;
5+
}
6+
7+
impl Foo < u32 > for () {}
8+
impl Foo < u64 > for () {}
9+
10+
fn main ()
11+
{
12+
assert_eq ! (< () as Foo < u32 >> :: Out :: default().to_string(), "false");
13+
}

ices/45814.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#![feature(specialization)]
2+
3+
pub trait Trait<T> { }
4+
5+
default impl<T, U> Trait<T> for U { }
6+
7+
impl<T> Trait<<T as Iterator>::Item> for T { }
8+
9+
fn main() { }

ices/46511.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
struct Foo<'a>
2+
{
3+
a: [u8; std::mem::size_of::<&'a mut u8>()]
4+
}

ices/47814.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
struct ArpIPv4<'a> {
2+
s: &'a u8
3+
}
4+
5+
impl<'a> ArpIPv4<'a> {
6+
const LENGTH: usize = 20;
7+
8+
pub fn to_buffer() -> [u8; Self::LENGTH] {
9+
unimplemented!()
10+
}
11+
}
12+
13+
fn main() {}

ices/49362.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(generic_associated_types)]
2+
3+
struct S;
4+
5+
trait Trait {
6+
type Associated<'a>;
7+
}
8+
9+
impl Trait for S {
10+
type Associated<'a> = &'a ();
11+
}
12+
13+
fn main() {}

ices/51506.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![feature(never_type)]
2+
#![feature(specialization)]
3+
4+
use std::iter::{self, Empty};
5+
6+
trait Trait {
7+
type Out: Iterator<Item = u32>;
8+
9+
fn f(&self) -> Option<Self::Out>;
10+
}
11+
12+
impl<T> Trait for T {
13+
default type Out = !;
14+
15+
default fn f(&self) -> Option<Self::Out> {
16+
None
17+
}
18+
}
19+
20+
struct X;
21+
22+
impl Trait for X {
23+
type Out = Empty<u32>;
24+
25+
fn f(&self) -> Option<Self::Out> {
26+
Some(iter::empty())
27+
}
28+
}
29+
30+
fn main() {
31+
if let Some(iter) = 1.f() { // replacing 1 by X makes the code compiles and runs fine
32+
println!("Some");
33+
for x in iter {
34+
println!("x = {}", x);
35+
}
36+
}
37+
}

ices/51892.rs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(specialization)]
2+
3+
pub trait Trait {
4+
type Type;
5+
}
6+
7+
impl<T: ?Sized> Trait for T {
8+
default type Type = [u8; 1];
9+
}
10+
11+
impl<T: Trait> Trait for *const T {
12+
type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()];
13+
}

ices/52808.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct Foo<'a> { x: &'a () }
2+
3+
impl<'a> Foo<'a> {
4+
const X: usize = 0;
5+
6+
fn foo(_: [u8; Self::X]) {}
7+
}
8+
9+
10+
fn main() {}

ices/52843.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(type_alias_impl_trait)]
2+
3+
type Foo<T> = impl Default;
4+
5+
#[allow(unused)]
6+
fn foo<T: Default>(t: T) -> Foo<T> {
7+
t
8+
}
9+
10+
struct NotDefault;
11+
12+
fn main() {
13+
let _ = Foo::<NotDefault>::default();
14+
}

ices/53092.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#![feature(const_fn)]
2+
#![feature(const_fn_union)]
3+
#![feature(type_alias_impl_trait)]
4+
#![feature(untagged_unions)]
5+
6+
const fn transmute<T, U>(t: T) -> U {
7+
union Transform<TT, UU> {
8+
t: TT,
9+
u: UU,
10+
}
11+
12+
unsafe { Transform { t }.u }
13+
}
14+
15+
type Foo<F, U> = impl Fn(F) -> U + Copy;
16+
17+
const BAZR: Foo<u8, ()> = transmute(|x: ()| { x });
18+
19+
fn bar<T, U: From<T>>() -> Foo<T, U> { |x| x.into() }
20+
21+
fn main() {
22+
let x = BAZR(0);
23+
}

ices/53448.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![feature(unboxed_closures)]
2+
3+
trait Lt<'a> {
4+
type T;
5+
}
6+
impl<'a> Lt<'a> for () {
7+
type T = ();
8+
}
9+
10+
fn main() {
11+
let v:<() as Lt<'_>>::T = ();
12+
let f:&mut FnMut<(_,),Output=()> = &mut |_:<() as Lt<'_>>::T|{};
13+
f(v);
14+
}

ices/53475.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(coerce_unsized)]
2+
3+
use std::ops::CoerceUnsized;
4+
use std::any::Any;
5+
6+
struct Foo<T> {
7+
data: Box<T>
8+
}
9+
10+
impl<T> CoerceUnsized<Foo<dyn Any>> for Foo<T> {}
11+
12+
fn main() {}

ices/54038.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
struct Foo<'a> {
2+
data: &'a [u8],
3+
}
4+
5+
impl<'a> Foo<'a> {
6+
const LEN: usize = 4;
7+
fn bar(buf: &mut [u8; Self::LEN]) {
8+
unimplemented!()
9+
}
10+
}

ices/54108.rs

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
use std::ops::Add;
2+
3+
pub trait Encoder {
4+
type Size: Add<Output = Self::Size>;
5+
6+
fn foo(&self) -> Self::Size;
7+
}
8+
9+
pub trait SubEncoder : Encoder {
10+
type ActualSize;
11+
12+
fn bar(&self) -> Self::Size;
13+
}
14+
15+
impl<T> Encoder for T where T: SubEncoder {
16+
type Size = <Self as SubEncoder>::ActualSize;
17+
18+
fn foo(&self) -> Self::Size {
19+
self.bar() + self.bar()
20+
}
21+
}
22+
23+
pub struct UnitEncoder;
24+
25+
impl SubEncoder for UnitEncoder {
26+
type ActualSize = ();
27+
28+
fn bar(&self) {}
29+
}
30+
31+
32+
fn main() {
33+
fun(&UnitEncoder {});
34+
}
35+
36+
pub fn fun<R: Encoder>(encoder: &R) {
37+
encoder.foo();
38+
}

ices/54840.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#![feature(impl_trait_in_bindings)]
2+
3+
use std::ops::Add;
4+
5+
fn main() {
6+
let i: i32 = 0;
7+
let j: &impl Add = &i;
8+
}

ices/54888.rs

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(unsize, coerce_unsized)]
2+
3+
use std::{
4+
ops::CoerceUnsized,
5+
marker::Unsize,
6+
};
7+
8+
#[repr(C)]
9+
struct Ptr<T: ?Sized>(Box<T>);
10+
11+
impl<T: ?Sized, U: ?Sized> CoerceUnsized<Ptr<U>> for Ptr<T>
12+
where
13+
T: Unsize<U>,
14+
{}
15+
16+
17+
fn main() {
18+
let foo = Ptr(Box::new(5)) as Ptr<::std::any::Any>;
19+
}

ices/54895.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait Trait<'a> {
2+
type Out;
3+
}
4+
impl<'a> Trait<'a> for () {
5+
type Out = ();
6+
}
7+
fn main() -> impl for<'a> Trait<'a, Out = impl ?Sized + 'a> {
8+
()
9+
}

ices/55414.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
macro_rules! bug {
2+
($expr:expr) => {
3+
#[rustc_dummy = $expr] // Any key-value attribute, not necessarily `doc`
4+
struct S;
5+
};
6+
}
7+
8+
// Any expressions containing macro call `X` that's more complex than `X` itself.
9+
// Parentheses will work.
10+
bug!((line!()));
11+
12+
fn main() {}

ices/56445-1.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
struct OnDiskDirEntry<'a> { _s: &'a usize }
2+
3+
impl<'a> OnDiskDirEntry<'a> {
4+
const LFN_FRAGMENT_LEN: usize = 2;
5+
6+
fn lfn_contents(&self) -> [char; Self::LFN_FRAGMENT_LEN] { loop { } }
7+
}
8+
9+
fn main() {}

ices/56445-2.rs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#![feature(const_generics)]
2+
use core::marker::PhantomData;
3+
4+
struct Bug<'a, const S: &'a str>(PhantomData<&'a ()>);
5+
6+
impl Bug<'_, {""}> {}

ices/56445-3.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub struct Memory<'rom> {
2+
rom: &'rom [u8],
3+
ram: [u8; Self::SIZE],
4+
}
5+
6+
impl<'rom> Memory<'rom> {
7+
pub const SIZE: usize = 0x8000;
8+
}

ices/57200.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#![feature(impl_trait_in_bindings)]
2+
3+
fn bug<'a, 'b, T>()
4+
where
5+
'a: 'b,
6+
{
7+
let f: impl Fn(&'a T) -> &'b T = |x| x;
8+
}
9+
10+
11+
fn main() {}

0 commit comments

Comments
 (0)