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

Commit 470d378

Browse files
committed
Add regression tests for the impl_trait_in_bindings ICEs
1 parent 1158367 commit 470d378

20 files changed

+221
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::fmt::Debug;
2+
3+
fn main() {
4+
let x: Option<impl Debug> = Some(44_u32);
5+
//~^ `impl Trait` not allowed outside of function and method return types
6+
println!("{:?}", x);
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0562]: `impl Trait` not allowed outside of function and method return types
2+
--> $DIR/issue-54600.rs:4:19
3+
|
4+
LL | let x: Option<impl Debug> = Some(44_u32);
5+
| ^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0562`.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use std::ops::Add;
2+
3+
fn main() {
4+
let i: i32 = 0;
5+
let j: &impl Add = &i;
6+
//~^ `impl Trait` not allowed outside of function and method return types
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0562]: `impl Trait` not allowed outside of function and method return types
2+
--> $DIR/issue-54840.rs:5:13
3+
|
4+
LL | let j: &impl Add = &i;
5+
| ^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0562`.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#![feature(generators, generator_trait, never_type)]
2+
3+
use std::ops::Generator;
4+
5+
fn mk_gen() -> impl Generator<Return=!, Yield=()> {
6+
|| { loop { yield; } }
7+
}
8+
9+
fn main() {
10+
let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
11+
//~^ `impl Trait` not allowed outside of function and method return types
12+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0562]: `impl Trait` not allowed outside of function and method return types
2+
--> $DIR/issue-58504.rs:10:16
3+
|
4+
LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0562`.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
trait Lam {}
2+
3+
pub struct B;
4+
impl Lam for B {}
5+
pub struct Wrap<T>(T);
6+
7+
const _A: impl Lam = {
8+
//~^ `impl Trait` not allowed outside of function and method return types
9+
let x: Wrap<impl Lam> = Wrap(B);
10+
//~^ `impl Trait` not allowed outside of function and method return types
11+
x.0
12+
};
13+
14+
fn main() {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0562]: `impl Trait` not allowed outside of function and method return types
2+
--> $DIR/issue-58956.rs:7:11
3+
|
4+
LL | const _A: impl Lam = {
5+
| ^^^^^^^^
6+
7+
error[E0562]: `impl Trait` not allowed outside of function and method return types
8+
--> $DIR/issue-58956.rs:9:17
9+
|
10+
LL | let x: Wrap<impl Lam> = Wrap(B);
11+
| ^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0562`.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn main() {
2+
let x : (impl Copy,) = (true,);
3+
//~^ `impl Trait` not allowed outside of function and method return types
4+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0562]: `impl Trait` not allowed outside of function and method return types
2+
--> $DIR/issue-70971.rs:2:14
3+
|
4+
LL | let x : (impl Copy,) = (true,);
5+
| ^^^^^^^^^
6+
7+
error: aborting due to previous error
8+
9+
For more information about this error, try `rustc --explain E0562`.

0 commit comments

Comments
 (0)