Move E0562 to librustc from librustc_typeck
With the check for impl trait moving from type checking to HIR lowering the error needs to move too.
This commit is contained in:
parent
88a28ff602
commit
779fc372c7
@ -1770,6 +1770,46 @@ If you want to get command-line arguments, use `std::env::args`. To exit with a
|
||||
specified exit code, use `std::process::exit`.
|
||||
"##,
|
||||
|
||||
E0562: r##"
|
||||
Abstract return types (written `impl Trait` for some trait `Trait`) are only
|
||||
allowed as function return types.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0562
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
fn main() {
|
||||
let count_to_ten: impl Iterator<Item=usize> = 0..10;
|
||||
// error: `impl Trait` not allowed outside of function and inherent method
|
||||
// return types
|
||||
for i in count_to_ten {
|
||||
println!("{}", i);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Make sure `impl Trait` only appears in return-type position.
|
||||
|
||||
```
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
|
||||
0..n
|
||||
}
|
||||
|
||||
fn main() {
|
||||
for i in count_to_n(10) { // ok!
|
||||
println!("{}", i);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See [RFC 1522] for more details.
|
||||
|
||||
[RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
|
||||
"##,
|
||||
|
||||
E0591: r##"
|
||||
Per [RFC 401][rfc401], if you have a function declaration `foo`:
|
||||
|
||||
|
@ -3818,46 +3818,6 @@ let s = Simba { mother: 1, father: 0 }; // ok!
|
||||
```
|
||||
"##,
|
||||
|
||||
E0562: r##"
|
||||
Abstract return types (written `impl Trait` for some trait `Trait`) are only
|
||||
allowed as function return types.
|
||||
|
||||
Erroneous code example:
|
||||
|
||||
```compile_fail,E0562
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
fn main() {
|
||||
let count_to_ten: impl Iterator<Item=usize> = 0..10;
|
||||
// error: `impl Trait` not allowed outside of function and inherent method
|
||||
// return types
|
||||
for i in count_to_ten {
|
||||
println!("{}", i);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Make sure `impl Trait` only appears in return-type position.
|
||||
|
||||
```
|
||||
#![feature(conservative_impl_trait)]
|
||||
|
||||
fn count_to_n(n: usize) -> impl Iterator<Item=usize> {
|
||||
0..n
|
||||
}
|
||||
|
||||
fn main() {
|
||||
for i in count_to_n(10) { // ok!
|
||||
println!("{}", i);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See [RFC 1522] for more details.
|
||||
|
||||
[RFC 1522]: https://github.com/rust-lang/rfcs/blob/master/text/1522-conservative-impl-trait.md
|
||||
"##,
|
||||
|
||||
E0569: r##"
|
||||
If an impl has a generic parameter with the `#[may_dangle]` attribute, then
|
||||
that impl must be declared as an `unsafe impl.
|
||||
|
Loading…
Reference in New Issue
Block a user