forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add type of a let tait test impl trait straight in let
- Loading branch information
1 parent
08e20d9
commit dbadab5
Showing
2 changed files
with
46 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,25 @@ | ||
#![feature(type_alias_impl_trait)] | ||
#![allow(dead_code)] | ||
|
||
// FIXME This should be under a feature flag | ||
|
||
use std::fmt::Debug; | ||
|
||
fn foo1() -> u32 { | ||
let x: impl Debug = 22_u32; | ||
//~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] | ||
x // ERROR: we only know x: Debug, we don't know x = u32 | ||
} | ||
|
||
fn foo2() -> u32 { | ||
let x: impl Debug = 22_u32; | ||
//~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] | ||
let y: impl Debug = x; | ||
//~^ ERROR: `impl Trait` not allowed outside of function and method return types [E0562] | ||
same_type((x, y)); // ERROR | ||
x | ||
} | ||
|
||
fn same_type<T>(x: (T, T)) {} | ||
|
||
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,21 @@ | ||
error[E0562]: `impl Trait` not allowed outside of function and method return types | ||
--> $DIR/type_of_a_let2.rs:9:12 | ||
| | ||
LL | let x: impl Debug = 22_u32; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0562]: `impl Trait` not allowed outside of function and method return types | ||
--> $DIR/type_of_a_let2.rs:15:12 | ||
| | ||
LL | let x: impl Debug = 22_u32; | ||
| ^^^^^^^^^^ | ||
|
||
error[E0562]: `impl Trait` not allowed outside of function and method return types | ||
--> $DIR/type_of_a_let2.rs:17:12 | ||
| | ||
LL | let y: impl Debug = x; | ||
| ^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0562`. |