diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/run-make/rust-lld-by-default-beta-stable/rmake.rs | 17 | ||||
| -rw-r--r-- | tests/run-make/rust-lld-by-default-nightly/rmake.rs | 27 | ||||
| -rw-r--r-- | tests/run-make/rust-lld-custom-target/rmake.rs | 39 | ||||
| -rw-r--r-- | tests/run-make/rust-lld/rmake.rs | 68 | ||||
| -rw-r--r-- | tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.rs | 41 | ||||
| -rw-r--r-- | tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr | 23 | ||||
| -rw-r--r-- | tests/ui/drop/nonsense-drop-impl-issue-139278.rs | 10 | ||||
| -rw-r--r-- | tests/ui/drop/nonsense-drop-impl-issue-139278.stderr | 18 | ||||
| -rw-r--r-- | tests/ui/linking/link-self-contained-consistency.many.stderr (renamed from tests/ui/linkage-attr/link-self-contained-consistency.many.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/linking/link-self-contained-consistency.one.stderr (renamed from tests/ui/linkage-attr/link-self-contained-consistency.one.stderr) | 0 | ||||
| -rw-r--r-- | tests/ui/linking/link-self-contained-consistency.rs (renamed from tests/ui/linkage-attr/link-self-contained-consistency.rs) | 0 |
11 files changed, 124 insertions, 119 deletions
diff --git a/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs b/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs index 263bb9b2e20..9a08991c4b8 100644 --- a/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs +++ b/tests/run-make/rust-lld-by-default-beta-stable/rmake.rs @@ -4,24 +4,11 @@ //@ ignore-nightly //@ only-x86_64-unknown-linux-gnu -use std::process::Output; - -use run_make_support::regex::Regex; +use run_make_support::linker::assert_rustc_doesnt_use_lld; use run_make_support::rustc; fn main() { // A regular compilation should not use rust-lld by default. We'll check that by asking the // linker to display its version number with a link-arg. - let output = rustc().arg("-Wlinker-messages").link_arg("-Wl,-v").input("main.rs").run(); - assert!( - !find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should not be present in the output logs:\n{}", - output.stderr_utf8() - ); -} - -fn find_lld_version_in_logs(stderr: String) -> bool { - let lld_version_re = - Regex::new(r"^warning: linker stdout: LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap(); - stderr.lines().any(|line| lld_version_re.is_match(line.trim())) + assert_rustc_doesnt_use_lld(rustc().input("main.rs")); } diff --git a/tests/run-make/rust-lld-by-default-nightly/rmake.rs b/tests/run-make/rust-lld-by-default-nightly/rmake.rs index 7a0a08863dd..3ff1e2770e6 100644 --- a/tests/run-make/rust-lld-by-default-nightly/rmake.rs +++ b/tests/run-make/rust-lld-by-default-nightly/rmake.rs @@ -6,35 +6,14 @@ //@ ignore-stable //@ only-x86_64-unknown-linux-gnu -use run_make_support::regex::Regex; +use run_make_support::linker::{assert_rustc_doesnt_use_lld, assert_rustc_uses_lld}; use run_make_support::rustc; fn main() { // A regular compilation should use rust-lld by default. We'll check that by asking the linker // to display its version number with a link-arg. - let output = rustc().arg("-Wlinker-messages").link_arg("-Wl,-v").input("main.rs").run(); - assert!( - find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should be present in the output logs:\n{}", - output.stderr_utf8() - ); + assert_rustc_uses_lld(rustc().input("main.rs")); // But it can still be disabled by turning the linker feature off. - let output = rustc() - .arg("-Wlinker-messages") - .link_arg("-Wl,-v") - .arg("-Zlinker-features=-lld") - .input("main.rs") - .run(); - assert!( - !find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should not be present in the output logs:\n{}", - output.stderr_utf8() - ); -} - -fn find_lld_version_in_logs(stderr: String) -> bool { - let lld_version_re = - Regex::new(r"^warning: linker stdout: LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap(); - stderr.lines().any(|line| lld_version_re.is_match(line.trim())) + assert_rustc_doesnt_use_lld(rustc().arg("-Zlinker-features=-lld").input("main.rs")); } diff --git a/tests/run-make/rust-lld-custom-target/rmake.rs b/tests/run-make/rust-lld-custom-target/rmake.rs index 993a248ad00..e2b065a10b1 100644 --- a/tests/run-make/rust-lld-custom-target/rmake.rs +++ b/tests/run-make/rust-lld-custom-target/rmake.rs @@ -8,43 +8,22 @@ //@ needs-rust-lld //@ only-x86_64-unknown-linux-gnu -use run_make_support::regex::Regex; +use run_make_support::linker::{assert_rustc_doesnt_use_lld, assert_rustc_uses_lld}; use run_make_support::rustc; fn main() { // Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking // the linker to display its version number with a link-arg. - let output = rustc() - .crate_type("cdylib") - .arg("-Wlinker-messages") - .target("custom-target.json") - .link_arg("-Wl,-v") - .input("lib.rs") - .run(); - assert!( - find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should be present in the output logs:\n{}", - output.stderr_utf8() + assert_rustc_uses_lld( + rustc().crate_type("cdylib").target("custom-target.json").input("lib.rs"), ); // But it can also be disabled via linker features. - let output = rustc() - .crate_type("cdylib") - .arg("-Wlinker-messages") - .target("custom-target.json") - .arg("-Zlinker-features=-lld") - .link_arg("-Wl,-v") - .input("lib.rs") - .run(); - assert!( - !find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should not be present in the output logs:\n{}", - output.stderr_utf8() + assert_rustc_doesnt_use_lld( + rustc() + .crate_type("cdylib") + .target("custom-target.json") + .arg("-Zlinker-features=-lld") + .input("lib.rs"), ); } - -fn find_lld_version_in_logs(stderr: String) -> bool { - let lld_version_re = - Regex::new(r"^warning: linker stdout: LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap(); - stderr.lines().any(|line| lld_version_re.is_match(line.trim())) -} diff --git a/tests/run-make/rust-lld/rmake.rs b/tests/run-make/rust-lld/rmake.rs index 35f716c24c7..9470f5d0be1 100644 --- a/tests/run-make/rust-lld/rmake.rs +++ b/tests/run-make/rust-lld/rmake.rs @@ -4,64 +4,32 @@ //@ needs-rust-lld //@ ignore-s390x lld does not yet support s390x as target -use run_make_support::regex::Regex; -use run_make_support::{is_msvc, rustc}; +use run_make_support::linker::{assert_rustc_doesnt_use_lld, assert_rustc_uses_lld}; +use run_make_support::rustc; fn main() { - // lld-link is used if msvc, otherwise a gnu-compatible lld is used. - let linker_version_flag = if is_msvc() { "--version" } else { "-Wl,-v" }; - // Opt-in to lld and the self-contained linker, to link with rust-lld. We'll check that by // asking the linker to display its version number with a link-arg. - let output = rustc() - .arg("-Zlinker-features=+lld") - .arg("-Clink-self-contained=+linker") - .arg("-Zunstable-options") - .arg("-Wlinker-messages") - .link_arg(linker_version_flag) - .input("main.rs") - .run(); - assert!( - find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should be present in the output logs:\n{}", - output.stderr_utf8() + assert_rustc_uses_lld( + rustc() + .arg("-Zlinker-features=+lld") + .arg("-Clink-self-contained=+linker") + .arg("-Zunstable-options") + .input("main.rs"), ); - // It should not be used when we explicitly opt-out of lld. - let output = rustc() - .link_arg(linker_version_flag) - .arg("-Zlinker-features=-lld") - .arg("-Wlinker-messages") - .input("main.rs") - .run(); - assert!( - !find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should not be present in the output logs:\n{}", - output.stderr_utf8() - ); + // It should not be used when we explicitly opt out of lld. + assert_rustc_doesnt_use_lld(rustc().arg("-Zlinker-features=-lld").input("main.rs")); // While we're here, also check that the last linker feature flag "wins" when passed multiple // times to rustc. - let output = rustc() - .link_arg(linker_version_flag) - .arg("-Clink-self-contained=+linker") - .arg("-Zunstable-options") - .arg("-Zlinker-features=-lld") - .arg("-Zlinker-features=+lld") - .arg("-Zlinker-features=-lld,+lld") - .arg("-Wlinker-messages") - .input("main.rs") - .run(); - assert!( - find_lld_version_in_logs(output.stderr_utf8()), - "the LLD version string should be present in the output logs:\n{}", - output.stderr_utf8() + assert_rustc_uses_lld( + rustc() + .arg("-Clink-self-contained=+linker") + .arg("-Zunstable-options") + .arg("-Zlinker-features=-lld") + .arg("-Zlinker-features=+lld") + .arg("-Zlinker-features=-lld,+lld") + .input("main.rs"), ); } - -fn find_lld_version_in_logs(stderr: String) -> bool { - // Strip the `-Wlinker-messages` wrappers prefixing the linker output. - let stderr = Regex::new(r"warning: linker std(out|err):").unwrap().replace_all(&stderr, ""); - let lld_version_re = Regex::new(r"^LLD [0-9]+\.[0-9]+\.[0-9]+").unwrap(); - stderr.lines().any(|line| lld_version_re.is_match(line.trim())) -} diff --git a/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.rs b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.rs new file mode 100644 index 00000000000..231bb5252de --- /dev/null +++ b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.rs @@ -0,0 +1,41 @@ +// compile-flags: -Znext-solver + +// Test for a weird diagnostics corner case. In the error reporting code, when reporting +// fulfillment errors for goals A and B, we try to see if elaborating A will result in +// another goal that can equate with B. That would signal that B is "implied by" A, +// allowing us to skip reporting it, which is beneficial for cutting down on the number +// of diagnostics we report. In the new trait solver especially, but even in the old trait +// solver through things like defining opaque type usages, this `can_equate` call was not +// properly taking the param-env of the goals, resulting in nested obligations that had +// empty param-envs. If one of these nested obligations was a `ConstParamHasTy` goal, then +// we would ICE, since those goals are particularly strict about the param-env they're +// evaluated in. + +// This is morally a fix for <https://github.com/rust-lang/rust/issues/139314>, but that +// repro uses details about how defining usages in the `check_opaque_well_formed` code +// can spring out of type equality, and will likely stop failing soon coincidentally once +// we start using `PostBorrowck` mode in that check. + +trait Foo: Baz<()> {} +trait Baz<T> {} + +trait IdentityWithConstArgGoal<const N: usize> { + type Assoc; +} +impl<T, const N: usize> IdentityWithConstArgGoal<N> for T { + type Assoc = T; +} + +fn unsatisfied<T, const N: usize>() +where + T: Foo, + T: Baz<<T as IdentityWithConstArgGoal<N>>::Assoc>, +{ +} + +fn test<const N: usize>() { + unsatisfied::<(), N>(); + //~^ ERROR the trait bound `(): Foo` is not satisfied +} + +fn main() {} diff --git a/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr new file mode 100644 index 00000000000..77bba494552 --- /dev/null +++ b/tests/ui/const-generics/const-param-has-ty-goal-in-error-implies.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `(): Foo` is not satisfied + --> $DIR/const-param-has-ty-goal-in-error-implies.rs:37:19 + | +LL | unsatisfied::<(), N>(); + | ^^ the trait `Foo` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/const-param-has-ty-goal-in-error-implies.rs:19:1 + | +LL | trait Foo: Baz<()> {} + | ^^^^^^^^^^^^^^^^^^ +note: required by a bound in `unsatisfied` + --> $DIR/const-param-has-ty-goal-in-error-implies.rs:31:8 + | +LL | fn unsatisfied<T, const N: usize>() + | ----------- required by a bound in this function +LL | where +LL | T: Foo, + | ^^^ required by this bound in `unsatisfied` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/drop/nonsense-drop-impl-issue-139278.rs b/tests/ui/drop/nonsense-drop-impl-issue-139278.rs new file mode 100644 index 00000000000..86f4e4d8607 --- /dev/null +++ b/tests/ui/drop/nonsense-drop-impl-issue-139278.rs @@ -0,0 +1,10 @@ +//@ check-fail +struct Foo; + +impl Drop for Foo { //~ ERROR: not all trait items implemented + const SPLOK: u32 = 0; //~ ERROR: not a member of trait +} + +const X: Foo = Foo; + +fn main() {} diff --git a/tests/ui/drop/nonsense-drop-impl-issue-139278.stderr b/tests/ui/drop/nonsense-drop-impl-issue-139278.stderr new file mode 100644 index 00000000000..825e883fa6d --- /dev/null +++ b/tests/ui/drop/nonsense-drop-impl-issue-139278.stderr @@ -0,0 +1,18 @@ +error[E0438]: const `SPLOK` is not a member of trait `Drop` + --> $DIR/nonsense-drop-impl-issue-139278.rs:5:5 + | +LL | const SPLOK: u32 = 0; + | ^^^^^^^^^^^^^^^^^^^^^ not a member of trait `Drop` + +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/nonsense-drop-impl-issue-139278.rs:4:1 + | +LL | impl Drop for Foo { + | ^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `fn drop(&mut self) { todo!() }` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0046, E0438. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/linkage-attr/link-self-contained-consistency.many.stderr b/tests/ui/linking/link-self-contained-consistency.many.stderr index a5fc96b4e0b..a5fc96b4e0b 100644 --- a/tests/ui/linkage-attr/link-self-contained-consistency.many.stderr +++ b/tests/ui/linking/link-self-contained-consistency.many.stderr diff --git a/tests/ui/linkage-attr/link-self-contained-consistency.one.stderr b/tests/ui/linking/link-self-contained-consistency.one.stderr index 5982b7a618e..5982b7a618e 100644 --- a/tests/ui/linkage-attr/link-self-contained-consistency.one.stderr +++ b/tests/ui/linking/link-self-contained-consistency.one.stderr diff --git a/tests/ui/linkage-attr/link-self-contained-consistency.rs b/tests/ui/linking/link-self-contained-consistency.rs index 08227433891..08227433891 100644 --- a/tests/ui/linkage-attr/link-self-contained-consistency.rs +++ b/tests/ui/linking/link-self-contained-consistency.rs |
