From bf12aa49e71d6e444c34d7adb87647f36b7dde1a Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Thu, 21 Mar 2024 16:13:46 -0400 Subject: [PATCH 1/2] Don't emit an error about failing to produce a file with a specific name If user never gave an explicit name --- compiler/rustc_codegen_ssa/src/back/write.rs | 2 +- compiler/rustc_session/src/config.rs | 5 ++++ .../issues/no-explicit-path-issue-122509.rs | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 tests/ui/issues/no-explicit-path-issue-122509.rs diff --git a/compiler/rustc_codegen_ssa/src/back/write.rs b/compiler/rustc_codegen_ssa/src/back/write.rs index 4eda4c2f08c69..b7bcaac3b18f6 100644 --- a/compiler/rustc_codegen_ssa/src/back/write.rs +++ b/compiler/rustc_codegen_ssa/src/back/write.rs @@ -592,7 +592,7 @@ fn produce_final_output_artifacts( .unwrap() .to_owned(); - if crate_output.outputs.contains_key(&output_type) { + if crate_output.outputs.contains_explicit_name(&output_type) { // 2) Multiple codegen units, with `--emit foo=some_name`. We have // no good solution for this case, so warn the user. sess.dcx().emit_warn(errors::IgnoringEmitPath { extension }); diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index e6eb1a3e83c6c..e4d2af95c572a 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -557,6 +557,11 @@ impl OutputTypes { self.0.contains_key(key) } + /// Returns `true` if user specified a name and not just produced type + pub fn contains_explicit_name(&self, key: &OutputType) -> bool { + self.0.get(key).map_or(false, |f| f.is_some()) + } + pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option> { self.0.iter() } diff --git a/tests/ui/issues/no-explicit-path-issue-122509.rs b/tests/ui/issues/no-explicit-path-issue-122509.rs new file mode 100644 index 0000000000000..4e8eefde5dad1 --- /dev/null +++ b/tests/ui/issues/no-explicit-path-issue-122509.rs @@ -0,0 +1,23 @@ +//@ build-pass +//@ compile-flags: -C codegen-units=2 --emit asm + +fn one() -> usize { + 1 +} + +pub mod a { + pub fn two() -> usize { + ::one() + ::one() + } +} + +pub mod b { + pub fn three() -> usize { + ::one() + ::a::two() + } +} + +fn main() { + a::two(); + b::three(); +} From b84326ec9caca0c8877bc58a85a8c7814ca6c052 Mon Sep 17 00:00:00 2001 From: Michael Baikov Date: Fri, 22 Mar 2024 11:20:55 -0400 Subject: [PATCH 2/2] tests/ui: Add a directory for warnings, add a test --- src/tools/tidy/src/ui_tests.rs | 2 +- tests/ui/{issues => warnings}/no-explicit-path-issue-122509.rs | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/ui/{issues => warnings}/no-explicit-path-issue-122509.rs (100%) diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 22927cffd1b9b..015d0518a405a 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -18,7 +18,7 @@ const ENTRY_LIMIT: usize = 900; // FIXME: The following limits should be reduced eventually. const ISSUES_ENTRY_LIMIT: usize = 1750; -const ROOT_ENTRY_LIMIT: usize = 859; +const ROOT_ENTRY_LIMIT: usize = 860; const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[ "rs", // test source files diff --git a/tests/ui/issues/no-explicit-path-issue-122509.rs b/tests/ui/warnings/no-explicit-path-issue-122509.rs similarity index 100% rename from tests/ui/issues/no-explicit-path-issue-122509.rs rename to tests/ui/warnings/no-explicit-path-issue-122509.rs