-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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 #106557 - Ezrashaw:ui-test-fixups-1, r=GuillaumeGomez
Add some UI tests and reword error-code docs Added UI tests for `E0013` and `E0015`. Error code docs for `E0015` were a bit unclear (they referred to all non-const errors in const context, when only non-const functions applied), so I touched them up a bit. I also fixed up some issues in the new `error_codes.rs` tidy check (linked #106341), that I overlooked previously. r? ``@GuillaumeGomez``
- Loading branch information
Showing
6 changed files
with
57 additions
and
27 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
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 @@ | ||
static X: i32 = 42; | ||
const Y: i32 = X; //~ ERROR constants cannot refer to statics [E0013] | ||
|
||
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,11 @@ | ||
error[E0013]: constants cannot refer to statics | ||
--> $DIR/E0013.rs:2:16 | ||
| | ||
LL | const Y: i32 = X; | ||
| ^ | ||
| | ||
= help: consider extracting the value of the `static` to a `const`, and referring to that | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0013`. |
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 @@ | ||
fn create_some() -> Option<u8> { | ||
Some(1) | ||
} | ||
|
||
const FOO: Option<u8> = create_some(); | ||
//~^ ERROR cannot call non-const fn `create_some` in constants [E0015] | ||
|
||
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,11 @@ | ||
error[E0015]: cannot call non-const fn `create_some` in constants | ||
--> $DIR/E0015.rs:5:25 | ||
| | ||
LL | const FOO: Option<u8> = create_some(); | ||
| ^^^^^^^^^^^^^ | ||
| | ||
= note: calls in constants are limited to constant functions, tuple structs and tuple variants | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0015`. |
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