Rollup merge of #87383 - Alexendoo:impl_trait_in_bindings-tests, r=oli-obk
Add regression tests for the impl_trait_in_bindings ICEs Closes #54600, closes #54840, closes #58504, closes #58956, closes #70971, closes #79099, closes #84919, closes #86201, closes #86642, closes #87295 r? ``@oli-obk``
This commit is contained in:
commit
7c0c329635
20 changed files with 221 additions and 0 deletions
7
src/test/ui/impl-trait/issues/issue-54600.rs
Normal file
7
src/test/ui/impl-trait/issues/issue-54600.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use std::fmt::Debug;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let x: Option<impl Debug> = Some(44_u32);
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
println!("{:?}", x);
|
||||||
|
}
|
9
src/test/ui/impl-trait/issues/issue-54600.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-54600.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-54600.rs:4:19
|
||||||
|
|
|
||||||
|
LL | let x: Option<impl Debug> = Some(44_u32);
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
7
src/test/ui/impl-trait/issues/issue-54840.rs
Normal file
7
src/test/ui/impl-trait/issues/issue-54840.rs
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
use std::ops::Add;
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let i: i32 = 0;
|
||||||
|
let j: &impl Add = &i;
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
}
|
9
src/test/ui/impl-trait/issues/issue-54840.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-54840.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-54840.rs:5:13
|
||||||
|
|
|
||||||
|
LL | let j: &impl Add = &i;
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
12
src/test/ui/impl-trait/issues/issue-58504.rs
Normal file
12
src/test/ui/impl-trait/issues/issue-58504.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
#![feature(generators, generator_trait, never_type)]
|
||||||
|
|
||||||
|
use std::ops::Generator;
|
||||||
|
|
||||||
|
fn mk_gen() -> impl Generator<Return=!, Yield=()> {
|
||||||
|
|| { loop { yield; } }
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
}
|
9
src/test/ui/impl-trait/issues/issue-58504.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-58504.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-58504.rs:10:16
|
||||||
|
|
|
||||||
|
LL | let gens: [impl Generator<Return=!, Yield=()>;2] = [ mk_gen(), mk_gen() ];
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
14
src/test/ui/impl-trait/issues/issue-58956.rs
Normal file
14
src/test/ui/impl-trait/issues/issue-58956.rs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
trait Lam {}
|
||||||
|
|
||||||
|
pub struct B;
|
||||||
|
impl Lam for B {}
|
||||||
|
pub struct Wrap<T>(T);
|
||||||
|
|
||||||
|
const _A: impl Lam = {
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
let x: Wrap<impl Lam> = Wrap(B);
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
x.0
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() {}
|
15
src/test/ui/impl-trait/issues/issue-58956.stderr
Normal file
15
src/test/ui/impl-trait/issues/issue-58956.stderr
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-58956.rs:7:11
|
||||||
|
|
|
||||||
|
LL | const _A: impl Lam = {
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-58956.rs:9:17
|
||||||
|
|
|
||||||
|
LL | let x: Wrap<impl Lam> = Wrap(B);
|
||||||
|
| ^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
4
src/test/ui/impl-trait/issues/issue-70971.rs
Normal file
4
src/test/ui/impl-trait/issues/issue-70971.rs
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
fn main() {
|
||||||
|
let x : (impl Copy,) = (true,);
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
}
|
9
src/test/ui/impl-trait/issues/issue-70971.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-70971.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-70971.rs:2:14
|
||||||
|
|
|
||||||
|
LL | let x : (impl Copy,) = (true,);
|
||||||
|
| ^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
10
src/test/ui/impl-trait/issues/issue-79099.rs
Normal file
10
src/test/ui/impl-trait/issues/issue-79099.rs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
struct Bug {
|
||||||
|
V1: [(); {
|
||||||
|
let f: impl core::future::Future<Output = u8> = async { 1 };
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
//~| expected identifier
|
||||||
|
1
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
20
src/test/ui/impl-trait/issues/issue-79099.stderr
Normal file
20
src/test/ui/impl-trait/issues/issue-79099.stderr
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
error: expected identifier, found `1`
|
||||||
|
--> $DIR/issue-79099.rs:3:65
|
||||||
|
|
|
||||||
|
LL | let f: impl core::future::Future<Output = u8> = async { 1 };
|
||||||
|
| ----- ^ expected identifier
|
||||||
|
| |
|
||||||
|
| `async` blocks are only allowed in Rust 2018 or later
|
||||||
|
|
|
||||||
|
= help: set `edition = "2018"` in `Cargo.toml`
|
||||||
|
= note: for more on editions, read https://doc.rust-lang.org/edition-guide
|
||||||
|
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-79099.rs:3:16
|
||||||
|
|
|
||||||
|
LL | let f: impl core::future::Future<Output = u8> = async { 1 };
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
9
src/test/ui/impl-trait/issues/issue-84919.rs
Normal file
9
src/test/ui/impl-trait/issues/issue-84919.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
trait Trait {}
|
||||||
|
impl Trait for () {}
|
||||||
|
|
||||||
|
fn foo<'a: 'a>() {
|
||||||
|
let _x: impl Trait = ();
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
9
src/test/ui/impl-trait/issues/issue-84919.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-84919.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-84919.rs:5:13
|
||||||
|
|
|
||||||
|
LL | let _x: impl Trait = ();
|
||||||
|
| ^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
13
src/test/ui/impl-trait/issues/issue-86201.rs
Normal file
13
src/test/ui/impl-trait/issues/issue-86201.rs
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#![feature(unboxed_closures)]
|
||||||
|
#![feature(min_type_alias_impl_trait)]
|
||||||
|
|
||||||
|
type FunType = impl Fn<()>;
|
||||||
|
//~^ could not find defining uses
|
||||||
|
static STATIC_FN: FunType = some_fn;
|
||||||
|
//~^ mismatched types
|
||||||
|
|
||||||
|
fn some_fn() {}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _: <FunType as FnOnce<()>>::Output = STATIC_FN();
|
||||||
|
}
|
21
src/test/ui/impl-trait/issues/issue-86201.stderr
Normal file
21
src/test/ui/impl-trait/issues/issue-86201.stderr
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
error[E0308]: mismatched types
|
||||||
|
--> $DIR/issue-86201.rs:6:29
|
||||||
|
|
|
||||||
|
LL | type FunType = impl Fn<()>;
|
||||||
|
| ----------- the expected opaque type
|
||||||
|
LL |
|
||||||
|
LL | static STATIC_FN: FunType = some_fn;
|
||||||
|
| ^^^^^^^ expected opaque type, found fn item
|
||||||
|
|
|
||||||
|
= note: expected opaque type `impl Fn<()>`
|
||||||
|
found fn item `fn() {some_fn}`
|
||||||
|
|
||||||
|
error: could not find defining uses
|
||||||
|
--> $DIR/issue-86201.rs:4:16
|
||||||
|
|
|
||||||
|
LL | type FunType = impl Fn<()>;
|
||||||
|
| ^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0308`.
|
8
src/test/ui/impl-trait/issues/issue-86642.rs
Normal file
8
src/test/ui/impl-trait/issues/issue-86642.rs
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
static x: impl Fn(&str) -> Result<&str, ()> = move |source| {
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
let res = (move |source| Ok(source))(source);
|
||||||
|
let res = res.or((move |source| Ok(source))(source));
|
||||||
|
res
|
||||||
|
};
|
||||||
|
|
||||||
|
fn main() {}
|
9
src/test/ui/impl-trait/issues/issue-86642.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-86642.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-86642.rs:1:11
|
||||||
|
|
|
||||||
|
LL | static x: impl Fn(&str) -> Result<&str, ()> = move |source| {
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
18
src/test/ui/impl-trait/issues/issue-87295.rs
Normal file
18
src/test/ui/impl-trait/issues/issue-87295.rs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
trait Trait {
|
||||||
|
type Output;
|
||||||
|
}
|
||||||
|
impl Trait for () {
|
||||||
|
type Output = i32;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Struct<F>(F);
|
||||||
|
impl<F> Struct<F> {
|
||||||
|
pub fn new(_: F) -> Self {
|
||||||
|
todo!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
|
||||||
|
//~^ `impl Trait` not allowed outside of function and method return types
|
||||||
|
}
|
9
src/test/ui/impl-trait/issues/issue-87295.stderr
Normal file
9
src/test/ui/impl-trait/issues/issue-87295.stderr
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
error[E0562]: `impl Trait` not allowed outside of function and method return types
|
||||||
|
--> $DIR/issue-87295.rs:16:31
|
||||||
|
|
|
||||||
|
LL | let _do_not_waste: Struct<impl Trait<Output = i32>> = Struct::new(());
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
error: aborting due to previous error
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0562`.
|
Loading…
Reference in a new issue