0

Don't emit an error about failing to produce a file with a specific name if user...

 4 weeks ago
source link: https://github.com/rust-lang/rust/pull/122842
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Conversation

Contributor

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:

            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.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK