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

Commit 3c5ef2b

Browse files
authored
Merge pull request #895 from Alexendoo/add
Add some ICEs
2 parents 22a1688 + c4a02ee commit 3c5ef2b

20 files changed

+358
-0
lines changed

ices/86953.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - --crate-type=lib -C incremental=foo << 'EOF'
4+
#![feature(const_generics)]
5+
#![feature(const_evaluatable_checked)]
6+
7+
use std::ops::Add;
8+
9+
pub struct StackBitSet<const N: usize> where [(); 0]: Sized;
10+
11+
impl<const N: usize, const M: usize> Add<&StackBitSet<M>> for StackBitSet<N>
12+
where
13+
[(); 0+0]: Sized, // changing 0+0 to 0 makes this work
14+
[(); 0]: Sized,
15+
[(); 0]: Sized,
16+
{
17+
type Output = StackBitSet<0>;
18+
fn add(self, _: &StackBitSet<M>) -> Self::Output {
19+
loop {}
20+
}
21+
}
22+
23+
#[test]
24+
fn bitset_create() {
25+
let _a: StackBitSet<42> = StackBitSet;
26+
}
27+
EOF

ices/87142.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - --crate-type lib -C debuginfo=2 << 'EOF'
4+
#![feature(type_alias_impl_trait, generator_trait, generators)]
5+
use std::ops::{Generator};
6+
7+
pub trait GeneratorProviderAlt: Sized {
8+
type Gen: Generator<(), Return=(), Yield=()>;
9+
10+
fn start(ctx: Context<Self>) -> Self::Gen;
11+
}
12+
13+
pub struct Context<G: 'static + GeneratorProviderAlt> {
14+
// back-link to our generator state
15+
// In reality some other pointer type, but Box triggers the bug
16+
// Also in reality, points to a wrapper struct that only indirectly holds
17+
// the generator state.
18+
link: Box<G::Gen>,
19+
}
20+
21+
impl GeneratorProviderAlt for () {
22+
type Gen = impl Generator<(), Return=(), Yield=()>;
23+
fn start(ctx: Context<Self>) -> Self::Gen {
24+
move || {
25+
match ctx { _ => () } // make sure to use the context
26+
yield ();
27+
}
28+
}
29+
}
30+
EOF

ices/87219.sh

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - --emit=mir -Zpolymorphize=on << 'EOF'
4+
#![feature(generic_associated_types)]
5+
6+
pub trait Iter {
7+
type Item<'a> where Self: 'a;
8+
9+
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>>;
10+
11+
fn for_each<F>(mut self, mut f: F)
12+
where Self: Sized, F: for<'a> FnMut(Self::Item<'a>)
13+
{
14+
while let Some(item) = self.next() {
15+
f(item);
16+
}
17+
}
18+
}
19+
20+
pub struct Windows<T> {
21+
items: Vec<T>,
22+
start: usize,
23+
len: usize,
24+
}
25+
26+
impl<T> Windows<T> {
27+
pub fn new(items: Vec<T>, len: usize) -> Self {
28+
Self { items, start: 0, len }
29+
}
30+
}
31+
32+
impl<T> Iter for Windows<T> {
33+
type Item<'a> where T: 'a = &'a mut [T];
34+
35+
fn next<'a>(&'a mut self) -> Option<Self::Item<'a>> {
36+
let slice = self.items.get_mut(self.start..self.start + self.len)?;
37+
self.start += 1;
38+
Some(slice)
39+
}
40+
}
41+
42+
fn main() {
43+
Windows::new(vec![1, 2, 3, 4, 5], 3)
44+
.for_each(|slice| println!("{:?}", slice));
45+
}
46+
EOF

ices/87258.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#![feature(min_type_alias_impl_trait)]
2+
#![feature(generic_associated_types)]
3+
use std::future::Future;
4+
5+
pub trait Trait1
6+
{
7+
type Error: Clone;
8+
type Assoc2<'a>
9+
where
10+
Self: 'a;
11+
}
12+
13+
pub trait Trait2: Trait1 {
14+
type FooFuture<'a, 'b>: Future<Output = Result<(), Self::Error>>;
15+
fn foo<'a: 'b, 'b>(assoc2: &'b mut Self::Assoc2<'a>) -> Self::FooFuture<'a, 'b>
16+
where
17+
Self: 'a;
18+
}
19+
20+
impl<'c, S : Trait1> Trait1 for &'c mut S {
21+
type Error = S::Error;
22+
23+
type Assoc2<'a> where 'c: 'a = S::Assoc2<'a>;
24+
}
25+
26+
impl<'c, S : Trait2> Trait2 for &'c mut S {
27+
type FooFuture<'a, 'b> = impl Future<Output = Result<(), Self::Error>>;
28+
fn foo<'a: 'b, 'b>(assoc2: &'b mut Self::Assoc2<'a>) -> Self::FooFuture<'a, 'b>
29+
where
30+
Self: 'a
31+
{
32+
async move {
33+
unimplemented!();
34+
}
35+
}
36+
}

ices/87308.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - -Zunpretty=everybody_loops << 'EOF'
4+
macro_rules! foo {
5+
() => { break 'x; } //~ ERROR use of undeclared label `'x`
6+
}
7+
8+
pub fn main() {
9+
'x: loop { foo!() }
10+
}
11+
EOF

ices/87340.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
type PartiallyDefined<T> = impl 'static;
2+
fn partially_defined() -> PartiallyDefined<_> {}

ices/87490.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
trait StreamOnce {
2+
type Position;
3+
}
4+
impl StreamOnce for &str {
5+
type Position = usize;
6+
}
7+
fn follow(_: &str) -> <&str as StreamOnce>::Position {
8+
String::new
9+
}

ices/87496.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#[repr(transparent)]
2+
struct TransparentCustomZst(());
3+
extern "C" {
4+
fn good17(p: TransparentCustomZst);
5+
}
6+
7+
fn main() {}

ices/87542.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pub enum Foo<const A: usize> {
2+
Bar,
3+
Baz([(); A]),
4+
}
5+
6+
7+
fn main() {
8+
// Cannot infer type for 9
9+
// let x = Foo::Bar::<9>;
10+
// Compiler error
11+
let x = Foo::Bar::<9usize>;
12+
}

ices/87549.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - -C incremental=true << 'EOF'
4+
trait XTrait<A> {}
5+
6+
struct X<T: XTrait<A>, A> (T, A);
7+
8+
trait Y<'t> {
9+
type M;
10+
type N: 't;
11+
}
12+
13+
impl<'t, T: XTrait<A>, A> Y<'t> for X<T, A> {
14+
type M = X<T, Self::N>;
15+
type N = &'t ();
16+
}
17+
18+
fn main() {
19+
println!("Hello, world!");
20+
}
21+
EOF

ices/87558.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
struct ErrorKind;
2+
struct Error(ErrorKind);
3+
impl Fn(&isize) for Error {
4+
fn from() {}
5+
}

ices/87563.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
3+
rustc - --emit=mir -Zsave-analysis << 'EOF'
4+
#![feature(generic_arg_infer)]
5+
6+
struct All<'a, T, const N: usize> {
7+
v: &'a T,
8+
}
9+
10+
struct BadInfer<_>;
11+
//~^ ERROR expected identifier
12+
//~| ERROR parameter `_` is never used
13+
14+
fn all_fn<'a, T, const N: usize>() {}
15+
16+
fn bad_infer_fn<_>() {}
17+
//~^ ERROR expected identifier
18+
19+
20+
fn main() {
21+
let a: All<_, _, _>;
22+
all_fn();
23+
let v: [u8; _];
24+
//~^ ERROR in expressions
25+
let v: [u8; 10] = [0; _];
26+
//~^ ERROR in expressions
27+
}
28+
EOF

ices/87573.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#![crate_type = "lib"]
2+
#![feature(no_core, lang_items)]
3+
#![no_core]
4+
5+
static STATIC_BOOL: bool = true;
6+
7+
#[lang = "sized"]
8+
trait Sized {}
9+
10+
#[lang = "copy"]
11+
trait Copy {}
12+
13+
// Uncommenting avoids the second ICE
14+
//impl Copy for bool {}
15+
16+
#[lang = "sync"]
17+
trait Sync {}
18+
impl Sync for bool {}
19+
20+
// Both errors occur here and are independent
21+
#[lang = "drop_in_place"]
22+
fn drop_fn() { // <- the drop fn expects a generic T, missing T causes index error
23+
while false {} // <- this expects the bool condition to be Copy, and it isn't
24+
}
25+
26+
// required to make the compiler happy
27+
#[lang = "start"]
28+
fn start(){}

ices/87577.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[derive(Debug)]
2+
struct S<#[cfg(feature = "alloc")] N: A<T>> {}

ices/87750.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#![feature(generic_associated_types)]
2+
use std::rc::Rc;
3+
use std::ops::Deref;
4+
5+
trait PointerFamily {
6+
type Pointer<T>: Deref<Target=T> + Sized;
7+
8+
fn new<T>(obj: T) -> Self::Pointer<T>;
9+
}
10+
11+
#[derive(Debug)]
12+
struct RcFamily;
13+
14+
impl PointerFamily for RcFamily {
15+
type Pointer<T> = Rc<T>;
16+
17+
fn new<T>(obj: T) -> Rc<T> {
18+
Rc::new(obj)
19+
}
20+
}
21+
22+
#[derive(Debug)]
23+
enum Node<T, P: PointerFamily> where P::Pointer<Node<T, P>>: Sized {
24+
Cons(T, P::Pointer<Node<T, P>>),
25+
Nil
26+
}
27+
28+
type List<T, P> = <P as PointerFamily>::Pointer<Node<T, P>>;
29+
type RcList<T> = List<T, RcFamily>;
30+
type RcNode<T> = Node<T, RcFamily>;
31+
32+
impl<T, P: PointerFamily> Node<T, P> where P::Pointer<Node<T, P>>: Sized {
33+
fn new() -> P::Pointer<Self> {
34+
P::new(Self::Nil)
35+
}
36+
37+
fn cons(head: T, tail: P::Pointer<Self>) -> P::Pointer<Self> {
38+
P::new(Self::Cons(head, tail))
39+
}
40+
}
41+
42+
fn main() {
43+
let mut list: RcList<i32> = RcNode::<i32>::new();
44+
list = RcNode::<i32>::cons(1, list);
45+
//println!("{:?}", list);
46+
47+
}

ices/87762.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#![feature(generic_associated_types)]
2+
3+
trait Trait {
4+
type Assoc<'a>;
5+
}
6+
7+
fn f<T: Trait>(_: T, _: fn(T::Assoc<'_>)) {}
8+
9+
struct Type;
10+
11+
impl Trait for Type {
12+
type Assoc<'a> = &'a ();
13+
}
14+
15+
fn main() {
16+
f(Type, |_| ());
17+
}

ices/87771.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let mut arr = vec![vec![]];
3+
arr[0][0] = arr[0][0] = true;
4+
}

ices/87793.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn m(){#[c=[r
2+
e
3+
e

ices/87802.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![feature(asm)]
2+
3+
fn hmm() -> ! {
4+
let x;
5+
unsafe {
6+
asm!("/* {0} */", out(reg) x);
7+
}
8+
x
9+
}
10+
11+
fn main() {
12+
hmm();
13+
}

ices/87877.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
macro_rules! two_items {() => (
2+
extern {}
3+
extern {}
4+
)}
5+
6+
macro_rules! single_item_funneler {( $item:item ) => ( $item )}
7+
8+
fn inside_some_function() {
9+
single_item_funneler! { two_items! {} }
10+
}

0 commit comments

Comments
 (0)