From 08b188c8f1c6aee66529208960e73ebda0c06bc0 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 28 Oct 2025 13:24:09 +1100 Subject: [PATCH 01/15] Remove `cleanup_debug_info_options` This "cleanup" function is more than a decade old, and I can't find any evidence of modern-day bootstrap being able to pass any of these flags to `--host-rustcflags` or `--target-rustcflags`. --- .../compiletest/src/runtest/debuginfo.rs | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 9175a38ffa5c9..bc597597ce12e 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -8,7 +8,6 @@ use tracing::debug; use super::debugger::DebuggerCommands; use super::{Debugger, Emit, ProcRes, TestCx, Truncated, WillExecute}; -use crate::common::Config; use crate::debuggers::{extract_gdb_version, is_android_gdb_target}; impl TestCx<'_> { @@ -21,18 +20,6 @@ impl TestCx<'_> { } fn run_debuginfo_cdb_test(&self) { - let config = Config { - target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags), - host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags), - ..self.config.clone() - }; - - let test_cx = TestCx { config: &config, ..*self }; - - test_cx.run_debuginfo_cdb_test_no_opt(); - } - - fn run_debuginfo_cdb_test_no_opt(&self) { let exe_file = self.make_exe_name(); // Existing PDB files are update in-place. When changing the debuginfo @@ -118,18 +105,6 @@ impl TestCx<'_> { } fn run_debuginfo_gdb_test(&self) { - let config = Config { - target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags), - host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags), - ..self.config.clone() - }; - - let test_cx = TestCx { config: &config, ..*self }; - - test_cx.run_debuginfo_gdb_test_no_opt(); - } - - fn run_debuginfo_gdb_test_no_opt(&self) { let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, "gdb") .unwrap_or_else(|e| self.fatal(&e)); let mut cmds = dbg_cmds.commands.join("\n"); @@ -355,18 +330,6 @@ impl TestCx<'_> { self.fatal("Can't run LLDB test because LLDB's python path is not set."); } - let config = Config { - target_rustcflags: self.cleanup_debug_info_options(&self.config.target_rustcflags), - host_rustcflags: self.cleanup_debug_info_options(&self.config.host_rustcflags), - ..self.config.clone() - }; - - let test_cx = TestCx { config: &config, ..*self }; - - test_cx.run_debuginfo_lldb_test_no_opt(); - } - - fn run_debuginfo_lldb_test_no_opt(&self) { // compile test file (it should have 'compile-flags:-g' in the directive) let should_run = self.run_if_enabled(); let compile_result = self.compile_test(should_run, Emit::None); @@ -501,11 +464,4 @@ impl TestCx<'_> { .env("PYTHONPATH", pythonpath), ) } - - fn cleanup_debug_info_options(&self, options: &Vec) -> Vec { - // Remove options that are either unwanted (-O) or may lead to duplicates due to RUSTFLAGS. - let options_to_remove = ["-O".to_owned(), "-g".to_owned(), "--debuginfo".to_owned()]; - - options.iter().filter(|x| !options_to_remove.contains(x)).cloned().collect() - } } From bd5788690b7bff71bca99da28433dacd2b036067 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 28 Oct 2025 17:58:10 +1100 Subject: [PATCH 02/15] Test that auxiliaries are built against their own directives There are probably plenty of tests that will check this incidentally, but it's convenient to have a dedicated self-test. --- tests/ui/compiletest-self-test/aux-has-props.rs | 14 ++++++++++++++ .../auxiliary/aux_with_props.rs | 6 ++++++ 2 files changed, 20 insertions(+) create mode 100644 tests/ui/compiletest-self-test/aux-has-props.rs create mode 100644 tests/ui/compiletest-self-test/auxiliary/aux_with_props.rs diff --git a/tests/ui/compiletest-self-test/aux-has-props.rs b/tests/ui/compiletest-self-test/aux-has-props.rs new file mode 100644 index 0000000000000..73ec2e169f4fe --- /dev/null +++ b/tests/ui/compiletest-self-test/aux-has-props.rs @@ -0,0 +1,14 @@ +//@ edition: 2024 +//@ aux-build: aux_with_props.rs +//@ compile-flags: --check-cfg=cfg(this_is_aux) +//@ run-pass + +// Test that auxiliaries are built using the directives in the auxiliary file, +// and don't just accidentally use the directives of the main test file. + +extern crate aux_with_props; + +fn main() { + assert!(!cfg!(this_is_aux)); + assert!(aux_with_props::aux_directives_are_respected()); +} diff --git a/tests/ui/compiletest-self-test/auxiliary/aux_with_props.rs b/tests/ui/compiletest-self-test/auxiliary/aux_with_props.rs new file mode 100644 index 0000000000000..31a5a05a7144f --- /dev/null +++ b/tests/ui/compiletest-self-test/auxiliary/aux_with_props.rs @@ -0,0 +1,6 @@ +//@ edition: 2024 +//@ compile-flags: --cfg=this_is_aux + +pub fn aux_directives_are_respected() -> bool { + cfg!(this_is_aux) +} From c62794553e642ad801aaabd45e2f3d734bb35977 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 28 Oct 2025 17:58:10 +1100 Subject: [PATCH 03/15] Don't modify `testpaths` when creating aux contexts --- src/tools/compiletest/src/runtest.rs | 58 +++++++++++++--------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 16b604e9df821..fed59764a2eb8 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -18,7 +18,6 @@ use crate::common::{ CompareMode, Config, Debugger, FailMode, PassMode, RunFailMode, RunResult, TestMode, TestPaths, TestSuite, UI_EXTENSIONS, UI_FIXED, UI_RUN_STDERR, UI_RUN_STDOUT, UI_STDERR, UI_STDOUT, UI_SVG, UI_WINDOWS_SVG, expected_output_path, incremental_dir, output_base_dir, output_base_name, - output_testname_unique, }; use crate::directives::TestProps; use crate::errors::{Error, ErrorKind, load_errors}; @@ -1004,27 +1003,39 @@ impl<'test> TestCx<'test> { root_out_dir: &Utf8Path, root_testpaths: &TestPaths, kind: DocKind, + ) -> ProcRes { + self.document_inner(&self.testpaths.file, root_out_dir, root_testpaths, kind) + } + + /// Like `document`, but takes an explicit `file_to_doc` argument so that + /// it can also be used for documenting auxiliaries, in addition to + /// documenting the main test file. + fn document_inner( + &self, + file_to_doc: &Utf8Path, + root_out_dir: &Utf8Path, + root_testpaths: &TestPaths, + kind: DocKind, ) -> ProcRes { if self.props.build_aux_docs { assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output"); for rel_ab in &self.props.aux.builds { - let aux_testpaths = self.compute_aux_test_paths(root_testpaths, rel_ab); - let props_for_aux = - self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config); + let aux_path = self.compute_aux_test_paths(root_testpaths, rel_ab); + let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config); let aux_cx = TestCx { config: self.config, stdout: self.stdout, stderr: self.stderr, props: &props_for_aux, - testpaths: &aux_testpaths, + testpaths: self.testpaths, revision: self.revision, }; // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); // use root_testpaths here, because aux-builds should have the // same --out-dir and auxiliary directory. - let auxres = aux_cx.document(&root_out_dir, root_testpaths, kind); + let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, root_testpaths, kind); if !auxres.status.success() { return auxres; } @@ -1038,7 +1049,7 @@ impl<'test> TestCx<'test> { // actual --out-dir given to the auxiliary or test, as opposed to the root out dir for the entire // test let out_dir: Cow<'_, Utf8Path> = if self.props.unique_doc_out_dir { - let file_name = self.testpaths.file.file_stem().expect("file name should not be empty"); + let file_name = file_to_doc.file_stem().expect("file name should not be empty"); let out_dir = Utf8PathBuf::from_iter([ root_out_dir, Utf8Path::new("docs"), @@ -1063,7 +1074,7 @@ impl<'test> TestCx<'test> { .arg(out_dir.as_ref()) .arg("--deny") .arg("warnings") - .arg(&self.testpaths.file) + .arg(file_to_doc) .arg("-A") .arg("internal_features") .args(&self.props.compile_flags) @@ -1195,24 +1206,14 @@ impl<'test> TestCx<'test> { /// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary` /// directory relative to the test itself (not any intermediate auxiliaries). - fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> TestPaths { + fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> Utf8PathBuf { let test_ab = of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab); if !test_ab.exists() { self.fatal(&format!("aux-build `{}` source not found", test_ab)) } - TestPaths { - file: test_ab, - relative_dir: of - .relative_dir - .join(self.output_testname_unique()) - .join("auxiliary") - .join(rel_ab) - .parent() - .expect("aux-build path has no parent") - .to_path_buf(), - } + test_ab } fn is_vxworks_pure_static(&self) -> bool { @@ -1369,9 +1370,8 @@ impl<'test> TestCx<'test> { aux_dir: &Utf8Path, aux_type: Option, ) -> AuxType { - let aux_testpaths = self.compute_aux_test_paths(of, source_path); - let mut aux_props = - self.props.from_aux_file(&aux_testpaths.file, self.revision, self.config); + let aux_path = self.compute_aux_test_paths(of, source_path); + let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config); if aux_type == Some(AuxType::ProcMacro) { aux_props.force_host = true; } @@ -1388,14 +1388,13 @@ impl<'test> TestCx<'test> { stdout: self.stdout, stderr: self.stderr, props: &aux_props, - testpaths: &aux_testpaths, + testpaths: self.testpaths, revision: self.revision, }; // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); - let input_file = &aux_testpaths.file; let mut aux_rustc = aux_cx.make_compile_args( - input_file, + &aux_path, aux_output, Emit::None, AllowUnused::No, @@ -1471,7 +1470,7 @@ impl<'test> TestCx<'test> { ); if !auxres.status.success() { self.fatal_proc_rec( - &format!("auxiliary build of {} failed to compile: ", aux_testpaths.file), + &format!("auxiliary build of {aux_path} failed to compile: "), &auxres, ); } @@ -2033,11 +2032,6 @@ impl<'test> TestCx<'test> { self.aux_output_dir_name().join("bin") } - /// Generates a unique name for the test, such as `testname.revision.mode`. - fn output_testname_unique(&self) -> Utf8PathBuf { - output_testname_unique(self.config, self.testpaths, self.safe_revision()) - } - /// The revision, ignored for incremental compilation since it wants all revisions in /// the same directory. fn safe_revision(&self) -> Option<&str> { From 6dfc82b24af1708068aaecbb0edeafea0cd28b47 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 28 Oct 2025 17:58:10 +1100 Subject: [PATCH 04/15] Remove some parameters that are always `self.testpaths` In particular, this eliminates the cryptic `of: &TestPaths` parameters. --- src/tools/compiletest/src/runtest.rs | 67 ++++++++----------- src/tools/compiletest/src/runtest/assembly.rs | 2 +- src/tools/compiletest/src/runtest/coverage.rs | 2 +- src/tools/compiletest/src/runtest/js_doc.rs | 2 +- src/tools/compiletest/src/runtest/rustdoc.rs | 2 +- .../compiletest/src/runtest/rustdoc_json.rs | 2 +- src/tools/compiletest/src/runtest/ui.rs | 2 +- 7 files changed, 35 insertions(+), 44 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index fed59764a2eb8..6696662c7a091 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -562,7 +562,7 @@ impl<'test> TestCx<'test> { self.maybe_add_external_args(&mut rustc, &self.config.target_rustcflags); rustc.args(&self.props.compile_flags); - self.compose_and_run_compiler(rustc, Some(src), self.testpaths) + self.compose_and_run_compiler(rustc, Some(src)) } fn maybe_add_external_args(&self, cmd: &mut Command, args: &Vec) { @@ -993,18 +993,13 @@ impl<'test> TestCx<'test> { passes, ); - self.compose_and_run_compiler(rustc, None, self.testpaths) + self.compose_and_run_compiler(rustc, None) } /// `root_out_dir` and `root_testpaths` refer to the parameters of the actual test being run. /// Auxiliaries, no matter how deep, have the same root_out_dir and root_testpaths. - fn document( - &self, - root_out_dir: &Utf8Path, - root_testpaths: &TestPaths, - kind: DocKind, - ) -> ProcRes { - self.document_inner(&self.testpaths.file, root_out_dir, root_testpaths, kind) + fn document(&self, root_out_dir: &Utf8Path, kind: DocKind) -> ProcRes { + self.document_inner(&self.testpaths.file, root_out_dir, kind) } /// Like `document`, but takes an explicit `file_to_doc` argument so that @@ -1014,14 +1009,13 @@ impl<'test> TestCx<'test> { &self, file_to_doc: &Utf8Path, root_out_dir: &Utf8Path, - root_testpaths: &TestPaths, kind: DocKind, ) -> ProcRes { if self.props.build_aux_docs { assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output"); for rel_ab in &self.props.aux.builds { - let aux_path = self.compute_aux_test_paths(root_testpaths, rel_ab); + let aux_path = self.compute_aux_test_paths(rel_ab); let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config); let aux_cx = TestCx { config: self.config, @@ -1033,9 +1027,7 @@ impl<'test> TestCx<'test> { }; // Create the directory for the stdout/stderr files. create_dir_all(aux_cx.output_base_dir()).unwrap(); - // use root_testpaths here, because aux-builds should have the - // same --out-dir and auxiliary directory. - let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, root_testpaths, kind); + let auxres = aux_cx.document_inner(&aux_path, &root_out_dir, kind); if !auxres.status.success() { return auxres; } @@ -1063,7 +1055,7 @@ impl<'test> TestCx<'test> { }; let mut rustdoc = Command::new(rustdoc_path); - let current_dir = output_base_dir(self.config, root_testpaths, self.safe_revision()); + let current_dir = self.output_base_dir(); rustdoc.current_dir(current_dir); rustdoc .arg("-L") @@ -1091,7 +1083,7 @@ impl<'test> TestCx<'test> { rustdoc.arg(format!("-Clinker={}", linker)); } - self.compose_and_run_compiler(rustdoc, None, root_testpaths) + self.compose_and_run_compiler(rustdoc, None) } fn exec_compiled_test(&self) -> ProcRes { @@ -1206,9 +1198,14 @@ impl<'test> TestCx<'test> { /// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary` /// directory relative to the test itself (not any intermediate auxiliaries). - fn compute_aux_test_paths(&self, of: &TestPaths, rel_ab: &str) -> Utf8PathBuf { - let test_ab = - of.file.parent().expect("test file path has no parent").join("auxiliary").join(rel_ab); + fn compute_aux_test_paths(&self, rel_ab: &str) -> Utf8PathBuf { + let test_ab = self + .testpaths + .file + .parent() + .expect("test file path has no parent") + .join("auxiliary") + .join(rel_ab); if !test_ab.exists() { self.fatal(&format!("aux-build `{}` source not found", test_ab)) } @@ -1259,13 +1256,13 @@ impl<'test> TestCx<'test> { aux_dir } - fn build_all_auxiliary(&self, of: &TestPaths, aux_dir: &Utf8Path, rustc: &mut Command) { + fn build_all_auxiliary(&self, aux_dir: &Utf8Path, rustc: &mut Command) { for rel_ab in &self.props.aux.builds { - self.build_auxiliary(of, rel_ab, &aux_dir, None); + self.build_auxiliary(rel_ab, &aux_dir, None); } for rel_ab in &self.props.aux.bins { - self.build_auxiliary(of, rel_ab, &aux_dir, Some(AuxType::Bin)); + self.build_auxiliary(rel_ab, &aux_dir, Some(AuxType::Bin)); } let path_to_crate_name = |path: &str| -> String { @@ -1284,12 +1281,12 @@ impl<'test> TestCx<'test> { }; for (aux_name, aux_path) in &self.props.aux.crates { - let aux_type = self.build_auxiliary(of, &aux_path, &aux_dir, None); + let aux_type = self.build_auxiliary(&aux_path, &aux_dir, None); add_extern(rustc, aux_name, aux_path, aux_type); } for proc_macro in &self.props.aux.proc_macros { - self.build_auxiliary(of, proc_macro, &aux_dir, Some(AuxType::ProcMacro)); + self.build_auxiliary(proc_macro, &aux_dir, Some(AuxType::ProcMacro)); let crate_name = path_to_crate_name(proc_macro); add_extern(rustc, &crate_name, proc_macro, AuxType::ProcMacro); } @@ -1297,7 +1294,7 @@ impl<'test> TestCx<'test> { // Build any `//@ aux-codegen-backend`, and pass the resulting library // to `-Zcodegen-backend` when compiling the test file. if let Some(aux_file) = &self.props.aux.codegen_backend { - let aux_type = self.build_auxiliary(of, aux_file, aux_dir, None); + let aux_type = self.build_auxiliary(aux_file, aux_dir, None); if let Some(lib_name) = get_lib_name(aux_file.trim_end_matches(".rs"), aux_type) { let lib_path = aux_dir.join(&lib_name); rustc.arg(format!("-Zcodegen-backend={}", lib_path)); @@ -1307,12 +1304,7 @@ impl<'test> TestCx<'test> { /// `root_testpaths` refers to the path of the original test. the auxiliary and the test with an /// aux-build have the same `root_testpaths`. - fn compose_and_run_compiler( - &self, - mut rustc: Command, - input: Option, - root_testpaths: &TestPaths, - ) -> ProcRes { + fn compose_and_run_compiler(&self, mut rustc: Command, input: Option) -> ProcRes { if self.props.add_core_stubs { let minicore_path = self.build_minicore(); rustc.arg("--extern"); @@ -1320,7 +1312,7 @@ impl<'test> TestCx<'test> { } let aux_dir = self.aux_output_dir(); - self.build_all_auxiliary(root_testpaths, &aux_dir, &mut rustc); + self.build_all_auxiliary(&aux_dir, &mut rustc); rustc.envs(self.props.rustc_env.clone()); self.props.unset_rustc_env.iter().fold(&mut rustc, Command::env_remove); @@ -1365,12 +1357,11 @@ impl<'test> TestCx<'test> { /// If `aux_type` is `None`, then this will determine the aux-type automatically. fn build_auxiliary( &self, - of: &TestPaths, source_path: &str, aux_dir: &Utf8Path, aux_type: Option, ) -> AuxType { - let aux_path = self.compute_aux_test_paths(of, source_path); + let aux_path = self.compute_aux_test_paths(source_path); let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config); if aux_type == Some(AuxType::ProcMacro) { aux_props.force_host = true; @@ -1401,7 +1392,7 @@ impl<'test> TestCx<'test> { LinkToAux::No, Vec::new(), ); - aux_cx.build_all_auxiliary(of, &aux_dir, &mut aux_rustc); + aux_cx.build_all_auxiliary(&aux_dir, &mut aux_rustc); aux_rustc.envs(aux_props.rustc_env.clone()); for key in &aux_props.unset_rustc_env { @@ -2126,7 +2117,7 @@ impl<'test> TestCx<'test> { Vec::new(), ); - let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths); + let proc_res = self.compose_and_run_compiler(rustc, None); (proc_res, output_path) } @@ -2204,9 +2195,9 @@ impl<'test> TestCx<'test> { Vec::new(), ); let aux_dir = new_rustdoc.aux_output_dir(); - new_rustdoc.build_all_auxiliary(&new_rustdoc.testpaths, &aux_dir, &mut rustc); + new_rustdoc.build_all_auxiliary(&aux_dir, &mut rustc); - let proc_res = new_rustdoc.document(&compare_dir, &new_rustdoc.testpaths, DocKind::Html); + let proc_res = new_rustdoc.document(&compare_dir, DocKind::Html); if !proc_res.status.success() { writeln!(self.stderr, "failed to run nightly rustdoc"); return; diff --git a/src/tools/compiletest/src/runtest/assembly.rs b/src/tools/compiletest/src/runtest/assembly.rs index 91d4f620f7194..c805b4c7a59e0 100644 --- a/src/tools/compiletest/src/runtest/assembly.rs +++ b/src/tools/compiletest/src/runtest/assembly.rs @@ -43,7 +43,7 @@ impl TestCx<'_> { Vec::new(), ); - let proc_res = self.compose_and_run_compiler(rustc, None, self.testpaths); + let proc_res = self.compose_and_run_compiler(rustc, None); (proc_res, output_path) } } diff --git a/src/tools/compiletest/src/runtest/coverage.rs b/src/tools/compiletest/src/runtest/coverage.rs index d0a0c960b4512..5b94d9567d8fc 100644 --- a/src/tools/compiletest/src/runtest/coverage.rs +++ b/src/tools/compiletest/src/runtest/coverage.rs @@ -197,7 +197,7 @@ impl<'test> TestCx<'test> { rustdoc_cmd.arg(&self.testpaths.file); - let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None, self.testpaths); + let proc_res = self.compose_and_run_compiler(rustdoc_cmd, None); if !proc_res.status.success() { self.fatal_proc_rec("rustdoc --test failed!", &proc_res) } diff --git a/src/tools/compiletest/src/runtest/js_doc.rs b/src/tools/compiletest/src/runtest/js_doc.rs index 93b05617e6f8c..e7e078ff27d9e 100644 --- a/src/tools/compiletest/src/runtest/js_doc.rs +++ b/src/tools/compiletest/src/runtest/js_doc.rs @@ -7,7 +7,7 @@ impl TestCx<'_> { if let Some(nodejs) = &self.config.nodejs { let out_dir = self.output_base_dir(); - self.document(&out_dir, &self.testpaths, DocKind::Html); + self.document(&out_dir, DocKind::Html); let file_stem = self.testpaths.file.file_stem().expect("no file stem"); let res = self.run_command_to_procres( diff --git a/src/tools/compiletest/src/runtest/rustdoc.rs b/src/tools/compiletest/src/runtest/rustdoc.rs index 32b1823961bea..a4558de5f1c0c 100644 --- a/src/tools/compiletest/src/runtest/rustdoc.rs +++ b/src/tools/compiletest/src/runtest/rustdoc.rs @@ -11,7 +11,7 @@ impl TestCx<'_> { panic!("failed to remove and recreate output directory `{out_dir}`: {e}") }); - let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Html); + let proc_res = self.document(&out_dir, DocKind::Html); if !proc_res.status.success() { self.fatal_proc_rec("rustdoc failed!", &proc_res); } diff --git a/src/tools/compiletest/src/runtest/rustdoc_json.rs b/src/tools/compiletest/src/runtest/rustdoc_json.rs index dd7ebe9efaeef..6cb0c2a040535 100644 --- a/src/tools/compiletest/src/runtest/rustdoc_json.rs +++ b/src/tools/compiletest/src/runtest/rustdoc_json.rs @@ -13,7 +13,7 @@ impl TestCx<'_> { panic!("failed to remove and recreate output directory `{out_dir}`: {e}") }); - let proc_res = self.document(&out_dir, &self.testpaths, DocKind::Json); + let proc_res = self.document(&out_dir, DocKind::Json); if !proc_res.status.success() { self.fatal_proc_rec("rustdoc failed!", &proc_res); } diff --git a/src/tools/compiletest/src/runtest/ui.rs b/src/tools/compiletest/src/runtest/ui.rs index d683a325c8666..2bbde95dba54c 100644 --- a/src/tools/compiletest/src/runtest/ui.rs +++ b/src/tools/compiletest/src/runtest/ui.rs @@ -249,7 +249,7 @@ impl TestCx<'_> { rustc.arg(crate_name); } - let res = self.compose_and_run_compiler(rustc, None, self.testpaths); + let res = self.compose_and_run_compiler(rustc, None); if !res.status.success() { self.fatal_proc_rec("failed to compile fixed code", &res); } From 720bfff17132a6295df26d62b7db8b8262b328e4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Tue, 28 Oct 2025 17:58:10 +1100 Subject: [PATCH 05/15] Rename `compute_aux_paths` to `resolve_aux_path` This method no longer returns a `TestPaths`, so the old name is no longer appropriate. --- src/tools/compiletest/src/runtest.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 6696662c7a091..84806ffb66c72 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1015,7 +1015,7 @@ impl<'test> TestCx<'test> { assert_eq!(kind, DocKind::Html, "build-aux-docs only make sense for html output"); for rel_ab in &self.props.aux.builds { - let aux_path = self.compute_aux_test_paths(rel_ab); + let aux_path = self.resolve_aux_path(rel_ab); let props_for_aux = self.props.from_aux_file(&aux_path, self.revision, self.config); let aux_cx = TestCx { config: self.config, @@ -1198,19 +1198,21 @@ impl<'test> TestCx<'test> { /// For each `aux-build: foo/bar` annotation, we check to find the file in an `auxiliary` /// directory relative to the test itself (not any intermediate auxiliaries). - fn compute_aux_test_paths(&self, rel_ab: &str) -> Utf8PathBuf { - let test_ab = self + fn resolve_aux_path(&self, relative_aux_path: &str) -> Utf8PathBuf { + let aux_path = self .testpaths .file .parent() .expect("test file path has no parent") .join("auxiliary") - .join(rel_ab); - if !test_ab.exists() { - self.fatal(&format!("aux-build `{}` source not found", test_ab)) + .join(relative_aux_path); + if !aux_path.exists() { + self.fatal(&format!( + "auxiliary source file `{relative_aux_path}` not found at `{aux_path}`" + )); } - test_ab + aux_path } fn is_vxworks_pure_static(&self) -> bool { @@ -1361,7 +1363,7 @@ impl<'test> TestCx<'test> { aux_dir: &Utf8Path, aux_type: Option, ) -> AuxType { - let aux_path = self.compute_aux_test_paths(source_path); + let aux_path = self.resolve_aux_path(source_path); let mut aux_props = self.props.from_aux_file(&aux_path, self.revision, self.config); if aux_type == Some(AuxType::ProcMacro) { aux_props.force_host = true; From 48f8f2358e8b7b5e8940d45aed8fe853d1c9a15d Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Wed, 29 Oct 2025 12:58:55 +0000 Subject: [PATCH 06/15] Remove a special case for rust_eh_personality from reachable_non_generics It doesn't seem like this special case is necessary anymore and if it still is anyway, it should probably be moved to cg_llvm's prepare_lto instead. --- compiler/rustc_codegen_ssa/src/back/symbol_export.rs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 5bc18e2d7f8bb..8a1f20826a946 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -104,10 +104,6 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap, _: LocalCrate) -> DefIdMap Date: Wed, 29 Oct 2025 13:06:24 +0000 Subject: [PATCH 07/15] Remove special case for the panic runtime from reachable_non_generics The panic runtime uses #[rustc_std_internal_symbol] which has the same effect as this special case with respect to symbol visibility. --- .../rustc_codegen_ssa/src/back/symbol_export.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs index 8a1f20826a946..d9ba5017a422d 100644 --- a/compiler/rustc_codegen_ssa/src/back/symbol_export.rs +++ b/compiler/rustc_codegen_ssa/src/back/symbol_export.rs @@ -51,15 +51,7 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap = tcx .reachable_set(()) @@ -104,7 +96,12 @@ fn reachable_non_generics_provider(tcx: TyCtxt<'_>, _: LocalCrate) -> DefIdMap Date: Wed, 29 Oct 2025 09:33:38 -0400 Subject: [PATCH 08/15] Add tests to demonstrate explicit tail call bug --- .../explicit-tail-calls/become-cast-return.rs | 22 +++++++++++++++++++ .../become-indirect-return.rs | 21 ++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 tests/ui/explicit-tail-calls/become-cast-return.rs create mode 100644 tests/ui/explicit-tail-calls/become-indirect-return.rs diff --git a/tests/ui/explicit-tail-calls/become-cast-return.rs b/tests/ui/explicit-tail-calls/become-cast-return.rs new file mode 100644 index 0000000000000..3052886d7b8f8 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-cast-return.rs @@ -0,0 +1,22 @@ +//@ check-pass +//@ ignore-backends: gcc +//@ known-bug: #148239 +//@ compile-flags: -Zno-codegen +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[inline(never)] +fn leaf(_: &Box) -> [u8; 1] { + [1] +} + +#[inline(never)] +fn dispatch(param: &Box) -> [u8; 1] { + become leaf(param) +} + +fn main() { + let data = Box::new(0); + let out = dispatch(&data); + assert_eq!(out, [1]); +} diff --git a/tests/ui/explicit-tail-calls/become-indirect-return.rs b/tests/ui/explicit-tail-calls/become-indirect-return.rs new file mode 100644 index 0000000000000..c94683d15f40b --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-indirect-return.rs @@ -0,0 +1,21 @@ +//@ run-pass +//@ ignore-backends: gcc +//@ known-bug: #148239 +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[inline(never)] +fn op_dummy(_param: &Box) -> [u8; 24] { + [1; 24] +} + +#[inline(never)] +fn dispatch(param: &Box) -> [u8; 24] { + become op_dummy(param) +} + +fn main() { + let param = Box::new(0); + let result = dispatch(¶m); + assert_ne!(result, [1; 24]); // the data is not right! +} From 52959a85cca72bdacaae9793005ff7cc7af43762 Mon Sep 17 00:00:00 2001 From: "Mark Z. Ding" Date: Wed, 29 Oct 2025 09:38:56 -0400 Subject: [PATCH 09/15] Fix musttail returns for cast/indirect ABIs --- compiler/rustc_codegen_llvm/src/builder.rs | 6 +----- compiler/rustc_codegen_ssa/src/mir/block.rs | 12 +++++++++++- tests/ui/explicit-tail-calls/become-cast-return.rs | 4 +--- .../ui/explicit-tail-calls/become-indirect-return.rs | 3 +-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/compiler/rustc_codegen_llvm/src/builder.rs b/compiler/rustc_codegen_llvm/src/builder.rs index c082a82306848..49d38e05c8b06 100644 --- a/compiler/rustc_codegen_llvm/src/builder.rs +++ b/compiler/rustc_codegen_llvm/src/builder.rs @@ -16,7 +16,6 @@ use rustc_codegen_ssa::mir::place::PlaceRef; use rustc_codegen_ssa::traits::*; use rustc_data_structures::small_c_str::SmallCStr; use rustc_hir::def_id::DefId; -use rustc_middle::bug; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs; use rustc_middle::ty::layout::{ FnAbiError, FnAbiOfHelpers, FnAbiRequest, HasTypingEnv, LayoutError, LayoutOfHelpers, @@ -1458,10 +1457,7 @@ impl<'a, 'll, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> { match &fn_abi.ret.mode { PassMode::Ignore | PassMode::Indirect { .. } => self.ret_void(), - PassMode::Direct(_) | PassMode::Pair { .. } => self.ret(call), - mode @ PassMode::Cast { .. } => { - bug!("Encountered `PassMode::{mode:?}` during codegen") - } + PassMode::Direct(_) | PassMode::Pair { .. } | PassMode::Cast { .. } => self.ret(call), } } diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index e2241a77d186c..0d1e27a34dc5b 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -1063,7 +1063,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let return_dest = self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs); target.map(|target| (return_dest, target)) } - CallKind::Tail => None, + CallKind::Tail => { + if fn_abi.ret.is_indirect() { + match self.make_return_dest(bx, destination, &fn_abi.ret, &mut llargs) { + ReturnDest::Nothing => {} + _ => bug!( + "tail calls to functions with indirect returns cannot store into a destination" + ), + } + } + None + } }; // Split the rust-call tupled arguments off. diff --git a/tests/ui/explicit-tail-calls/become-cast-return.rs b/tests/ui/explicit-tail-calls/become-cast-return.rs index 3052886d7b8f8..212a0ddcbca15 100644 --- a/tests/ui/explicit-tail-calls/become-cast-return.rs +++ b/tests/ui/explicit-tail-calls/become-cast-return.rs @@ -1,7 +1,5 @@ -//@ check-pass +//@ run-pass //@ ignore-backends: gcc -//@ known-bug: #148239 -//@ compile-flags: -Zno-codegen #![expect(incomplete_features)] #![feature(explicit_tail_calls)] diff --git a/tests/ui/explicit-tail-calls/become-indirect-return.rs b/tests/ui/explicit-tail-calls/become-indirect-return.rs index c94683d15f40b..7eec34f3b95c9 100644 --- a/tests/ui/explicit-tail-calls/become-indirect-return.rs +++ b/tests/ui/explicit-tail-calls/become-indirect-return.rs @@ -1,6 +1,5 @@ //@ run-pass //@ ignore-backends: gcc -//@ known-bug: #148239 #![expect(incomplete_features)] #![feature(explicit_tail_calls)] @@ -17,5 +16,5 @@ fn dispatch(param: &Box) -> [u8; 24] { fn main() { let param = Box::new(0); let result = dispatch(¶m); - assert_ne!(result, [1; 24]); // the data is not right! + assert_eq!(result, [1; 24]); } From cac6f8760a6abca336a81f28e5508ebf4ca6f693 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Wed, 23 Jul 2025 11:50:21 +0000 Subject: [PATCH 10/15] Do not emit solver errors that contain error types --- compiler/rustc_infer/src/traits/project.rs | 3 +- .../src/error_reporting/traits/mod.rs | 7 +- .../rustc_trait_selection/src/traits/mod.rs | 5 +- .../invalid_const_in_lifetime_position.rs | 5 - .../invalid_const_in_lifetime_position.stderr | 85 +--------- .../generic_const_exprs/issue-102768.rs | 5 - .../generic_const_exprs/issue-102768.stderr | 85 +--------- .../gat-in-trait-path-undeclared-lifetime.rs | 3 - ...t-in-trait-path-undeclared-lifetime.stderr | 38 +---- .../gat-trait-path-parenthesised-args.rs | 9 -- .../gat-trait-path-parenthesised-args.stderr | 145 +----------------- .../generic-associated-types/issue-67510.rs | 1 - .../issue-67510.stderr | 21 +-- .../generic-associated-types/issue-71176.rs | 4 - .../issue-71176.stderr | 73 +-------- .../missing_lifetime_args.rs | 3 - .../missing_lifetime_args.stderr | 59 +------ .../trait-path-type-error-once-implemented.rs | 5 - ...it-path-type-error-once-implemented.stderr | 85 +--------- tests/ui/layout/issue-84108.rs | 2 - tests/ui/layout/issue-84108.stderr | 23 +-- .../next-solver/issue-118950-root-region.rs | 2 - .../issue-118950-root-region.stderr | 25 +-- tests/ui/transmutability/issue-101739-1.rs | 1 - .../ui/transmutability/issue-101739-1.stderr | 11 +- 25 files changed, 35 insertions(+), 670 deletions(-) diff --git a/compiler/rustc_infer/src/traits/project.rs b/compiler/rustc_infer/src/traits/project.rs index 9082db4f4488c..9dd35b6de3080 100644 --- a/compiler/rustc_infer/src/traits/project.rs +++ b/compiler/rustc_infer/src/traits/project.rs @@ -2,6 +2,7 @@ use rustc_data_structures::snapshot_map::{self, SnapshotMapRef, SnapshotMapStorage}; use rustc_data_structures::undo_log::Rollback; +use rustc_macros::TypeVisitable; use rustc_middle::traits::EvaluationResult; use rustc_middle::ty; use tracing::{debug, info}; @@ -12,7 +13,7 @@ use crate::infer::snapshot::undo_log::InferCtxtUndoLogs; pub(crate) type UndoLog<'tcx> = snapshot_map::UndoLog, ProjectionCacheEntry<'tcx>>; -#[derive(Clone)] +#[derive(Clone, TypeVisitable)] pub struct MismatchedProjectionTypes<'tcx> { pub err: ty::error::TypeError<'tcx>, } diff --git a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs index ded5969e83c5c..58e220cfbe7d8 100644 --- a/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/error_reporting/traits/mod.rs @@ -20,7 +20,7 @@ use rustc_infer::traits::{ PredicateObligation, SelectionError, }; use rustc_middle::ty::print::{PrintTraitRefExt as _, with_no_trimmed_paths}; -use rustc_middle::ty::{self, Ty, TyCtxt}; +use rustc_middle::ty::{self, Ty, TyCtxt, TypeVisitableExt as _}; use rustc_span::{DesugaringKind, ErrorGuaranteed, ExpnKind, Span}; use tracing::{info, instrument}; @@ -253,7 +253,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> { for from_expansion in [false, true] { for (error, suppressed) in iter::zip(&errors, &is_suppressed) { - if !suppressed && error.obligation.cause.span.from_expansion() == from_expansion { + if !suppressed + && error.obligation.cause.span.from_expansion() == from_expansion + && !error.references_error() + { let guar = self.report_fulfillment_error(error); self.infcx.set_tainted_by_errors(guar); reported = Some(guar); diff --git a/compiler/rustc_trait_selection/src/traits/mod.rs b/compiler/rustc_trait_selection/src/traits/mod.rs index 0f3b38ef66751..308d533e68991 100644 --- a/compiler/rustc_trait_selection/src/traits/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/mod.rs @@ -29,6 +29,7 @@ use std::ops::ControlFlow; use rustc_errors::ErrorGuaranteed; use rustc_hir::def::DefKind; pub use rustc_infer::traits::*; +use rustc_macros::TypeVisitable; use rustc_middle::query::Providers; use rustc_middle::span_bug; use rustc_middle::ty::error::{ExpectedFound, TypeError}; @@ -75,7 +76,7 @@ use crate::infer::{InferCtxt, TyCtxtInferExt}; use crate::regions::InferCtxtRegionExt; use crate::traits::query::evaluate_obligation::InferCtxtExt as _; -#[derive(Debug)] +#[derive(Debug, TypeVisitable)] pub struct FulfillmentError<'tcx> { pub obligation: PredicateObligation<'tcx>, pub code: FulfillmentErrorCode<'tcx>, @@ -107,7 +108,7 @@ impl<'tcx> FulfillmentError<'tcx> { } } -#[derive(Clone)] +#[derive(Clone, TypeVisitable)] pub enum FulfillmentErrorCode<'tcx> { /// Inherently impossible to fulfill; this trait is implemented if and only /// if it is already implemented. diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs index 427c84679ba1c..c3f4fd63bac70 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.rs @@ -4,8 +4,3 @@ trait X { fn f<'a>(arg : Box = &'a ()>>) {} //~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 0 generic arguments but 1 generic argument -//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments -//~| ERROR associated type takes 0 generic arguments but 1 generic argument -//~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments -//~| ERROR associated type takes 0 generic arguments but 1 generic argument -//~| ERROR trait `X` is not dyn compatible diff --git a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr index 2c25589a55314..a29cf5bf5ad92 100644 --- a/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr +++ b/tests/rustdoc-ui/invalid_const_in_lifetime_position.stderr @@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters LL | type Y<'a>; | ^ -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/invalid_const_in_lifetime_position.rs:4:26 - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/invalid_const_in_lifetime_position.rs:2:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/invalid_const_in_lifetime_position.rs:4:26 - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/invalid_const_in_lifetime_position.rs:2:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/invalid_const_in_lifetime_position.rs:4:26 - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/invalid_const_in_lifetime_position.rs:2:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/invalid_const_in_lifetime_position.rs:4:26 - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/invalid_const_in_lifetime_position.rs:2:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/invalid_const_in_lifetime_position.rs:4:20 - | -LL | fn f<'a>(arg : Box = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/invalid_const_in_lifetime_position.rs:2:10 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/const-generics/generic_const_exprs/issue-102768.rs b/tests/ui/const-generics/generic_const_exprs/issue-102768.rs index 882b27a418e55..18a9b53cf7681 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-102768.rs +++ b/tests/ui/const-generics/generic_const_exprs/issue-102768.rs @@ -9,11 +9,6 @@ const _: () = { fn f2<'a>(arg: Box = &'a ()>>) {} //~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR `X` is not dyn compatible }; fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr index 57b61006631f9..8e972100173f8 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-102768.stderr @@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters LL | type Y<'a>; | ^ -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/issue-102768.rs:9:30 - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-102768.rs:5:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/issue-102768.rs:9:30 - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/issue-102768.rs:5:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/issue-102768.rs:9:30 - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-102768.rs:5:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/issue-102768.rs:9:30 - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/issue-102768.rs:5:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/issue-102768.rs:9:24 - | -LL | fn f2<'a>(arg: Box = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/issue-102768.rs:5:10 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs index b02739a7d0acb..86b164ba7d8a8 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs +++ b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.rs @@ -6,7 +6,4 @@ fn main() { fn _f(arg : Box X = &'a [u32]>>) {} //~^ ERROR: use of undeclared lifetime name `'x` //~| ERROR: binding for associated type `Y` references lifetime - //~| ERROR: binding for associated type `Y` references lifetime - //~| ERROR: binding for associated type `Y` references lifetime - //~| ERROR: the trait `X` is not dyn compatible } diff --git a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr index c9b46de5c33c4..b77f10084c928 100644 --- a/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr +++ b/tests/ui/generic-associated-types/gat-in-trait-path-undeclared-lifetime.stderr @@ -20,39 +20,7 @@ error[E0582]: binding for associated type `Y` references lifetime `'a`, which do LL | fn _f(arg : Box X = &'a [u32]>>) {} | ^^^^^^^^^^^^^^^^^ -error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:33 - | -LL | fn _f(arg : Box X = &'a [u32]>>) {} - | ^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0582]: binding for associated type `Y` references lifetime `'a`, which does not appear in the trait input types - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:33 - | -LL | fn _f(arg : Box X = &'a [u32]>>) {} - | ^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:6:19 - | -LL | fn _f(arg : Box X = &'a [u32]>>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/gat-in-trait-path-undeclared-lifetime.rs:2:8 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'x>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0261, E0582. -For more information about an error, try `rustc --explain E0038`. +Some errors have detailed explanations: E0261, E0582. +For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs index 294fb6743fbcd..22f4918fb1919 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs +++ b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.rs @@ -7,19 +7,10 @@ fn foo<'a>(arg: Box>) {} //~| ERROR: parenthesized generic arguments cannot be used //~| ERROR associated type takes 0 generic arguments but 1 generic argument //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR at least one trait is required - //~| ERROR: the trait `X` is not dyn compatible fn bar<'a>(arg: Box>) {} //~^ ERROR: parenthesized generic arguments cannot be used //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR: the trait `X` is not dyn compatible fn main() {} diff --git a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr index e18d8198c9455..23199fae28b59 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-parenthesised-args.stderr @@ -22,7 +22,7 @@ LL + fn foo<'a>(arg: Box = &'a ()>>) {} | error: parenthesized generic arguments cannot be used in associated type constraints - --> $DIR/gat-trait-path-parenthesised-args.rs:18:27 + --> $DIR/gat-trait-path-parenthesised-args.rs:12:27 | LL | fn bar<'a>(arg: Box>) {} | ^-- @@ -60,109 +60,7 @@ LL | type Y<'a>; | ^ error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:27 - | -LL | fn foo<'a>(arg: Box>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn foo<'a>(arg: Box>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:27 - | -LL | fn foo<'a>(arg: Box>) {} - | ^---- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:27 - | -LL | fn foo<'a>(arg: Box>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn foo<'a>(arg: Box>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:5:27 - | -LL | fn foo<'a>(arg: Box>) {} - | ^---- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0224]: at least one trait is required for an object type - --> $DIR/gat-trait-path-parenthesised-args.rs:5:29 - | -LL | fn foo<'a>(arg: Box>) {} - | ^^ - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/gat-trait-path-parenthesised-args.rs:5:21 - | -LL | fn foo<'a>(arg: Box>) {} - | ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:18:27 - | -LL | fn bar<'a>(arg: Box>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ -- -help: add missing lifetime argument - | -LL | fn bar<'a>(arg: Box>) {} - | ++ - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:18:27 + --> $DIR/gat-trait-path-parenthesised-args.rs:12:27 | LL | fn bar<'a>(arg: Box>) {} | ^ expected 1 lifetime argument @@ -172,46 +70,11 @@ note: associated type defined here, with 1 lifetime parameter: `'a` | LL | type Y<'a>; | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: add missing lifetime argument | LL | fn bar<'a>(arg: Box>) {} | ++ -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/gat-trait-path-parenthesised-args.rs:18:27 - | -LL | fn bar<'a>(arg: Box>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn bar<'a>(arg: Box>) {} - | ++ - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/gat-trait-path-parenthesised-args.rs:18:21 - | -LL | fn bar<'a>(arg: Box>) {} - | ^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/gat-trait-path-parenthesised-args.rs:2:8 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 15 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0038, E0107, E0224. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/generic-associated-types/issue-67510.rs b/tests/ui/generic-associated-types/issue-67510.rs index 5c3150a77ed1b..2db9fb82aaec4 100644 --- a/tests/ui/generic-associated-types/issue-67510.rs +++ b/tests/ui/generic-associated-types/issue-67510.rs @@ -5,6 +5,5 @@ trait X { fn f(x: Box = &'a ()>>) {} //~^ ERROR: use of undeclared lifetime name `'a` //~| ERROR: use of undeclared lifetime name `'a` -//~| ERROR: the trait `X` is not dyn compatible [E0038] fn main() {} diff --git a/tests/ui/generic-associated-types/issue-67510.stderr b/tests/ui/generic-associated-types/issue-67510.stderr index f5c494788ea58..34d867621d7e0 100644 --- a/tests/ui/generic-associated-types/issue-67510.stderr +++ b/tests/ui/generic-associated-types/issue-67510.stderr @@ -29,23 +29,6 @@ help: consider introducing lifetime `'a` here LL | fn f<'a>(x: Box = &'a ()>>) {} | ++++ -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/issue-67510.rs:5:13 - | -LL | fn f(x: Box = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/issue-67510.rs:2:10 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0261. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/generic-associated-types/issue-71176.rs b/tests/ui/generic-associated-types/issue-71176.rs index 8ecfa93750d48..f0e162d825f9d 100644 --- a/tests/ui/generic-associated-types/issue-71176.rs +++ b/tests/ui/generic-associated-types/issue-71176.rs @@ -9,14 +9,10 @@ impl Provider for () { struct Holder { inner: Box>, //~^ ERROR: missing generics for associated type - //~| ERROR: missing generics for associated type - //~| ERROR: missing generics for associated type - //~| ERROR: the trait `Provider` is not dyn compatible } fn main() { Holder { inner: Box::new(()), - //~^ ERROR: the trait `Provider` is not dyn compatible }; } diff --git a/tests/ui/generic-associated-types/issue-71176.stderr b/tests/ui/generic-associated-types/issue-71176.stderr index f231056a2eed8..ed837f3475338 100644 --- a/tests/ui/generic-associated-types/issue-71176.stderr +++ b/tests/ui/generic-associated-types/issue-71176.stderr @@ -14,75 +14,6 @@ help: add missing lifetime argument LL | inner: Box = B>>, | ++++ -error[E0107]: missing generics for associated type `Provider::A` - --> $DIR/issue-71176.rs:10:27 - | -LL | inner: Box>, - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-71176.rs:2:10 - | -LL | type A<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | inner: Box = B>>, - | ++++ - -error[E0107]: missing generics for associated type `Provider::A` - --> $DIR/issue-71176.rs:10:27 - | -LL | inner: Box>, - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/issue-71176.rs:2:10 - | -LL | type A<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | inner: Box = B>>, - | ++++ - -error[E0038]: the trait `Provider` is not dyn compatible - --> $DIR/issue-71176.rs:10:14 - | -LL | inner: Box>, - | ^^^^^^^^^^^^^^^^^^^ `Provider` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/issue-71176.rs:2:10 - | -LL | trait Provider { - | -------- this trait is not dyn compatible... -LL | type A<'a>; - | ^ ...because it contains the generic associated type `A` - = help: consider moving `A` to another trait - = help: only type `()` implements `Provider`; consider using it directly instead. - -error[E0038]: the trait `Provider` is not dyn compatible - --> $DIR/issue-71176.rs:19:16 - | -LL | inner: Box::new(()), - | ^^^^^^^^^^^^ `Provider` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/issue-71176.rs:2:10 - | -LL | trait Provider { - | -------- this trait is not dyn compatible... -LL | type A<'a>; - | ^ ...because it contains the generic associated type `A` - = help: consider moving `A` to another trait - = help: only type `()` implements `Provider`; consider using it directly instead. - -error: aborting due to 5 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/generic-associated-types/missing_lifetime_args.rs b/tests/ui/generic-associated-types/missing_lifetime_args.rs index e0f2db5eb21ed..331511ba61a48 100644 --- a/tests/ui/generic-associated-types/missing_lifetime_args.rs +++ b/tests/ui/generic-associated-types/missing_lifetime_args.rs @@ -10,9 +10,6 @@ struct Foo<'a, 'b, 'c> { fn foo<'c, 'd>(_arg: Box>) {} //~^ ERROR missing generics for associated type -//~| ERROR missing generics for associated type -//~| ERROR missing generics for associated type -//~| ERROR the trait `X` is not dyn compatible fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {} //~^ ERROR struct takes 3 lifetime arguments but 2 lifetime diff --git a/tests/ui/generic-associated-types/missing_lifetime_args.stderr b/tests/ui/generic-associated-types/missing_lifetime_args.stderr index 7b6888817f4f4..1a7a2e787a1a9 100644 --- a/tests/ui/generic-associated-types/missing_lifetime_args.stderr +++ b/tests/ui/generic-associated-types/missing_lifetime_args.stderr @@ -14,58 +14,8 @@ help: add missing lifetime arguments LL | fn foo<'c, 'd>(_arg: Box = (&'c u32, &'d u32)>>) {} | ++++++++ -error[E0107]: missing generics for associated type `X::Y` - --> $DIR/missing_lifetime_args.rs:11:32 - | -LL | fn foo<'c, 'd>(_arg: Box>) {} - | ^ expected 2 lifetime arguments - | -note: associated type defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/missing_lifetime_args.rs:2:10 - | -LL | type Y<'a, 'b>; - | ^ -- -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime arguments - | -LL | fn foo<'c, 'd>(_arg: Box = (&'c u32, &'d u32)>>) {} - | ++++++++ - -error[E0107]: missing generics for associated type `X::Y` - --> $DIR/missing_lifetime_args.rs:11:32 - | -LL | fn foo<'c, 'd>(_arg: Box>) {} - | ^ expected 2 lifetime arguments - | -note: associated type defined here, with 2 lifetime parameters: `'a`, `'b` - --> $DIR/missing_lifetime_args.rs:2:10 - | -LL | type Y<'a, 'b>; - | ^ -- -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime arguments - | -LL | fn foo<'c, 'd>(_arg: Box = (&'c u32, &'d u32)>>) {} - | ++++++++ - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/missing_lifetime_args.rs:11:26 - | -LL | fn foo<'c, 'd>(_arg: Box>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/missing_lifetime_args.rs:2:10 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a, 'b>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - error[E0107]: struct takes 3 lifetime arguments but 2 lifetime arguments were supplied - --> $DIR/missing_lifetime_args.rs:17:26 + --> $DIR/missing_lifetime_args.rs:14:26 | LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b>) {} | ^^^ -- -- supplied 2 lifetime arguments @@ -83,7 +33,7 @@ LL | fn bar<'a, 'b, 'c>(_arg: Foo<'a, 'b, 'a>) {} | ++++ error[E0107]: struct takes 3 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing_lifetime_args.rs:20:16 + --> $DIR/missing_lifetime_args.rs:17:16 | LL | fn f<'a>(_arg: Foo<'a>) {} | ^^^ -- supplied 1 lifetime argument @@ -100,7 +50,6 @@ help: add missing lifetime arguments LL | fn f<'a>(_arg: Foo<'a, 'a, 'a>) {} | ++++++++ -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs index c828691bb3058..c58f9cf1dfc8e 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs +++ b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.rs @@ -6,11 +6,6 @@ const _: () = { fn f2<'a>(arg : Box = &'a ()>>) {} //~^ ERROR associated type takes 1 lifetime argument but 0 lifetime arguments //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR associated type takes 1 lifetime argument but 0 lifetime arguments - //~| ERROR associated type takes 0 generic arguments but 1 generic argument - //~| ERROR the trait `X` is not dyn compatible }; fn main() {} diff --git a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr index 45bca1a76287d..682fa27ab5d65 100644 --- a/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr +++ b/tests/ui/generic-associated-types/parse/trait-path-type-error-once-implemented.stderr @@ -28,87 +28,6 @@ note: associated type defined here, with 0 generic parameters LL | type Y<'a>; | ^ -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/trait-path-type-error-once-implemented.rs:6:29 - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/trait-path-type-error-once-implemented.rs:2:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/trait-path-type-error-once-implemented.rs:6:29 - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/trait-path-type-error-once-implemented.rs:2:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0107]: associated type takes 1 lifetime argument but 0 lifetime arguments were supplied - --> $DIR/trait-path-type-error-once-implemented.rs:6:29 - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^ expected 1 lifetime argument - | -note: associated type defined here, with 1 lifetime parameter: `'a` - --> $DIR/trait-path-type-error-once-implemented.rs:2:10 - | -LL | type Y<'a>; - | ^ -- - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: add missing lifetime argument - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | +++ - -error[E0107]: associated type takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/trait-path-type-error-once-implemented.rs:6:29 - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^--- help: remove the unnecessary generics - | | - | expected 0 generic arguments - | -note: associated type defined here, with 0 generic parameters - --> $DIR/trait-path-type-error-once-implemented.rs:2:10 - | -LL | type Y<'a>; - | ^ - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0038]: the trait `X` is not dyn compatible - --> $DIR/trait-path-type-error-once-implemented.rs:6:23 - | -LL | fn f2<'a>(arg : Box = &'a ()>>) {} - | ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit - --> $DIR/trait-path-type-error-once-implemented.rs:2:10 - | -LL | trait X { - | - this trait is not dyn compatible... -LL | type Y<'a>; - | ^ ...because it contains the generic associated type `Y` - = help: consider moving `Y` to another trait - -error: aborting due to 7 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0038, E0107. -For more information about an error, try `rustc --explain E0038`. +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/layout/issue-84108.rs b/tests/ui/layout/issue-84108.rs index 33884617acbf8..07ff3d3c0e3ee 100644 --- a/tests/ui/layout/issue-84108.rs +++ b/tests/ui/layout/issue-84108.rs @@ -8,8 +8,6 @@ static FOO: (dyn AsRef, u8) = ("hello", 42); const BAR: (&Path, [u8], usize) = ("hello", [], 42); //~^ ERROR cannot find type `Path` in this scope -//~| ERROR the size for values of type `[u8]` cannot be known at compilation time -//~| ERROR the size for values of type `[u8]` cannot be known at compilation time //~| ERROR mismatched types static BAZ: ([u8], usize) = ([], 0); diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr index 62a6ae341fa6e..08acc3d3b2579 100644 --- a/tests/ui/layout/issue-84108.stderr +++ b/tests/ui/layout/issue-84108.stderr @@ -21,16 +21,7 @@ LL + use std::path::Path; | error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/issue-84108.rs:9:12 - | -LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type - -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/issue-84108.rs:15:13 + --> $DIR/issue-84108.rs:13:13 | LL | static BAZ: ([u8], usize) = ([], 0); | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -38,16 +29,6 @@ LL | static BAZ: ([u8], usize) = ([], 0); = help: the trait `Sized` is not implemented for `[u8]` = note: only the last element of a tuple may have a dynamically sized type -error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/issue-84108.rs:9:12 - | -LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); - | ^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u8]` - = note: only the last element of a tuple may have a dynamically sized type - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error[E0308]: mismatched types --> $DIR/issue-84108.rs:9:45 | @@ -57,7 +38,7 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); = note: expected slice `[u8]` found array `[_; 0]` -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0308, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.rs b/tests/ui/traits/next-solver/issue-118950-root-region.rs index fe336766891da..84e2f4c94386d 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.rs +++ b/tests/ui/traits/next-solver/issue-118950-root-region.rs @@ -18,7 +18,5 @@ impl Overlap for T {} impl Overlap fn(Assoc<'a, T>)> for T where Missing: Overlap {} //~^ ERROR cannot find type `Missing` in this scope -//~| ERROR the trait bound `T: Overlap fn(Assoc<'a, T>)>` is not satisfied -//~| ERROR the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied fn main() {} diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index ce4f742a3fa97..e934c5cdc7494 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -26,30 +26,7 @@ LL | trait ToUnit<'a> { | ^^^^^^^^^^^^^^^^ WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a)), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. } -error[E0277]: the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied - --> $DIR/issue-118950-root-region.rs:19:9 - | -LL | impl Overlap fn(Assoc<'a, T>)> for T where Missing: Overlap {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> ToUnit<'a>` is not implemented for `*const T` - | -help: this trait has no implementations, consider adding one - --> $DIR/issue-118950-root-region.rs:8:1 - | -LL | trait ToUnit<'a> { - | ^^^^^^^^^^^^^^^^ - -error[E0277]: the trait bound `T: Overlap fn(Assoc<'a, T>)>` is not satisfied - --> $DIR/issue-118950-root-region.rs:19:47 - | -LL | impl Overlap fn(Assoc<'a, T>)> for T where Missing: Overlap {} - | ^ the trait `Overlap fn(Assoc<'a, T>)>` is not implemented for `T` - | -help: consider further restricting type parameter `T` with trait `Overlap` - | -LL | impl Overlap fn(Assoc<'a, T>)> for T where Missing: Overlap, T: Overlap fn(Assoc<'a, T>)> {} - | ++++++++++++++++++++++++++++++++++++++ - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0277, E0412. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/issue-101739-1.rs b/tests/ui/transmutability/issue-101739-1.rs index b801e2355404c..afd8aba51ce94 100644 --- a/tests/ui/transmutability/issue-101739-1.rs +++ b/tests/ui/transmutability/issue-101739-1.rs @@ -6,7 +6,6 @@ mod assert { pub fn is_transmutable() where Dst: TransmuteFrom, //~ ERROR cannot find type `Dst` in this scope - //~| ERROR the constant `ASSUME_ALIGNMENT` is not of type `Assume` { } } diff --git a/tests/ui/transmutability/issue-101739-1.stderr b/tests/ui/transmutability/issue-101739-1.stderr index b3c640a00b4c4..20bc8af47f8d9 100644 --- a/tests/ui/transmutability/issue-101739-1.stderr +++ b/tests/ui/transmutability/issue-101739-1.stderr @@ -4,15 +4,6 @@ error[E0412]: cannot find type `Dst` in this scope LL | Dst: TransmuteFrom, | ^^^ not found in this scope -error: the constant `ASSUME_ALIGNMENT` is not of type `Assume` - --> $DIR/issue-101739-1.rs:8:14 - | -LL | Dst: TransmuteFrom, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` - | -note: required by a const generic parameter in `TransmuteFrom` - --> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0412`. From 0efeec580a9cfa426e965af35747cef74d19191c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Esteban=20K=C3=BCber?= Date: Sun, 28 Sep 2025 23:04:50 +0000 Subject: [PATCH 11/15] Mention crate being analysized in query description "running analysis passes on this crate" -> "running analysis passes on crate `foo`" This message is displayed in cycle errors in particular, and in some cases without any spans or any other identifiable information to determine which dependency introduced the cycle. --- compiler/rustc_middle/src/query/mod.rs | 5 ++++- .../issue-24949-assoc-const-static-recursion-trait.stderr | 2 +- tests/ui/consts/const-eval/const-eval-query-stack.stderr | 2 +- tests/ui/consts/recursive-zst-static.default.stderr | 2 +- tests/ui/consts/recursive-zst-static.unleash.stderr | 2 +- tests/ui/track-diagnostics/track.stderr | 2 +- tests/ui/treat-err-as-bug/err.stderr | 2 +- 7 files changed, 10 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 30d4cc8b3c8d6..db2e252f9406a 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -397,7 +397,10 @@ rustc_queries! { /// The root query triggering all analysis passes like typeck or borrowck. query analysis(key: ()) { eval_always - desc { "running analysis passes on this crate" } + desc { |tcx| + "running analysis passes on crate `{}`", + tcx.crate_name(LOCAL_CRATE), + } } /// This query checks the fulfillment of collected lint expectations. diff --git a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr index 317af7975aa7e..8197cfcba5025 100644 --- a/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr +++ b/tests/ui/associated-consts/issue-24949-assoc-const-static-recursion-trait.stderr @@ -30,7 +30,7 @@ note: ...which requires elaborating drops for ` Date: Fri, 24 Oct 2025 17:03:26 +1100 Subject: [PATCH 12/15] Separate debugger discovery from debugger version-query --- src/tools/compiletest/src/debuggers.rs | 32 +++++++++++++------------- src/tools/compiletest/src/lib.rs | 7 +++--- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/tools/compiletest/src/debuggers.rs b/src/tools/compiletest/src/debuggers.rs index 8afe3289fa45a..93f27fb90951c 100644 --- a/src/tools/compiletest/src/debuggers.rs +++ b/src/tools/compiletest/src/debuggers.rs @@ -103,22 +103,19 @@ fn find_cdb(target: &str) -> Option { } /// Returns Path to CDB -pub(crate) fn analyze_cdb( - cdb: Option, - target: &str, -) -> (Option, Option<[u16; 4]>) { +pub(crate) fn discover_cdb(cdb: Option, target: &str) -> Option { let cdb = cdb.map(Utf8PathBuf::from).or_else(|| find_cdb(target)); + cdb +} +pub(crate) fn query_cdb_version(cdb: &Utf8Path) -> Option<[u16; 4]> { let mut version = None; - if let Some(cdb) = cdb.as_ref() { - if let Ok(output) = Command::new(cdb).arg("/version").output() { - if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() { - version = extract_cdb_version(&first_line); - } + if let Ok(output) = Command::new(cdb).arg("/version").output() { + if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() { + version = extract_cdb_version(&first_line); } } - - (cdb, version) + version } pub(crate) fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> { @@ -132,12 +129,11 @@ pub(crate) fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> { Some([major, minor, patch, build]) } -/// Returns (Path to GDB, GDB Version) -pub(crate) fn analyze_gdb( +pub(crate) fn discover_gdb( gdb: Option, target: &str, android_cross_path: &Utf8Path, -) -> (Option, Option) { +) -> Option { #[cfg(not(windows))] const GDB_FALLBACK: &str = "gdb"; #[cfg(windows)] @@ -159,6 +155,10 @@ pub(crate) fn analyze_gdb( Some(ref s) => s.to_owned(), }; + Some(gdb) +} + +pub(crate) fn query_gdb_version(gdb: &str) -> Option { let mut version_line = None; if let Ok(output) = Command::new(&gdb).arg("--version").output() { if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() { @@ -168,10 +168,10 @@ pub(crate) fn analyze_gdb( let version = match version_line { Some(line) => extract_gdb_version(&line), - None => return (None, None), + None => return None, }; - (Some(gdb), version) + version } pub(crate) fn extract_gdb_version(full_version_line: &str) -> Option { diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index b524017e4dadd..89f5623c1fc99 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -258,10 +258,11 @@ fn parse_config(args: Vec) -> Config { let target = opt_str2(matches.opt_str("target")); let android_cross_path = opt_path(matches, "android-cross-path"); // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! - let (cdb, cdb_version) = debuggers::analyze_cdb(matches.opt_str("cdb"), &target); + let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); + let cdb_version = cdb.as_deref().and_then(debuggers::query_cdb_version); // FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config! - let (gdb, gdb_version) = - debuggers::analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path); + let gdb = debuggers::discover_gdb(matches.opt_str("gdb"), &target, &android_cross_path); + let gdb_version = gdb.as_deref().and_then(debuggers::query_gdb_version); // FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config! let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(debuggers::extract_lldb_version); From c7a80ab7ff2694a39d0129054a2ed05b630a91ab Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 25 Oct 2025 20:42:50 +1100 Subject: [PATCH 13/15] Only pass debugger-related flags for `debuginfo` tests --- src/bootstrap/src/core/build_steps/test.rs | 60 ++++++++++--------- src/tools/compiletest/src/common.rs | 2 +- src/tools/compiletest/src/debuggers.rs | 4 +- src/tools/compiletest/src/lib.rs | 5 +- .../compiletest/src/runtest/debuginfo.rs | 5 +- 5 files changed, 41 insertions(+), 35 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index e1b3ff92a07b8..0042b6b5c7bd1 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -2078,27 +2078,39 @@ Please disable assertions with `rust.debug-assertions = false`. cmd.arg("--python").arg(builder.python()); - if let Some(ref gdb) = builder.config.gdb { - cmd.arg("--gdb").arg(gdb); - } - - let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); - let lldb_version = command(&lldb_exe) - .allow_failure() - .arg("--version") - .run_capture(builder) - .stdout_if_ok() - .and_then(|v| if v.trim().is_empty() { None } else { Some(v) }); - if let Some(ref vers) = lldb_version { - cmd.arg("--lldb-version").arg(vers); - let lldb_python_dir = command(&lldb_exe) + if mode == "debuginfo" { + if let Some(ref gdb) = builder.config.gdb { + cmd.arg("--gdb").arg(gdb); + } + + cmd.arg("--adb-path").arg("adb"); + cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR); + if target.contains("android") && !builder.config.dry_run() { + // Assume that cc for this target comes from the android sysroot + cmd.arg("--android-cross-path") + .arg(builder.cc(target).parent().unwrap().parent().unwrap()); + } else { + cmd.arg("--android-cross-path").arg(""); + } + + let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); + let lldb_version = command(&lldb_exe) .allow_failure() - .arg("-P") - .run_capture_stdout(builder) + .arg("--version") + .run_capture(builder) .stdout_if_ok() - .map(|p| p.lines().next().expect("lldb Python dir not found").to_string()); - if let Some(ref dir) = lldb_python_dir { - cmd.arg("--lldb-python-dir").arg(dir); + .and_then(|v| if v.trim().is_empty() { None } else { Some(v) }); + if let Some(ref vers) = lldb_version { + cmd.arg("--lldb-version").arg(vers); + let lldb_python_dir = command(&lldb_exe) + .allow_failure() + .arg("-P") + .run_capture_stdout(builder) + .stdout_if_ok() + .map(|p| p.lines().next().expect("lldb Python dir not found").to_string()); + if let Some(ref dir) = lldb_python_dir { + cmd.arg("--lldb-python-dir").arg(dir); + } } } @@ -2332,16 +2344,6 @@ Please disable assertions with `rust.debug-assertions = false`. cmd.env("RUST_TEST_TMPDIR", builder.tempdir()); - cmd.arg("--adb-path").arg("adb"); - cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR); - if target.contains("android") && !builder.config.dry_run() { - // Assume that cc for this target comes from the android sysroot - cmd.arg("--android-cross-path") - .arg(builder.cc(target).parent().unwrap().parent().unwrap()); - } else { - cmd.arg("--android-cross-path").arg(""); - } - if builder.config.cmd.rustfix_coverage() { cmd.arg("--rustfix-coverage"); } diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs index 1f893fecb54b0..1f01d279310e0 100644 --- a/src/tools/compiletest/src/common.rs +++ b/src/tools/compiletest/src/common.rs @@ -560,7 +560,7 @@ pub struct Config { /// /// FIXME: take a look at this; this is piggy-backing off of gdb code paths but only for /// `arm-linux-androideabi` target. - pub android_cross_path: Utf8PathBuf, + pub android_cross_path: Option, /// Extra parameter to run adb on `arm-linux-androideabi`. /// diff --git a/src/tools/compiletest/src/debuggers.rs b/src/tools/compiletest/src/debuggers.rs index 93f27fb90951c..e97352db9139c 100644 --- a/src/tools/compiletest/src/debuggers.rs +++ b/src/tools/compiletest/src/debuggers.rs @@ -132,7 +132,7 @@ pub(crate) fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> { pub(crate) fn discover_gdb( gdb: Option, target: &str, - android_cross_path: &Utf8Path, + android_cross_path: Option<&Utf8Path>, ) -> Option { #[cfg(not(windows))] const GDB_FALLBACK: &str = "gdb"; @@ -141,7 +141,7 @@ pub(crate) fn discover_gdb( let fallback_gdb = || { if is_android_gdb_target(target) { - let mut gdb_path = android_cross_path.to_string(); + let mut gdb_path = android_cross_path.unwrap().to_string(); gdb_path.push_str("/bin/gdb"); gdb_path } else { diff --git a/src/tools/compiletest/src/lib.rs b/src/tools/compiletest/src/lib.rs index 89f5623c1fc99..8e0c2693329df 100644 --- a/src/tools/compiletest/src/lib.rs +++ b/src/tools/compiletest/src/lib.rs @@ -256,12 +256,13 @@ fn parse_config(args: Vec) -> Config { } let target = opt_str2(matches.opt_str("target")); - let android_cross_path = opt_path(matches, "android-cross-path"); + let android_cross_path = matches.opt_str("android-cross-path").map(Utf8PathBuf::from); // FIXME: `cdb_version` is *derived* from cdb, but it's *not* technically a config! let cdb = debuggers::discover_cdb(matches.opt_str("cdb"), &target); let cdb_version = cdb.as_deref().and_then(debuggers::query_cdb_version); // FIXME: `gdb_version` is *derived* from gdb, but it's *not* technically a config! - let gdb = debuggers::discover_gdb(matches.opt_str("gdb"), &target, &android_cross_path); + let gdb = + debuggers::discover_gdb(matches.opt_str("gdb"), &target, android_cross_path.as_deref()); let gdb_version = gdb.as_deref().and_then(debuggers::query_gdb_version); // FIXME: `lldb_version` is *derived* from lldb, but it's *not* technically a config! let lldb_version = diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs index 9175a38ffa5c9..1712e2ac6c517 100644 --- a/src/tools/compiletest/src/runtest/debuginfo.rs +++ b/src/tools/compiletest/src/runtest/debuginfo.rs @@ -153,7 +153,10 @@ impl TestCx<'_> { // write debugger script let mut script_str = String::with_capacity(2048); script_str.push_str(&format!("set charset {}\n", Self::charset())); - script_str.push_str(&format!("set sysroot {}\n", &self.config.android_cross_path)); + script_str.push_str(&format!( + "set sysroot {}\n", + self.config.android_cross_path.as_deref().unwrap() + )); script_str.push_str(&format!("file {}\n", exe_file)); script_str.push_str("target remote :5039\n"); script_str.push_str(&format!( From 4587ea7ebaa17a05c6ff97a3b7f36eb50c2c55b4 Mon Sep 17 00:00:00 2001 From: Zalathar Date: Sat, 25 Oct 2025 20:34:51 +1100 Subject: [PATCH 14/15] Extract some discovery code for debuginfo tests into submodules --- src/bootstrap/src/core/build_steps/test.rs | 42 +++++++-------------- src/bootstrap/src/core/debuggers/android.rs | 24 ++++++++++++ src/bootstrap/src/core/debuggers/gdb.rs | 13 +++++++ src/bootstrap/src/core/debuggers/lldb.rs | 32 ++++++++++++++++ src/bootstrap/src/core/debuggers/mod.rs | 10 +++++ src/bootstrap/src/core/mod.rs | 1 + 6 files changed, 93 insertions(+), 29 deletions(-) create mode 100644 src/bootstrap/src/core/debuggers/android.rs create mode 100644 src/bootstrap/src/core/debuggers/gdb.rs create mode 100644 src/bootstrap/src/core/debuggers/lldb.rs create mode 100644 src/bootstrap/src/core/debuggers/mod.rs diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 0042b6b5c7bd1..924fe478650f1 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -29,6 +29,7 @@ use crate::core::builder::{ }; use crate::core::config::TargetSelection; use crate::core::config::flags::{Subcommand, get_completion, top_level_help}; +use crate::core::debuggers; use crate::utils::build_stamp::{self, BuildStamp}; use crate::utils::exec::{BootstrapCommand, command}; use crate::utils::helpers::{ @@ -38,8 +39,6 @@ use crate::utils::helpers::{ use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests}; use crate::{CLang, CodegenBackendKind, DocTests, GitRepo, Mode, PathSet, envify}; -const ADB_TEST_DIR: &str = "/data/local/tmp/work"; - /// Runs `cargo test` on various internal tools used by bootstrap. #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct CrateBootstrap { @@ -2079,38 +2078,23 @@ Please disable assertions with `rust.debug-assertions = false`. cmd.arg("--python").arg(builder.python()); if mode == "debuginfo" { - if let Some(ref gdb) = builder.config.gdb { + if let Some(debuggers::Gdb { gdb }) = debuggers::discover_gdb(builder) { cmd.arg("--gdb").arg(gdb); } - cmd.arg("--adb-path").arg("adb"); - cmd.arg("--adb-test-dir").arg(ADB_TEST_DIR); - if target.contains("android") && !builder.config.dry_run() { - // Assume that cc for this target comes from the android sysroot - cmd.arg("--android-cross-path") - .arg(builder.cc(target).parent().unwrap().parent().unwrap()); - } else { - cmd.arg("--android-cross-path").arg(""); + if let Some(debuggers::Android { adb_path, adb_test_dir, android_cross_path }) = + debuggers::discover_android(builder, target) + { + cmd.arg("--adb-path").arg(adb_path); + cmd.arg("--adb-test-dir").arg(adb_test_dir); + cmd.arg("--android-cross-path").arg(android_cross_path); } - let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); - let lldb_version = command(&lldb_exe) - .allow_failure() - .arg("--version") - .run_capture(builder) - .stdout_if_ok() - .and_then(|v| if v.trim().is_empty() { None } else { Some(v) }); - if let Some(ref vers) = lldb_version { - cmd.arg("--lldb-version").arg(vers); - let lldb_python_dir = command(&lldb_exe) - .allow_failure() - .arg("-P") - .run_capture_stdout(builder) - .stdout_if_ok() - .map(|p| p.lines().next().expect("lldb Python dir not found").to_string()); - if let Some(ref dir) = lldb_python_dir { - cmd.arg("--lldb-python-dir").arg(dir); - } + if let Some(debuggers::Lldb { lldb_version, lldb_python_dir }) = + debuggers::discover_lldb(builder) + { + cmd.arg("--lldb-version").arg(lldb_version); + cmd.arg("--lldb-python-dir").arg(lldb_python_dir); } } diff --git a/src/bootstrap/src/core/debuggers/android.rs b/src/bootstrap/src/core/debuggers/android.rs new file mode 100644 index 0000000000000..b1ad9ca555fbd --- /dev/null +++ b/src/bootstrap/src/core/debuggers/android.rs @@ -0,0 +1,24 @@ +use std::path::PathBuf; + +use crate::core::builder::Builder; +use crate::core::config::TargetSelection; + +pub(crate) struct Android { + pub(crate) adb_path: &'static str, + pub(crate) adb_test_dir: &'static str, + pub(crate) android_cross_path: PathBuf, +} + +pub(crate) fn discover_android(builder: &Builder<'_>, target: TargetSelection) -> Option { + let adb_path = "adb"; + // See . + let adb_test_dir = "/data/local/tmp/work"; + + let android_cross_path = if target.contains("android") && !builder.config.dry_run() { + builder.cc(target).parent().unwrap().parent().unwrap().to_owned() + } else { + PathBuf::new() + }; + + Some(Android { adb_path, adb_test_dir, android_cross_path }) +} diff --git a/src/bootstrap/src/core/debuggers/gdb.rs b/src/bootstrap/src/core/debuggers/gdb.rs new file mode 100644 index 0000000000000..ddad0909e4f07 --- /dev/null +++ b/src/bootstrap/src/core/debuggers/gdb.rs @@ -0,0 +1,13 @@ +use std::path::Path; + +use crate::core::builder::Builder; + +pub(crate) struct Gdb<'a> { + pub(crate) gdb: &'a Path, +} + +pub(crate) fn discover_gdb<'a>(builder: &'a Builder<'_>) -> Option> { + let gdb = builder.config.gdb.as_deref()?; + + Some(Gdb { gdb }) +} diff --git a/src/bootstrap/src/core/debuggers/lldb.rs b/src/bootstrap/src/core/debuggers/lldb.rs new file mode 100644 index 0000000000000..66ab45573d6bb --- /dev/null +++ b/src/bootstrap/src/core/debuggers/lldb.rs @@ -0,0 +1,32 @@ +use std::path::PathBuf; + +use crate::core::builder::Builder; +use crate::utils::exec::command; + +pub(crate) struct Lldb { + pub(crate) lldb_version: String, + pub(crate) lldb_python_dir: String, +} + +pub(crate) fn discover_lldb(builder: &Builder<'_>) -> Option { + // FIXME(#148361): We probably should not be picking up whatever arbitrary + // lldb happens to be in the user's path, and instead require some kind of + // explicit opt-in or configuration. + let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb")); + + let lldb_version = command(&lldb_exe) + .allow_failure() + .arg("--version") + .run_capture(builder) + .stdout_if_ok() + .and_then(|v| if v.trim().is_empty() { None } else { Some(v) })?; + + let lldb_python_dir = command(&lldb_exe) + .allow_failure() + .arg("-P") + .run_capture_stdout(builder) + .stdout_if_ok() + .map(|p| p.lines().next().expect("lldb Python dir not found").to_string())?; + + Some(Lldb { lldb_version, lldb_python_dir }) +} diff --git a/src/bootstrap/src/core/debuggers/mod.rs b/src/bootstrap/src/core/debuggers/mod.rs new file mode 100644 index 0000000000000..011ce4081a43e --- /dev/null +++ b/src/bootstrap/src/core/debuggers/mod.rs @@ -0,0 +1,10 @@ +//! Code for discovering debuggers and debugger-related configuration, so that +//! it can be passed to compiletest when running debuginfo tests. + +pub(crate) use self::android::{Android, discover_android}; +pub(crate) use self::gdb::{Gdb, discover_gdb}; +pub(crate) use self::lldb::{Lldb, discover_lldb}; + +mod android; +mod gdb; +mod lldb; diff --git a/src/bootstrap/src/core/mod.rs b/src/bootstrap/src/core/mod.rs index 9e18d6704d4fe..f27a09c81c55b 100644 --- a/src/bootstrap/src/core/mod.rs +++ b/src/bootstrap/src/core/mod.rs @@ -1,6 +1,7 @@ pub(crate) mod build_steps; pub(crate) mod builder; pub(crate) mod config; +pub(crate) mod debuggers; pub(crate) mod download; pub(crate) mod metadata; pub(crate) mod sanity; From 4220f7c90eadcf2bf5a719cf9da8895852642a55 Mon Sep 17 00:00:00 2001 From: Vitaliy Busko Date: Sat, 1 Nov 2025 15:20:57 +0700 Subject: [PATCH 15/15] confirmed success built rustc 1.91.0 + host tools for win7 --- src/doc/rustc/src/platform-support.md | 2 +- src/doc/rustc/src/platform-support/win7-windows-msvc.md | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 99739ee734e4c..8cae44bcd074c 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -439,7 +439,7 @@ target | std | host | notes `x86_64-uwp-windows-gnu` | ✓ | | [`x86_64-uwp-windows-msvc`](platform-support/uwp-windows-msvc.md) | ✓ | | [`x86_64-win7-windows-gnu`](platform-support/win7-windows-gnu.md) | ✓ | | 64-bit Windows 7 support -[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support +[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | ✓ | 64-bit Windows 7 support [`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell) [`xtensa-esp32-espidf`](platform-support/esp-idf.md) | ✓ | | Xtensa ESP32 diff --git a/src/doc/rustc/src/platform-support/win7-windows-msvc.md b/src/doc/rustc/src/platform-support/win7-windows-msvc.md index 56fe0f6401664..b14424ddbf3a4 100644 --- a/src/doc/rustc/src/platform-support/win7-windows-msvc.md +++ b/src/doc/rustc/src/platform-support/win7-windows-msvc.md @@ -16,7 +16,8 @@ Target triples: This target supports all of core, alloc, std and test. This is automatically tested every night on private infrastructure hosted by the maintainer. Host -tools may also work, though those are not currently tested. +tools may also work, though it is not guaranteed. Last known success built +version of rustc with host tools (x86_64) is 1.91.0. Those targets follow Windows calling convention for extern "C".