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

Commit 2cd5e5a

Browse files
committed
Add some ICEs
1 parent 66d559b commit 2cd5e5a

File tree

5 files changed

+137
-0
lines changed

5 files changed

+137
-0
lines changed

ices/75229.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
cat > 75229.rs <<EOF
4+
enum TestEnum {
5+
Field { test_field: String },
6+
}
7+
fn main(){
8+
()
9+
}
10+
11+
EOF
12+
13+
RUST_BACKTRACE=1 RUST_SAVE_ANALYSIS_CONFIG='{"output_file":null,"full_docs":true,"pub_only":false,"reachable_only":false,"distro_crate":false,"signatures":true,"borrow_data":false}' rustc 75229.rs -Z save_analysis

ices/76375.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
cat > x.rs <<EOF
4+
#![crate_type = "lib"]
5+
6+
#[inline(always)]
7+
pub fn f(s: bool) -> String {
8+
let a = "Hello world!".to_string();
9+
let b = a;
10+
let c = b;
11+
if s {
12+
c
13+
} else {
14+
String::new()
15+
}
16+
}
17+
18+
EOF
19+
20+
cat > y.rs <<EOF
21+
#![crate_type = "lib"]
22+
23+
pub async fn g() {
24+
x::f(true);
25+
h().await;
26+
}
27+
28+
pub async fn h() {}
29+
30+
EOF
31+
32+
rustc --edition=2018 -Zmir-opt-level=2 x.rs
33+
rustc --edition=2018 -Zmir-opt-level=2 y.rs --extern x -L.

ices/76510.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
struct Dummy;
2+
3+
impl Dummy {
4+
const fn func(&mut self) -> usize {
5+
42
6+
}
7+
}
8+
9+
const _: &[usize] = &[0; {
10+
const DUMMY: &Dummy = &Dummy;
11+
DUMMY.func()
12+
}];

ices/76535.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#![feature(generic_associated_types)]
2+
3+
pub trait SubTrait {}
4+
5+
pub trait SuperTrait {
6+
type SubType<'a>: SubTrait;
7+
8+
fn get_sub<'a>(&'a mut self) -> Self::SubType<'a>;
9+
}
10+
11+
pub struct SubStruct<'a> {
12+
sup: &'a mut SuperStruct,
13+
}
14+
15+
impl<'a> SubTrait for SubStruct<'a> {}
16+
17+
pub struct SuperStruct {
18+
value: u8,
19+
}
20+
21+
impl SuperStruct {
22+
pub fn new(value: u8) -> SuperStruct {
23+
SuperStruct { value }
24+
}
25+
}
26+
27+
impl SuperTrait for SuperStruct {
28+
type SubType<'a> = SubStruct<'a>;
29+
30+
fn get_sub<'a>(&'a mut self) -> Self::SubType<'a> {
31+
SubStruct { sup: self }
32+
}
33+
}
34+
35+
fn main() {
36+
let sub: Box<dyn SuperTrait<SubType = SubStruct>> = Box::new(SuperStruct::new(0));
37+
}

ices/76826.rs

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

0 commit comments

Comments
 (0)