Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2906ebc

Browse files
committedMar 22, 2024·
Don't emit an error about failing to produce a file with a specific name
If user never gave an explicit name
1 parent 03994e4 commit 2906ebc

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed
 

‎compiler/rustc_codegen_ssa/src/back/write.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ fn produce_final_output_artifacts(
592592
.unwrap()
593593
.to_owned();
594594

595-
if crate_output.outputs.contains_key(&output_type) {
595+
if crate_output.outputs.contains_explicit_name(&output_type) {
596596
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
597597
// no good solution for this case, so warn the user.
598598
sess.dcx().emit_warn(errors::IgnoringEmitPath { extension });

‎compiler/rustc_session/src/config.rs

+5
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,11 @@ impl OutputTypes {
557557
self.0.contains_key(key)
558558
}
559559

560+
/// Returns `true` if user specified a name and not just produced type
561+
pub fn contains_explicit_name(&self, key: &OutputType) -> bool {
562+
self.0.get(key).map_or(false, |f| f.is_some())
563+
}
564+
560565
pub fn iter(&self) -> BTreeMapIter<'_, OutputType, Option<OutFileName>> {
561566
self.0.iter()
562567
}

‎tests/ui/issue-122509.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//@ build-pass
2+
//@ compile-flags: -C codegen-units=2 --emit asm
3+
4+
fn one() -> usize {
5+
1
6+
}
7+
8+
pub mod a {
9+
pub fn two() -> usize {
10+
::one() + ::one()
11+
}
12+
}
13+
14+
pub mod b {
15+
pub fn three() -> usize {
16+
::one() + ::a::two()
17+
}
18+
}
19+
20+
fn main() {
21+
a::two();
22+
b::three();
23+
}

0 commit comments

Comments
 (0)
Please sign in to comment.