-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #87383 - Alexendoo:impl_trait_in_bindings-tests, r=ol…
…i-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`
- Loading branch information
Showing
20 changed files
with
221 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
let x : (impl Copy,) = (true,); | ||
//~^ `impl Trait` not allowed outside of function and method return types | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |