diff options
| author | Ezra Shaw <ezrasure@outlook.com> | 2023-01-07 18:37:40 +1300 |
|---|---|---|
| committer | Ezra Shaw <ezrasure@outlook.com> | 2023-01-08 13:33:09 +1300 |
| commit | ae61c250cd6124d0ec5095acb3be64b633268ab3 (patch) | |
| tree | ffa2f37dc44d8acc25f8b3596699aca5ff95c29c /src/test | |
| parent | 09382db78b293a649115fbd3d5bc79aaaf7b8deb (diff) | |
| download | rust-ae61c250cd6124d0ec5095acb3be64b633268ab3.tar.gz rust-ae61c250cd6124d0ec5095acb3be64b633268ab3.zip | |
doc/test: add UI test and reword docs for `E0013` and `E0015`
Diffstat (limited to 'src/test')
| -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`. |
