rust/compiler/rustc_session/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
..
config update paths in comments 2024-01-12 00:11:33 +01:00
code_stats.rs -Zprint-type-sizes: print the types of awaitees and unnamed coroutine locals. 2024-03-22 18:07:15 -07:00
config.rs Rollup merge of #122842 - pacak:explicit_name, r=michaelwoerister 2024-03-25 17:05:32 +01:00
cstore.rs Move MetadataLoader{,Dyn} to rustc_metadata. 2023-11-30 17:05:54 +11:00
errors.rs Rollup merge of #122748 - nnethercote:rustc_session-pub, r=jackh726 2024-03-20 05:51:24 +01:00
filesearch.rs Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot 2024-03-11 09:29:32 -07:00
lib.rs Use generic NonZero internally. 2024-02-15 08:09:42 +01:00
options.rs Rollup merge of #121207 - chriswailes:z-external-clangrt, r=michaelwoerister 2024-03-15 10:14:53 +01:00
output.rs Make incremental sessions identity no longer depend on the crate names provided by source code 2024-03-13 16:40:02 +01:00
parse.rs conditionally ignore fatal diagnostic in the SilentEmitter 2024-03-19 13:48:07 -04:00
search_paths.rs Rewrite the untranslatable_diagnostic lint. 2024-03-06 14:19:01 +11:00
session.rs Rename some target_cfg variables as target. 2024-03-21 11:50:40 +11:00
utils.rs Use better heuristic for printing Cargo specific diagnostics 2024-02-17 16:49:01 +01:00
version.rs Simplify the current_rustc_version macro. 2023-11-10 10:54:21 +11:00