-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @michaelwoerister (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
Thanks for the PR, @pacak! Would you mind adding a regression test? Let me know if you need any help with that. |
Absolutely. What is the most reliable way to ensure that the code will be compiled with at least two codegen units? |
Passing |
Compile flags like that can be set in the test file: https://rustc-dev-guide.rust-lang.org/tests/headers.html |
I think that's it. It supposed to produce an error before (I didn't check though) and it is not producing an error now. |
This comment has been minimized.
This comment has been minimized.
Looking at other tests that do start with just issue - "all tests are equal, but some are more equal..." |
This comment has been minimized.
This comment has been minimized.
If user never gave an explicit name
There's no relevant subdirectory for invalid warnings though as far as I can see. I tried moving it into issues - it also complains about having too many items... |
Adding a directory to tests/ui doesn't work either. I give up. |
Okay, now there's a sub directory for warnings. |
I'm sorry those tidy errors seemed to have sent you on a wild goose chase. There indeed doesn't seem to be a relevant pre-existing subdirectory for that test. The test and the fix both look good! @bors r+ rollup |
Not your fault. And now I know where to look and why is it happening :) |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#122842 (Don't emit an error about failing to produce a file with a specific name if user never gave an explicit name) - rust-lang#122881 (Delegation: fix ICE on `bound_vars` divergence) - rust-lang#122910 (Validate that we're only matching on unit struct for path pattern) - rust-lang#122970 (Use `chunk_by` when building `ReverseSccGraph`) - rust-lang#122988 (add even more tests! ) - rust-lang#122999 (Fix unpretty UI test when /tmp does not exist) - rust-lang#123001 (Rename `{enter,exit}_lint_attrs` to `check_attributes{,_post}`) - rust-lang#123022 (Add `async-closures/once.rs` back to cranelift tests) - rust-lang#123034 (Add a bunch of needs-unwind annotations to tests) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#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 rust-lang#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.
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 intofoo.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: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 ofcrate_output.outputs
- this doesn't work as expected: if user asked to produce an asm file without giving it an implicit name it will containSome(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.