Skip to content

Commit b3c022d

Browse files
committed
Add tests on fixed ICEs
Closes #29924. Closes #38857. Closes #39665. Closes #39872. Closes #39553. Closes #41210. Closes #41880. Closes #43483.
1 parent 6c06bfa commit b3c022d

7 files changed

+153
-0
lines changed

src/test/compile-fail/E0599.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
struct Foo;
12+
13+
fn main() {
14+
|| if let Foo::NotEvenReal() = Foo {}; //~ ERROR E0599
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// #29924
12+
13+
#![feature(const_fn, associated_consts)]
14+
15+
trait Trait {
16+
const N: usize;
17+
}
18+
19+
impl Trait {
20+
//~^ ERROR the trait `Trait` cannot be made into an object [E0038]
21+
const fn n() -> usize { Self::N }
22+
}
23+
24+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// #39872, #39553
12+
13+
#![feature(conservative_impl_trait)]
14+
fn will_ice(something: &u32) -> impl Iterator<Item = &u32> {
15+
//~^ ERROR the trait bound `(): std::iter::Iterator` is not satisfied [E0277]
16+
}
17+
18+
fn main() {}

src/test/compile-fail/issue-38857.rs

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {
12+
let a = std::sys::imp::process::process_common::StdioPipes { ..panic!() };
13+
//~^ ERROR failed to resolve. Could not find `imp` in `sys` [E0433]
14+
//~^^ ERROR module `sys` is private [E0603]
15+
}

src/test/compile-fail/issue-41880.rs

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn iterate<T, F>(initial: T, f: F) -> Iterate<T, F> {
12+
Iterate {
13+
state: initial,
14+
f: f,
15+
}
16+
}
17+
18+
pub struct Iterate<T, F> {
19+
state: T,
20+
f: F
21+
}
22+
23+
impl<T: Clone, F> Iterator for Iterate<T, F> where F: Fn(&T) -> T {
24+
type Item = T;
25+
26+
#[inline]
27+
fn next(&mut self) -> Option<Self::Item> {
28+
self.state = (self.f)(&self.state);
29+
Some(self.state.clone())
30+
}
31+
#[inline]
32+
fn size_hint(&self) -> (usize, Option<usize>) { (std::usize::MAX, None) }
33+
}
34+
35+
fn main() {
36+
let a = iterate(0, |x| x+1);
37+
println!("{:?}", a.iter().take(10).collect::<Vec<usize>>());
38+
//~^ ERROR no method named `iter` found for type `Iterate<{integer}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// #39665
12+
13+
#![feature(conservative_impl_trait)]
14+
15+
fn batches(n: &u32) -> impl Iterator<Item=&u32> {
16+
std::iter::once(n)
17+
}
18+
19+
fn main() {}

src/test/run-pass/issue-43483.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
trait VecN {
12+
const DIM: usize;
13+
}
14+
15+
trait Mat {
16+
type Row: VecN;
17+
}
18+
19+
fn m<M: Mat>() {
20+
let x = M::Row::DIM;
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)