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:
Christopher Vittal 2017-11-10 12:09:40 -05:00
parent 88a28ff602
commit 779fc372c7
2 changed files with 40 additions and 40 deletions

View File

@ -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`:

View File

@ -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.