Auto merge of #43726 - zackmdavis:extended_information_summer_block_party, r=GuillaumeGomez
E05XX odyssey chipping away at the surface exposed by #43709 r? @GuillaumeGomez
This commit is contained in:
commit
b2bf1639ac
@ -223,6 +223,40 @@ To fix this, add a label specifying which loop is being broken out of:
|
|||||||
```
|
```
|
||||||
'foo: while break 'foo {}
|
'foo: while break 'foo {}
|
||||||
```
|
```
|
||||||
|
"##,
|
||||||
|
|
||||||
|
E0571: r##"
|
||||||
|
A `break` statement with an argument appeared in a non-`loop` loop.
|
||||||
|
|
||||||
|
Example of erroneous code:
|
||||||
|
|
||||||
|
```compile_fail,E0571
|
||||||
|
# let mut i = 1;
|
||||||
|
# fn satisfied(n: usize) -> bool { n % 23 == 0 }
|
||||||
|
let result = while true {
|
||||||
|
if satisfied(i) {
|
||||||
|
break 2*i; // error: `break` with value from a `while` loop
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
The `break` statement can take an argument (which will be the value of the loop
|
||||||
|
expression if the `break` statement is executed) in `loop` loops, but not
|
||||||
|
`for`, `while`, or `while let` loops.
|
||||||
|
|
||||||
|
Make sure `break value;` statements only occur in `loop` loops:
|
||||||
|
|
||||||
|
```
|
||||||
|
# let mut i = 1;
|
||||||
|
# fn satisfied(n: usize) -> bool { n % 23 == 0 }
|
||||||
|
let result = loop { // ok!
|
||||||
|
if satisfied(i) {
|
||||||
|
break 2*i;
|
||||||
|
}
|
||||||
|
i += 1;
|
||||||
|
};
|
||||||
|
```
|
||||||
"##
|
"##
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,5 +264,4 @@ register_diagnostics! {
|
|||||||
E0226, // only a single explicit lifetime bound is permitted
|
E0226, // only a single explicit lifetime bound is permitted
|
||||||
E0472, // asm! is unsupported on this target
|
E0472, // asm! is unsupported on this target
|
||||||
E0561, // patterns aren't allowed in function pointer types
|
E0561, // patterns aren't allowed in function pointer types
|
||||||
E0571, // `break` with a value in a non-`loop`-loop
|
|
||||||
}
|
}
|
||||||
|
@ -162,6 +162,63 @@ For more information about the cfg attribute, read:
|
|||||||
https://doc.rust-lang.org/reference.html#conditional-compilation
|
https://doc.rust-lang.org/reference.html#conditional-compilation
|
||||||
"##,
|
"##,
|
||||||
|
|
||||||
|
E0552: r##"
|
||||||
|
A unrecognized representation attribute was used.
|
||||||
|
|
||||||
|
Erroneous code example:
|
||||||
|
|
||||||
|
```compile_fail,E0552
|
||||||
|
#[repr(D)] // error: unrecognized representation hint
|
||||||
|
struct MyStruct {
|
||||||
|
my_field: usize
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use a `repr` attribute to tell the compiler how you want a struct or
|
||||||
|
enum to be laid out in memory.
|
||||||
|
|
||||||
|
Make sure you're using one of the supported options:
|
||||||
|
|
||||||
|
```
|
||||||
|
#[repr(C)] // ok!
|
||||||
|
struct MyStruct {
|
||||||
|
my_field: usize
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information about specifying representations, see the ["Alternative
|
||||||
|
Representations" section] of the Rustonomicon.
|
||||||
|
|
||||||
|
["Alternative Representations" section]: https://doc.rust-lang.org/nomicon/other-reprs.html
|
||||||
|
"##,
|
||||||
|
|
||||||
|
E0554: r##"
|
||||||
|
Feature attributes are only allowed on the nightly release channel. Stable or
|
||||||
|
beta compilers will not comply.
|
||||||
|
|
||||||
|
Example of erroneous code (on a stable compiler):
|
||||||
|
|
||||||
|
```ignore (depends on release channel)
|
||||||
|
#![feature(non_ascii_idents)] // error: #![feature] may not be used on the
|
||||||
|
// stable release channel
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need the feature, make sure to use a nightly release of the compiler
|
||||||
|
(but be warned that the feature may be removed or altered in the future).
|
||||||
|
"##,
|
||||||
|
|
||||||
|
E0557: r##"
|
||||||
|
A feature attribute named a feature that has been removed.
|
||||||
|
|
||||||
|
Erroneous code example:
|
||||||
|
|
||||||
|
```compile_fail,E0557
|
||||||
|
#![feature(managed_boxes)] // error: feature has been removed
|
||||||
|
```
|
||||||
|
|
||||||
|
Delete the offending feature attribute.
|
||||||
|
"##,
|
||||||
|
|
||||||
E0558: r##"
|
E0558: r##"
|
||||||
The `export_name` attribute was malformed.
|
The `export_name` attribute was malformed.
|
||||||
|
|
||||||
@ -300,11 +357,8 @@ register_diagnostics! {
|
|||||||
E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
|
E0549, // rustc_deprecated attribute must be paired with either stable or unstable attribute
|
||||||
E0550, // multiple deprecated attributes
|
E0550, // multiple deprecated attributes
|
||||||
E0551, // incorrect meta item
|
E0551, // incorrect meta item
|
||||||
E0552, // unrecognized representation hint
|
|
||||||
E0554, // #[feature] may not be used on the [] release channel
|
|
||||||
E0555, // malformed feature attribute, expected #![feature(...)]
|
E0555, // malformed feature attribute, expected #![feature(...)]
|
||||||
E0556, // malformed feature, expected just one word
|
E0556, // malformed feature, expected just one word
|
||||||
E0557, // feature has been removed
|
|
||||||
E0584, // file for module `..` found at both .. and ..
|
E0584, // file for module `..` found at both .. and ..
|
||||||
E0589, // invalid `repr(align)` attribute
|
E0589, // invalid `repr(align)` attribute
|
||||||
}
|
}
|
||||||
|
@ -1602,7 +1602,7 @@ fn maybe_stage_features(span_handler: &Handler, krate: &ast::Crate,
|
|||||||
if attr.check_name("feature") {
|
if attr.check_name("feature") {
|
||||||
let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)");
|
let release_channel = option_env!("CFG_RELEASE_CHANNEL").unwrap_or("(unknown)");
|
||||||
span_err!(span_handler, attr.span, E0554,
|
span_err!(span_handler, attr.span, E0554,
|
||||||
"#[feature] may not be used on the {} release channel",
|
"#![feature] may not be used on the {} release channel",
|
||||||
release_channel);
|
release_channel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user