diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:03 +0000 |
commit | 64d98f8ee037282c35007b64c2649055c56af1db (patch) | |
tree | 5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/ui/meta | |
parent | Adding debian version 1.67.1+dfsg1-1. (diff) | |
download | rustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip |
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/meta')
-rw-r--r-- | tests/ui/meta/auxiliary/env.rs | 9 | ||||
-rw-r--r-- | tests/ui/meta/expected-error-correct-rev.a.stderr | 16 | ||||
-rw-r--r-- | tests/ui/meta/expected-error-correct-rev.rs | 10 | ||||
-rw-r--r-- | tests/ui/meta/meta-expected-error-wrong-rev.a.stderr | 16 | ||||
-rw-r--r-- | tests/ui/meta/meta-expected-error-wrong-rev.rs | 16 | ||||
-rw-r--r-- | tests/ui/meta/revision-bad.rs | 22 | ||||
-rw-r--r-- | tests/ui/meta/revision-ok.rs | 21 | ||||
-rw-r--r-- | tests/ui/meta/rustc-env.rs | 18 |
8 files changed, 128 insertions, 0 deletions
diff --git a/tests/ui/meta/auxiliary/env.rs b/tests/ui/meta/auxiliary/env.rs new file mode 100644 index 000000000..b3644d8d5 --- /dev/null +++ b/tests/ui/meta/auxiliary/env.rs @@ -0,0 +1,9 @@ +// Check that aux builds can also use rustc-env, but environment is configured +// separately from the main test case. +// +// rustc-env:COMPILETEST_BAR=bar + +pub fn test() { + assert_eq!(option_env!("COMPILETEST_FOO"), None); + assert_eq!(env!("COMPILETEST_BAR"), "bar"); +} diff --git a/tests/ui/meta/expected-error-correct-rev.a.stderr b/tests/ui/meta/expected-error-correct-rev.a.stderr new file mode 100644 index 000000000..4adeebe2a --- /dev/null +++ b/tests/ui/meta/expected-error-correct-rev.a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/expected-error-correct-rev.rs:7:18 + | +LL | let x: u32 = 22_usize; + | --- ^^^^^^^^ expected `u32`, found `usize` + | | + | expected due to this + | +help: change the type of the numeric literal from `usize` to `u32` + | +LL | let x: u32 = 22_u32; + | ~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/meta/expected-error-correct-rev.rs b/tests/ui/meta/expected-error-correct-rev.rs new file mode 100644 index 000000000..26798c3df --- /dev/null +++ b/tests/ui/meta/expected-error-correct-rev.rs @@ -0,0 +1,10 @@ +// revisions: a + +// Counterpart to `expected-error-wrong-rev.rs` + +#[cfg(a)] +fn foo() { + let x: u32 = 22_usize; //[a]~ ERROR mismatched types +} + +fn main() { } diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr b/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr new file mode 100644 index 000000000..87330155e --- /dev/null +++ b/tests/ui/meta/meta-expected-error-wrong-rev.a.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/meta-expected-error-wrong-rev.rs:13:18 + | +LL | let x: u32 = 22_usize; + | --- ^^^^^^^^ expected `u32`, found `usize` + | | + | expected due to this + | +help: change the type of the numeric literal from `usize` to `u32` + | +LL | let x: u32 = 22_u32; + | ~~~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/meta/meta-expected-error-wrong-rev.rs b/tests/ui/meta/meta-expected-error-wrong-rev.rs new file mode 100644 index 000000000..c30d4fe0a --- /dev/null +++ b/tests/ui/meta/meta-expected-error-wrong-rev.rs @@ -0,0 +1,16 @@ +// ignore-compare-mode-polonius + +// revisions: a +// should-fail + +// This is a "meta-test" of the compilertest framework itself. In +// particular, it includes the right error message, but the message +// targets the wrong revision, so we expect the execution to fail. +// See also `meta-expected-error-correct-rev.rs`. + +#[cfg(a)] +fn foo() { + let x: u32 = 22_usize; //[b]~ ERROR mismatched types +} + +fn main() { } diff --git a/tests/ui/meta/revision-bad.rs b/tests/ui/meta/revision-bad.rs new file mode 100644 index 000000000..37ddbe99a --- /dev/null +++ b/tests/ui/meta/revision-bad.rs @@ -0,0 +1,22 @@ +// Meta test for compiletest: check that when we give the wrong error +// patterns, the test fails. + +// run-fail +// revisions: foo bar +// should-fail +// needs-run-enabled +//[foo] error-pattern:bar +//[bar] error-pattern:foo + +#[cfg(foo)] +fn die() { + panic!("foo"); +} +#[cfg(bar)] +fn die() { + panic!("bar"); +} + +fn main() { + die(); +} diff --git a/tests/ui/meta/revision-ok.rs b/tests/ui/meta/revision-ok.rs new file mode 100644 index 000000000..bbeae41b8 --- /dev/null +++ b/tests/ui/meta/revision-ok.rs @@ -0,0 +1,21 @@ +// Meta test for compiletest: check that when we give the right error +// patterns, the test passes. See all `revision-bad.rs`. + +// run-fail +// revisions: foo bar +//[foo] error-pattern:foo +//[bar] error-pattern:bar +// ignore-emscripten no processes + +#[cfg(foo)] +fn die() { + panic!("foo"); +} +#[cfg(bar)] +fn die() { + panic!("bar"); +} + +fn main() { + die(); +} diff --git a/tests/ui/meta/rustc-env.rs b/tests/ui/meta/rustc-env.rs new file mode 100644 index 000000000..7d4e005be --- /dev/null +++ b/tests/ui/meta/rustc-env.rs @@ -0,0 +1,18 @@ +// Compiletest meta test checking that rustc-env and unset-rustc-env directives +// can be used to configure environment for rustc. +// +// run-pass +// aux-build:env.rs +// rustc-env:COMPILETEST_FOO=foo +// +// An environment variable that is likely to be set, but should be safe to unset. +// unset-rustc-env:PWD + +extern crate env; + +fn main() { + assert_eq!(env!("COMPILETEST_FOO"), "foo"); + assert_eq!(option_env!("COMPILETEST_BAR"), None); + assert_eq!(option_env!("PWD"), None); + env::test(); +} |