Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name #122842

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<OutFileName>> {
self.0.iter()
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions tests/ui/warnings/no-explicit-path-issue-122509.rs
Original file line number Diff line number Diff line change
@@ -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();
}
Loading