rust/compiler/rustc_codegen_ssa/src
Matthias Krüger ded16b3a97
Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister
Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name

Fixes #122509

You can ask `rustc` to produce some intermediate results with `--emit foo`, this operation comes in two flavors: `--emit asm` and `--emit asm=foo.s`. First one produces one or more `.s` files without any name guarantees, second one renames it into `foo.s`. Second version only works when compiler produces a single file - for asm files this means using a single compilation unit for example.

In case compilation produced more than a single file `rustc` runs following check to emit some warnings:

```rust
            if crate_output.outputs.contains_key(&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 });
            } else if crate_output.single_output_file.is_some() {
                // 3) Multiple codegen units, with `-o some_name`. We have
                //    no good solution for this case, so warn the user.
                sess.dcx().emit_warn(errors::IgnoringOutput { extension });
            } else {
                // 4) Multiple codegen units, but no explicit name. We
                //    just leave the `foo.0.x` files in place.
                // (We don't have to do any work in this case.)
            }
```

Comment in the final `else` branch implies that if user didn't ask for a specific name - there's no need to emit warnings. However because of the internal representation of `crate_output.outputs` - this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will contain `Some(None)`.

To fix the problem new code actually checks if user gave an explicit name. I think this was an original intentional behavior, at least comments imply that.
2024-03-25 17:05:32 +01:00
..
back Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister 2024-03-25 17:05:32 +01:00
debuginfo Programmatically convert some of the pat ctors 2024-03-22 11:13:29 -04:00
mir Rollup merge of #122937 - Zalathar:unbox, r=oli-obk 2024-03-24 17:08:16 +01:00
traits Rollup merge of #122937 - Zalathar:unbox, r=oli-obk 2024-03-24 17:08:16 +01:00
assert_module_sources.rs Rename IntoDiagnosticArg as IntoDiagArg. 2024-03-11 09:12:19 +11:00
base.rs CFI: Use Instance at callsites 2024-03-23 18:30:39 +00:00
codegen_attrs.rs Fix misleading message when using a named constant as a struct alignment/pack 2024-03-02 23:15:39 +08:00
common.rs Handle calls to upstream monomorphizations in compiler_builtins 2024-03-16 15:22:05 -04:00
errors.rs Handle calls to upstream monomorphizations in compiler_builtins 2024-03-16 15:22:05 -04:00
lib.rs Stabilize associated type bounds 2024-03-08 20:56:25 +00:00
meth.rs use ptradd for vtable indexing 2024-03-10 22:47:30 -04:00
mono_item.rs Fix ICE: global_asm!() Don't Panic When Unable to Evaluate Constant 2024-03-18 11:35:40 -04:00
size_of_val.rs CFI: Use Instance at callsites 2024-03-23 18:30:39 +00:00
target_features.rs Bump indexmap 2024-02-13 21:03:34 +00:00