diff options
| author | bors <bors@rust-lang.org> | 2025-07-10 13:49:36 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2025-07-10 13:49:36 +0000 |
| commit | 78a6e132984dba0303ebad7dcfd1305c93ad5835 (patch) | |
| tree | d750951d6c3044d202ada72e87b9c35cb0dc74f1 /tests | |
| parent | 119574f83576dc1f3ae067f9a97986d4e2b0826c (diff) | |
| parent | bd2a3517881de6026cac53262e14275758e70b7b (diff) | |
| download | rust-78a6e132984dba0303ebad7dcfd1305c93ad5835.tar.gz rust-78a6e132984dba0303ebad7dcfd1305c93ad5835.zip | |
Auto merge of #143731 - matthiaskrgr:rollup-lm9q7vc, r=matthiaskrgr
Rollup of 12 pull requests Successful merges: - rust-lang/rust#136906 (Add checking for unnecessary delims in closure body) - rust-lang/rust#143652 (docs: document trait upcasting rules in `Unsize` trait) - rust-lang/rust#143657 (Resolver: refact macro map into external and local maps) - rust-lang/rust#143659 (Use "Innermost" & "Outermost" terminology for `AttributeOrder`) - rust-lang/rust#143663 (fix: correct typo in attr_parsing_previously_accepted message key) - rust-lang/rust#143666 (Re-expose nested bodies in rustc_borrowck::consumers) - rust-lang/rust#143668 (Fix VxWorks build errors) - rust-lang/rust#143670 (Add a new maintainer to the wasm32-wasip1 target) - rust-lang/rust#143675 (improve lint doc text) - rust-lang/rust#143683 (Assorted `run-make-support` maintenance) - rust-lang/rust#143695 (Auto-add `S-waiting-on-author` when the PR is/switches to draft state) - rust-lang/rust#143706 (triagebot.toml: ping lolbinarycat if tidy extra checks were modified) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
30 files changed, 211 insertions, 77 deletions
diff --git a/tests/run-make/archive-duplicate-names/rmake.rs b/tests/run-make/archive-duplicate-names/rmake.rs index 62a35566199..0c352b3ae1b 100644 --- a/tests/run-make/archive-duplicate-names/rmake.rs +++ b/tests/run-make/archive-duplicate-names/rmake.rs @@ -6,7 +6,7 @@ //@ ignore-cross-compile // Reason: the compiled binary is executed -use run_make_support::{cc, is_msvc, llvm_ar, rfs, run, rustc}; +use run_make_support::{cc, is_windows_msvc, llvm_ar, rfs, run, rustc}; fn main() { rfs::create_dir("a"); @@ -15,7 +15,7 @@ fn main() { compile_obj_force_foo("b", "bar"); let mut ar = llvm_ar(); ar.obj_to_ar().arg("libfoo.a"); - if is_msvc() { + if is_windows_msvc() { ar.arg("a/foo.obj").arg("b/foo.obj").run(); } else { ar.arg("a/foo.o").arg("b/foo.o").run(); @@ -27,9 +27,9 @@ fn main() { #[track_caller] pub fn compile_obj_force_foo(dir: &str, lib_name: &str) { - let obj_file = if is_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") }; + let obj_file = if is_windows_msvc() { format!("{dir}/foo") } else { format!("{dir}/foo.o") }; let src = format!("{lib_name}.c"); - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe(&obj_file).input(src).run(); } else { cc().arg("-v").arg("-c").out_exe(&obj_file).input(src).run(); diff --git a/tests/run-make/c-link-to-rust-dylib/rmake.rs b/tests/run-make/c-link-to-rust-dylib/rmake.rs index 3a48af8a366..ece0c81d2da 100644 --- a/tests/run-make/c-link-to-rust-dylib/rmake.rs +++ b/tests/run-make/c-link-to-rust-dylib/rmake.rs @@ -3,12 +3,14 @@ //@ ignore-cross-compile -use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, rfs, run, run_fail, rustc}; +use run_make_support::{ + cc, cwd, dynamic_lib_extension, is_windows_msvc, rfs, run, run_fail, rustc, +}; fn main() { rustc().input("foo.rs").run(); - if is_msvc() { + if is_windows_msvc() { let lib = "foo.dll.lib"; cc().input("bar.c").arg(lib).out_exe("bar").run(); diff --git a/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs index 62e1748b6fb..ba5fe589acb 100644 --- a/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs +++ b/tests/run-make/c-unwind-abi-catch-lib-panic/rmake.rs @@ -8,11 +8,11 @@ //@ needs-unwind // Reason: this test exercises unwinding a panic -use run_make_support::{cc, is_msvc, llvm_ar, run, rustc, static_lib_name}; +use run_make_support::{cc, is_windows_msvc, llvm_ar, run, rustc, static_lib_name}; fn main() { // Compile `add.c` into an object file. - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe("add").input("add.c").run(); } else { cc().arg("-v").arg("-c").out_exe("add.o").input("add.c").run(); @@ -24,7 +24,7 @@ fn main() { rustc().emit("obj").input("panic.rs").run(); // Now, create an archive using these two objects. - if is_msvc() { + if is_windows_msvc() { llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.obj", "panic.o"]).run(); } else { llvm_ar().obj_to_ar().args(&[&static_lib_name("add"), "add.o", "panic.o"]).run(); diff --git a/tests/run-make/cdylib-dylib-linkage/rmake.rs b/tests/run-make/cdylib-dylib-linkage/rmake.rs index a8fd8e2d168..3c145d9f99c 100644 --- a/tests/run-make/cdylib-dylib-linkage/rmake.rs +++ b/tests/run-make/cdylib-dylib-linkage/rmake.rs @@ -9,7 +9,7 @@ use run_make_support::{ bin_name, cc, dynamic_lib_extension, dynamic_lib_name, filename_contains, has_extension, - has_prefix, has_suffix, is_msvc, msvc_import_dynamic_lib_name, path, run, rustc, + has_prefix, has_suffix, is_windows_msvc, msvc_import_dynamic_lib_name, path, run, rustc, shallow_find_files, target, }; @@ -19,7 +19,7 @@ fn main() { let sysroot = rustc().print("sysroot").run().stdout_utf8(); let sysroot = sysroot.trim(); let target_sysroot = path(sysroot).join("lib/rustlib").join(target()).join("lib"); - if is_msvc() { + if is_windows_msvc() { let mut libs = shallow_find_files(&target_sysroot, |path| { has_prefix(path, "libstd-") && has_suffix(path, ".dll.lib") }); diff --git a/tests/run-make/cdylib/rmake.rs b/tests/run-make/cdylib/rmake.rs index 21b83d1b1a9..21fd8b486c4 100644 --- a/tests/run-make/cdylib/rmake.rs +++ b/tests/run-make/cdylib/rmake.rs @@ -10,13 +10,13 @@ //@ ignore-cross-compile -use run_make_support::{cc, cwd, dynamic_lib_name, is_msvc, rfs, run, rustc}; +use run_make_support::{cc, cwd, dynamic_lib_name, is_windows_msvc, rfs, run, rustc}; fn main() { rustc().input("bar.rs").run(); rustc().input("foo.rs").run(); - if is_msvc() { + if is_windows_msvc() { cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run(); } else { cc().input("foo.c").arg("-lfoo").library_search_path(cwd()).output("foo").run(); diff --git a/tests/run-make/compiler-rt-works-on-mingw/rmake.rs b/tests/run-make/compiler-rt-works-on-mingw/rmake.rs index f1b41f96312..b15e56db1bb 100644 --- a/tests/run-make/compiler-rt-works-on-mingw/rmake.rs +++ b/tests/run-make/compiler-rt-works-on-mingw/rmake.rs @@ -5,7 +5,7 @@ //@ only-windows-gnu -use run_make_support::{cxx, is_msvc, llvm_ar, run, rustc, static_lib_name}; +use run_make_support::{cxx, llvm_ar, run, rustc, static_lib_name}; fn main() { cxx().input("foo.cpp").arg("-c").out_exe("foo.o").run(); diff --git a/tests/run-make/link-args-order/rmake.rs b/tests/run-make/link-args-order/rmake.rs index 7a67c12f74c..e3c730bfec5 100644 --- a/tests/run-make/link-args-order/rmake.rs +++ b/tests/run-make/link-args-order/rmake.rs @@ -6,10 +6,10 @@ // checks that linker arguments remain intact and in the order they were originally passed in. // See https://github.com/rust-lang/rust/pull/70665 -use run_make_support::{is_msvc, rustc}; +use run_make_support::{is_windows_msvc, rustc}; fn main() { - let linker = if is_msvc() { "msvc" } else { "ld" }; + let linker = if is_windows_msvc() { "msvc" } else { "ld" }; rustc() .input("empty.rs") diff --git a/tests/run-make/link-dedup/rmake.rs b/tests/run-make/link-dedup/rmake.rs index 874e6e0083b..84fdf87e9c7 100644 --- a/tests/run-make/link-dedup/rmake.rs +++ b/tests/run-make/link-dedup/rmake.rs @@ -9,7 +9,7 @@ use std::fmt::Write; -use run_make_support::{is_msvc, rustc, target}; +use run_make_support::{is_windows_msvc, rustc, target}; fn main() { rustc().input("depa.rs").run(); @@ -32,7 +32,7 @@ fn main() { fn needle_from_libs(libs: &[&str]) -> String { let mut needle = String::new(); for lib in libs { - if is_msvc() { + if is_windows_msvc() { needle.write_fmt(format_args!(r#""{lib}.lib" "#)).unwrap(); } else if target().contains("wasm") { needle.write_fmt(format_args!(r#""-l" "{lib}" "#)).unwrap(); diff --git a/tests/run-make/native-link-modifier-bundle/rmake.rs b/tests/run-make/native-link-modifier-bundle/rmake.rs index 058b66b15f1..64ee7733498 100644 --- a/tests/run-make/native-link-modifier-bundle/rmake.rs +++ b/tests/run-make/native-link-modifier-bundle/rmake.rs @@ -20,7 +20,7 @@ // Reason: cross-compilation fails to export native symbols use run_make_support::{ - build_native_static_lib, dynamic_lib_name, is_msvc, llvm_nm, rust_lib_name, rustc, + build_native_static_lib, dynamic_lib_name, is_windows_msvc, llvm_nm, rust_lib_name, rustc, static_lib_name, }; @@ -60,7 +60,7 @@ fn main() { .assert_stdout_contains_regex("U _*native_func"); // This part of the test does not function on Windows MSVC - no symbols are printed. - if !is_msvc() { + if !is_windows_msvc() { // Build a cdylib, `native-staticlib` will not appear on the linker line because it was // bundled previously. The cdylib will contain the `native_func` symbol in the end. rustc() diff --git a/tests/run-make/native-link-modifier-whole-archive/rmake.rs b/tests/run-make/native-link-modifier-whole-archive/rmake.rs index b8b814043e5..90b0203e278 100644 --- a/tests/run-make/native-link-modifier-whole-archive/rmake.rs +++ b/tests/run-make/native-link-modifier-whole-archive/rmake.rs @@ -10,11 +10,11 @@ // Reason: compiling C++ code does not work well when cross-compiling // plus, the compiled binary is executed -use run_make_support::{cxx, is_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; +use run_make_support::{cxx, is_windows_msvc, llvm_ar, run, run_with_args, rustc, static_lib_name}; fn main() { let mut cxx = cxx(); - if is_msvc() { + if is_windows_msvc() { cxx.arg("-EHs"); } cxx.input("c_static_lib_with_constructor.cpp") @@ -24,7 +24,7 @@ fn main() { let mut llvm_ar = llvm_ar(); llvm_ar.obj_to_ar(); - if is_msvc() { + if is_windows_msvc() { llvm_ar .output_input( static_lib_name("c_static_lib_with_constructor"), diff --git a/tests/run-make/pointer-auth-link-with-c/rmake.rs b/tests/run-make/pointer-auth-link-with-c/rmake.rs index 7b6dff10eae..a4d7454e575 100644 --- a/tests/run-make/pointer-auth-link-with-c/rmake.rs +++ b/tests/run-make/pointer-auth-link-with-c/rmake.rs @@ -9,7 +9,7 @@ //@ ignore-cross-compile // Reason: the compiled binary is executed -use run_make_support::{build_native_static_lib, cc, is_msvc, llvm_ar, run, rustc}; +use run_make_support::{build_native_static_lib, cc, is_windows_msvc, llvm_ar, run, rustc}; fn main() { build_native_static_lib("test"); @@ -21,7 +21,7 @@ fn main() { .input("test.c") .arg("-mbranch-protection=bti+pac-ret+leaf") .run(); - let obj_file = if is_msvc() { "test.obj" } else { "test" }; + let obj_file = if is_windows_msvc() { "test.obj" } else { "test" }; llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run(); rustc().arg("-Zbranch-protection=bti,pac-ret,leaf").input("test.rs").run(); run("test"); @@ -33,7 +33,7 @@ fn main() { // .input("test.c") // .arg("-mbranch-protection=bti+pac-ret+pc+leaf") // .run(); - // let obj_file = if is_msvc() { "test.obj" } else { "test" }; + // let obj_file = if is_windows_msvc() { "test.obj" } else { "test" }; // llvm_ar().obj_to_ar().output_input("libtest.a", &obj_file).run(); // rustc().arg("-Zbranch-protection=bti,pac-ret,pc,leaf").input("test.rs").run(); // run("test"); diff --git a/tests/run-make/print-native-static-libs/rmake.rs b/tests/run-make/print-native-static-libs/rmake.rs index a51ac934c72..4502c874cae 100644 --- a/tests/run-make/print-native-static-libs/rmake.rs +++ b/tests/run-make/print-native-static-libs/rmake.rs @@ -12,7 +12,7 @@ //@ ignore-cross-compile //@ ignore-wasm -use run_make_support::{is_msvc, rustc}; +use run_make_support::{is_windows_msvc, rustc}; fn main() { // build supporting crate @@ -41,9 +41,9 @@ fn main() { ($lib:literal in $args:ident) => {{ let lib = format!( "{}{}{}", - if !is_msvc() { "-l" } else { "" }, + if !is_windows_msvc() { "-l" } else { "" }, $lib, - if !is_msvc() { "" } else { ".lib" }, + if !is_windows_msvc() { "" } else { ".lib" }, ); let found = $args.contains(&&*lib); assert!(found, "unable to find lib `{}` in those linker args: {:?}", lib, $args); diff --git a/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs b/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs index 1a1622f2754..0843c6beae8 100644 --- a/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs +++ b/tests/run-make/raw-dylib-alt-calling-convention/rmake.rs @@ -9,7 +9,9 @@ //@ only-x86 //@ only-windows -use run_make_support::{build_native_dynamic_lib, diff, is_msvc, run, run_with_args, rustc}; +use run_make_support::{ + build_native_dynamic_lib, diff, is_windows_msvc, run, run_with_args, rustc, +}; fn main() { rustc() @@ -21,7 +23,7 @@ fn main() { build_native_dynamic_lib("extern"); let out = run("driver").stdout_utf8(); diff().expected_file("output.txt").actual_text("actual", out).normalize(r#"\r"#, "").run(); - if is_msvc() { + if is_windows_msvc() { let out_msvc = run_with_args("driver", &["true"]).stdout_utf8(); diff() .expected_file("output.msvc.txt") diff --git a/tests/run-make/raw-dylib-import-name-type/rmake.rs b/tests/run-make/raw-dylib-import-name-type/rmake.rs index 13a2c99150e..71f255ab39f 100644 --- a/tests/run-make/raw-dylib-import-name-type/rmake.rs +++ b/tests/run-make/raw-dylib-import-name-type/rmake.rs @@ -11,14 +11,14 @@ //@ only-windows // Reason: this test specifically exercises a 32bit Windows calling convention. -use run_make_support::{cc, diff, is_msvc, run, rustc}; +use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; // NOTE: build_native_dynamic lib is not used, as the special `def` files // must be passed to the CC compiler. fn main() { rustc().crate_type("bin").input("driver.rs").run(); - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe("extern").input("extern.c").run(); cc().input("extern.obj") .arg("extern.msvc.def") diff --git a/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs b/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs index 6e3b31a0cdb..a167e8198a7 100644 --- a/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs +++ b/tests/run-make/raw-dylib-inline-cross-dylib/rmake.rs @@ -7,7 +7,7 @@ //@ only-windows -use run_make_support::{cc, diff, is_msvc, llvm_objdump, run, rustc}; +use run_make_support::{cc, diff, is_windows_msvc, llvm_objdump, run, rustc}; fn main() { rustc() @@ -31,7 +31,7 @@ fn main() { .assert_stdout_not_contains("inline_library_function") // Make sure we do find an import to the functions we expect to be imported. .assert_stdout_contains("library_function"); - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe("extern_1").input("extern_1.c").run(); cc().arg("-c").out_exe("extern_2").input("extern_2.c").run(); cc().input("extern_1.obj") diff --git a/tests/run-make/raw-dylib-link-ordinal/rmake.rs b/tests/run-make/raw-dylib-link-ordinal/rmake.rs index b52181ae3f9..43274b9765b 100644 --- a/tests/run-make/raw-dylib-link-ordinal/rmake.rs +++ b/tests/run-make/raw-dylib-link-ordinal/rmake.rs @@ -11,7 +11,7 @@ //@ only-windows -use run_make_support::{cc, diff, is_msvc, run, rustc}; +use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; // NOTE: build_native_dynamic lib is not used, as the special `def` files // must be passed to the CC compiler. @@ -19,7 +19,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc}; fn main() { rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run(); rustc().crate_type("bin").input("driver.rs").run(); - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe("exporter").input("exporter.c").run(); cc().input("exporter.obj") .arg("exporter.def") diff --git a/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs b/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs index 320ea1520d8..f898cc0f8c8 100644 --- a/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs +++ b/tests/run-make/raw-dylib-stdcall-ordinal/rmake.rs @@ -10,7 +10,7 @@ //@ only-windows // Reason: this test specifically exercises a 32bit Windows calling convention. -use run_make_support::{cc, diff, is_msvc, run, rustc}; +use run_make_support::{cc, diff, is_windows_msvc, run, rustc}; // NOTE: build_native_dynamic lib is not used, as the special `def` files // must be passed to the CC compiler. @@ -18,7 +18,7 @@ use run_make_support::{cc, diff, is_msvc, run, rustc}; fn main() { rustc().crate_type("lib").crate_name("raw_dylib_test").input("lib.rs").run(); rustc().crate_type("bin").input("driver.rs").run(); - if is_msvc() { + if is_windows_msvc() { cc().arg("-c").out_exe("exporter").input("exporter.c").run(); cc().input("exporter.obj") .arg("exporter-msvc.def") diff --git a/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs b/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs index ff0438a6b72..f0929a3ee85 100644 --- a/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs +++ b/tests/run-make/rlib-format-packed-bundled-libs/rmake.rs @@ -8,8 +8,8 @@ // Reason: cross-compilation fails to export native symbols use run_make_support::{ - bin_name, build_native_static_lib, cwd, filename_contains, is_msvc, llvm_ar, llvm_nm, rfs, - rust_lib_name, rustc, shallow_find_files, + bin_name, build_native_static_lib, cwd, filename_contains, is_windows_msvc, llvm_ar, llvm_nm, + rfs, rust_lib_name, rustc, shallow_find_files, }; fn main() { @@ -74,7 +74,7 @@ fn main() { .assert_stdout_contains_regex("native_dep_1.*native_dep_2.*native_dep_3"); // The binary "main" will not contain any symbols on MSVC. - if !is_msvc() { + if !is_windows_msvc() { llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f1"); llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f2"); llvm_nm().input(bin_name("main")).run().assert_stdout_contains_regex("T.*native_f3"); diff --git a/tests/run-make/split-debuginfo/rmake.rs b/tests/run-make/split-debuginfo/rmake.rs index 530a5d119f1..e8de5aed172 100644 --- a/tests/run-make/split-debuginfo/rmake.rs +++ b/tests/run-make/split-debuginfo/rmake.rs @@ -61,8 +61,8 @@ use std::collections::BTreeSet; use run_make_support::rustc::Rustc; use run_make_support::{ - cwd, has_extension, is_darwin, is_msvc, is_windows, llvm_dwarfdump, run_in_tmpdir, rustc, - shallow_find_directories, shallow_find_files, uname, + cwd, has_extension, is_darwin, is_windows, is_windows_msvc, llvm_dwarfdump, run_in_tmpdir, + rustc, shallow_find_directories, shallow_find_files, uname, }; /// `-C debuginfo`. See <https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo>. @@ -1296,7 +1296,7 @@ fn main() { // identify which combination isn't exercised with a 6-layers nested for loop iterating through // each of the cli flag enum variants. - if is_msvc() { + if is_windows_msvc() { // FIXME: the windows-msvc test coverage is sparse at best. windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified); diff --git a/tests/run-make/static-dylib-by-default/rmake.rs b/tests/run-make/static-dylib-by-default/rmake.rs index 133210c74e7..b1160c63297 100644 --- a/tests/run-make/static-dylib-by-default/rmake.rs +++ b/tests/run-make/static-dylib-by-default/rmake.rs @@ -9,7 +9,7 @@ // Reason: the compiled binary is executed use run_make_support::{ - cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_msvc, rfs, run, rustc, + cc, cwd, dynamic_lib_name, extra_c_flags, has_extension, is_windows_msvc, rfs, run, rustc, shallow_find_files, }; @@ -22,13 +22,13 @@ fn main() { // bar.dll.exp // export library for the dylib // msvc's underlying link.exe requires the import library for the dynamic library as input. // That is why the library is bar.dll.lib, not bar.dll. - let library = if is_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") }; + let library = if is_windows_msvc() { "bar.dll.lib" } else { &dynamic_lib_name("bar") }; cc().input("main.c").out_exe("main").arg(library).args(extra_c_flags()).run(); for rlib in shallow_find_files(cwd(), |path| has_extension(path, "rlib")) { rfs::remove_file(rlib); } rfs::remove_file(dynamic_lib_name("foo")); - if is_msvc() { + if is_windows_msvc() { rfs::remove_file("foo.dll.lib"); } run("main"); diff --git a/tests/run-make/staticlib-dylib-linkage/rmake.rs b/tests/run-make/staticlib-dylib-linkage/rmake.rs index 8dd1ac0ffbd..9582ca19831 100644 --- a/tests/run-make/staticlib-dylib-linkage/rmake.rs +++ b/tests/run-make/staticlib-dylib-linkage/rmake.rs @@ -9,7 +9,7 @@ //@ ignore-wasm // Reason: WASM does not support dynamic libraries -use run_make_support::{cc, is_msvc, regex, run, rustc, static_lib_name}; +use run_make_support::{cc, is_windows_msvc, regex, run, rustc, static_lib_name}; fn main() { rustc().arg("-Cprefer-dynamic").input("bar.rs").run(); @@ -27,7 +27,7 @@ fn main() { let (_, native_link_args) = libs.split_once("note: native-static-libs: ").unwrap(); // divide the command-line arguments in a vec let mut native_link_args = native_link_args.split(' ').collect::<Vec<&str>>(); - if is_msvc() { + if is_windows_msvc() { // For MSVC pass the arguments on to the linker. native_link_args.insert(0, "-link"); } diff --git a/tests/run-make/symbol-visibility/rmake.rs b/tests/run-make/symbol-visibility/rmake.rs index 49c8e87707b..e3d276d6da8 100644 --- a/tests/run-make/symbol-visibility/rmake.rs +++ b/tests/run-make/symbol-visibility/rmake.rs @@ -9,7 +9,7 @@ // See https://github.com/rust-lang/rust/issues/37530 use run_make_support::object::read::Object; -use run_make_support::{bin_name, dynamic_lib_name, is_msvc, object, regex, rfs, rustc}; +use run_make_support::{bin_name, dynamic_lib_name, is_windows_msvc, object, regex, rfs, rustc}; fn main() { let cdylib_name = dynamic_lib_name("a_cdylib"); @@ -64,7 +64,7 @@ fn main() { ); // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 - if is_msvc() { + if is_windows_msvc() { // Check that an executable does not export any dynamic symbols symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false); symbols_check( @@ -130,7 +130,7 @@ fn main() { ); // FIXME(nbdd0121): This is broken in MinGW, see https://github.com/rust-lang/rust/pull/95604#issuecomment-1101564032 - if is_msvc() { + if is_windows_msvc() { // Check that an executable does not export any dynamic symbols symbols_check(&exe_name, SymbolCheckType::StrSymbol("public_c_function_from_rlib"), false); symbols_check( diff --git a/tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs b/tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs index 7213e06792a..9cfc901eabe 100644 --- a/tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs +++ b/tests/ui-fulldeps/auxiliary/obtain-borrowck-input.rs @@ -28,6 +28,10 @@ const fn foo() -> usize { 1 } +fn with_nested_body(opt: Option<i32>) -> Option<i32> { + opt.map(|x| x + 1) +} + fn main() { let bar: [Bar; foo()] = [Bar::new()]; assert_eq!(bar[0].provided(), foo()); diff --git a/tests/ui-fulldeps/obtain-borrowck.rs b/tests/ui-fulldeps/obtain-borrowck.rs index 84f6970c83a..08213fd7588 100644 --- a/tests/ui-fulldeps/obtain-borrowck.rs +++ b/tests/ui-fulldeps/obtain-borrowck.rs @@ -9,16 +9,17 @@ //! This program implements a rustc driver that retrieves MIR bodies with //! borrowck information. This cannot be done in a straightforward way because -//! `get_body_with_borrowck_facts`–the function for retrieving a MIR body with -//! borrowck facts–can panic if the body is stolen before it is invoked. +//! `get_bodies_with_borrowck_facts`–the function for retrieving MIR bodies with +//! borrowck facts–can panic if the bodies are stolen before it is invoked. //! Therefore, the driver overrides `mir_borrowck` query (this is done in the -//! `config` callback), which retrieves the body that is about to be borrow -//! checked and stores it in a thread local `MIR_BODIES`. Then, `after_analysis` +//! `config` callback), which retrieves the bodies that are about to be borrow +//! checked and stores them in a thread local `MIR_BODIES`. Then, `after_analysis` //! callback triggers borrow checking of all MIR bodies by retrieving //! `optimized_mir` and pulls out the MIR bodies with the borrowck information //! from the thread local storage. extern crate rustc_borrowck; +extern crate rustc_data_structures; extern crate rustc_driver; extern crate rustc_hir; extern crate rustc_interface; @@ -30,6 +31,7 @@ use std::collections::HashMap; use std::thread_local; use rustc_borrowck::consumers::{self, BodyWithBorrowckFacts, ConsumerOptions}; +use rustc_data_structures::fx::FxHashMap; use rustc_driver::Compilation; use rustc_hir::def::DefKind; use rustc_hir::def_id::LocalDefId; @@ -129,13 +131,15 @@ thread_local! { fn mir_borrowck<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId) -> ProvidedValue<'tcx> { let opts = ConsumerOptions::PoloniusInputFacts; - let body_with_facts = consumers::get_body_with_borrowck_facts(tcx, def_id, opts); + let bodies_with_facts = consumers::get_bodies_with_borrowck_facts(tcx, def_id, opts); // SAFETY: The reader casts the 'static lifetime to 'tcx before using it. - let body_with_facts: BodyWithBorrowckFacts<'static> = - unsafe { std::mem::transmute(body_with_facts) }; + let bodies_with_facts: FxHashMap<LocalDefId, BodyWithBorrowckFacts<'static>> = + unsafe { std::mem::transmute(bodies_with_facts) }; MIR_BODIES.with(|state| { let mut map = state.borrow_mut(); - assert!(map.insert(def_id, body_with_facts).is_none()); + for (def_id, body_with_facts) in bodies_with_facts { + assert!(map.insert(def_id, body_with_facts).is_none()); + } }); let mut providers = Providers::default(); rustc_borrowck::provide(&mut providers); diff --git a/tests/ui-fulldeps/obtain-borrowck.run.stdout b/tests/ui-fulldeps/obtain-borrowck.run.stdout index e011622e6b2..09d3e50f42d 100644 --- a/tests/ui-fulldeps/obtain-borrowck.run.stdout +++ b/tests/ui-fulldeps/obtain-borrowck.run.stdout @@ -3,6 +3,8 @@ Bodies retrieved for: ::foo ::main ::main::{constant#0} +::with_nested_body +::with_nested_body::{closure#0} ::{impl#0}::new ::{impl#1}::provided ::{impl#1}::required diff --git a/tests/ui/async-await/issues/issue-54752-async-block.rs b/tests/ui/async-await/issues/issue-54752-async-block.rs index 452b6794bee..164c1885da1 100644 --- a/tests/ui/async-await/issues/issue-54752-async-block.rs +++ b/tests/ui/async-await/issues/issue-54752-async-block.rs @@ -4,4 +4,3 @@ //@ pp-exact fn main() { let _a = (async { }); } -//~^ WARNING unnecessary parentheses around assigned value diff --git a/tests/ui/async-await/issues/issue-54752-async-block.stderr b/tests/ui/async-await/issues/issue-54752-async-block.stderr deleted file mode 100644 index 8cc849dd985..00000000000 --- a/tests/ui/async-await/issues/issue-54752-async-block.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: unnecessary parentheses around assigned value - --> $DIR/issue-54752-async-block.rs:6:22 - | -LL | fn main() { let _a = (async { }); } - | ^ ^ - | - = note: `#[warn(unused_parens)]` on by default -help: remove these parentheses - | -LL - fn main() { let _a = (async { }); } -LL + fn main() { let _a = async { }; } - | - -warning: 1 warning emitted - diff --git a/tests/ui/lint/unused/closure-body-issue-136741.fixed b/tests/ui/lint/unused/closure-body-issue-136741.fixed new file mode 100644 index 00000000000..2ded52544b9 --- /dev/null +++ b/tests/ui/lint/unused/closure-body-issue-136741.fixed @@ -0,0 +1,36 @@ +//@ run-rustfix +// ignore-tidy-linelength +#![deny(unused_parens)] +#![deny(unused_braces)] + +fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() +{} + +fn func(f: impl FnOnce()) { + f() +} + +pub fn main() { + let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; + let _ = || 0 == 0; //~ ERROR unnecessary parentheses around closure body + let _ = (0..).find(|n| n % 2 == 0); //~ ERROR unnecessary parentheses around closure body + let _ = (0..).find(|n| {n % 2 == 0}); + + // multiple lines of code will not lint with braces + let _ = (0..).find(|n| { + n % 2 == 0 + }); + + // multiple lines of code will lint with parentheses + let _ = (0..).find(|n| n % 2 == 0); + + let _ = || { + _ = 0; + 0 == 0 //~ ERROR unnecessary parentheses around block return value + }; + + // long expressions will not lint with braces + func(|| { + long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() + }) +} diff --git a/tests/ui/lint/unused/closure-body-issue-136741.rs b/tests/ui/lint/unused/closure-body-issue-136741.rs new file mode 100644 index 00000000000..4eac981ec2e --- /dev/null +++ b/tests/ui/lint/unused/closure-body-issue-136741.rs @@ -0,0 +1,38 @@ +//@ run-rustfix +// ignore-tidy-linelength +#![deny(unused_parens)] +#![deny(unused_braces)] + +fn long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() +{} + +fn func(f: impl FnOnce()) { + f() +} + +pub fn main() { + let _closure = |x: i32, y: i32| { x * (x + (y * 2)) }; + let _ = || (0 == 0); //~ ERROR unnecessary parentheses around closure body + let _ = (0..).find(|n| (n % 2 == 0)); //~ ERROR unnecessary parentheses around closure body + let _ = (0..).find(|n| {n % 2 == 0}); + + // multiple lines of code will not lint with braces + let _ = (0..).find(|n| { + n % 2 == 0 + }); + + // multiple lines of code will lint with parentheses + let _ = (0..).find(|n| ( //~ ERROR unnecessary parentheses around closure body + n % 2 == 0 + )); + + let _ = || { + _ = 0; + (0 == 0) //~ ERROR unnecessary parentheses around block return value + }; + + // long expressions will not lint with braces + func(|| { + long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces_long_expr_that_does_not_require_braces() + }) +} diff --git a/tests/ui/lint/unused/closure-body-issue-136741.stderr b/tests/ui/lint/unused/closure-body-issue-136741.stderr new file mode 100644 index 00000000000..2ea872c08c7 --- /dev/null +++ b/tests/ui/lint/unused/closure-body-issue-136741.stderr @@ -0,0 +1,62 @@ +error: unnecessary parentheses around closure body + --> $DIR/closure-body-issue-136741.rs:15:16 + | +LL | let _ = || (0 == 0); + | ^ ^ + | +note: the lint level is defined here + --> $DIR/closure-body-issue-136741.rs:3:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - let _ = || (0 == 0); +LL + let _ = || 0 == 0; + | + +error: unnecessary parentheses around closure body + --> $DIR/closure-body-issue-136741.rs:16:28 + | +LL | let _ = (0..).find(|n| (n % 2 == 0)); + | ^ ^ + | +help: remove these parentheses + | +LL - let _ = (0..).find(|n| (n % 2 == 0)); +LL + let _ = (0..).find(|n| n % 2 == 0); + | + +error: unnecessary parentheses around closure body + --> $DIR/closure-body-issue-136741.rs:25:28 + | +LL | let _ = (0..).find(|n| ( + | _____________________________^ +LL | | n % 2 == 0 + | | ________^__________^ + | ||________| + | | +LL | | )); + | |_____^ + | +help: remove these parentheses + | +LL - let _ = (0..).find(|n| ( +LL - n % 2 == 0 +LL + let _ = (0..).find(|n| n % 2 == 0); + | + +error: unnecessary parentheses around block return value + --> $DIR/closure-body-issue-136741.rs:31:9 + | +LL | (0 == 0) + | ^ ^ + | +help: remove these parentheses + | +LL - (0 == 0) +LL + 0 == 0 + | + +error: aborting due to 4 previous errors + |
