diff options
| author | Yuki Okushi <huyuumi.dev+love@gmail.com> | 2023-01-08 17:01:48 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-08 17:01:48 +0900 |
| commit | 3b5afa590bec0652eabc4d97c967cd9f26a6ef5e (patch) | |
| tree | 990ce8265a5e8ee4e96e93b311afc7e157d56456 /src/test/ui/error-codes | |
| parent | 7997ff6612c1beadb74edd54f772c97147e14b96 (diff) | |
| parent | ae61c250cd6124d0ec5095acb3be64b633268ab3 (diff) | |
| download | rust-3b5afa590bec0652eabc4d97c967cd9f26a6ef5e.tar.gz rust-3b5afa590bec0652eabc4d97c967cd9f26a6ef5e.zip | |
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``
Diffstat (limited to 'src/test/ui/error-codes')
| -rw-r--r-- | src/test/ui/error-codes/E0013.rs | 4 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0013.stderr | 11 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0015.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/error-codes/E0015.stderr | 11 |
4 files changed, 34 insertions, 0 deletions
diff --git a/src/test/ui/error-codes/E0013.rs b/src/test/ui/error-codes/E0013.rs new file mode 100644 index 00000000000..9b3982a785b --- /dev/null +++ b/src/test/ui/error-codes/E0013.rs @@ -0,0 +1,4 @@ +static X: i32 = 42; +const Y: i32 = X; //~ ERROR constants cannot refer to statics [E0013] + +fn main() {} diff --git a/src/test/ui/error-codes/E0013.stderr b/src/test/ui/error-codes/E0013.stderr new file mode 100644 index 00000000000..dc22053a638 --- /dev/null +++ b/src/test/ui/error-codes/E0013.stderr @@ -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`. diff --git a/src/test/ui/error-codes/E0015.rs b/src/test/ui/error-codes/E0015.rs new file mode 100644 index 00000000000..b0211358d81 --- /dev/null +++ b/src/test/ui/error-codes/E0015.rs @@ -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() {} diff --git a/src/test/ui/error-codes/E0015.stderr b/src/test/ui/error-codes/E0015.stderr new file mode 100644 index 00000000000..ec1ce47b2ce --- /dev/null +++ b/src/test/ui/error-codes/E0015.stderr @@ -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`. |
