-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Warn when rustc output conflicts with existing directories #47203
Warn when rustc output conflicts with existing directories #47203
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_driver/driver.rs
Outdated
if let Some(dir_path) = outputs.conflicts_with_dir() { | ||
sess.err(&format!( | ||
"the generated executable for the input file \"{}\" conflicts with the \ | ||
existing directory \"{}\'", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK so why the existing directory part ends with a single quote?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An inadvertent stylistic experiment... Fixed.
The |
src/librustc/session/config.rs
Outdated
if input_path.is_none() { | ||
return false | ||
} | ||
fn check_output<F, T>(&self, f: F) -> Option<T> where F: Fn(PathBuf) -> Option<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code was able to limp along without a comment before since it was singly-purposed. But if you're going to generalize it with a higher-order function, you should add documentation stating what it does. (E.g. something like "Runs f
on every potential output file path, returning this first for which f
returns non-none, or None
if f
is none for all paths.")
As @kennytm notes, the From what I can tell, this is happening because your code is (reasonably?) assuming that the paths enumerated by the However, from what I can tell, when the |
However you decide to resolve this, it would probably be good to ensure that |
Thanks for the pointers @pnkfelix — they were helpful in getting on the right track. I've only got a line or so of documentation for the two new functions at the moment — let me know if you think it's still too sparse! This uncovered (the same) bug in the "don't overwrite the input file" check too, so it was helpful to run into it here. |
src/librustc_driver/driver.rs
Outdated
let output_paths = generated_output_paths(sess, &outputs, &crate_name); | ||
|
||
// Ensure the source file isn't accidentally overwritten during compilation. | ||
match *input_path { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd personally use if let Some(ref input_path) = *input_path { ... }
here, especially since the None
branch is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(oh but I guess the pre-existing code that you're refactoring used match
. Fine to leave it as is to ease reading the diff here, I guess.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns out the diffing algorithm doesn't catch on anyway, so I'll change it (considering the change is currently breaking on x86_64-pc-windows-msvc
).
@bors r+ |
📌 Commit eba03fa has been approved by |
⌛ Testing commit eba03fa06e2550a62135c8f4d094fa3fb1ab3724 with merge 0dd43d7a6794e3f5aeb9d4559cbea953e48ede21... |
💔 Test failed - status-appveyor |
⌛ Testing commit eba03fa06e2550a62135c8f4d094fa3fb1ab3724 with merge 72c51266f24476d376160243aed05d1f36fae8cc... |
💔 Test failed - status-appveyor |
Likely legit error on |
I guess The failing |
Hi @varkor,
Have you checked the problem, or is it ready to be r+'ed again? |
a23fb80
to
9a2f02d
Compare
@pnkfelix: I think the latest changes should fix the issues on Windows! Do you think you could have a quick look over? |
@pnkfelix and @rust-lang/compiler, ping from triage! This PR needs a review. |
@bors r+ |
📌 Commit e92bdb9 has been approved by |
…y, r=estebank Warn when rustc output conflicts with existing directories When the compiled executable would conflict with a directory, display a rustc error instead of a verbose and potentially-confusing linker error. This is a usability improvement, and doesn’t actually change behaviour with regards to compilation success. This addresses the concern in #35887. Fixes #13098.
💥 Test timed out |
@bors retry The macs were not scheduled to start. |
…y, r=estebank Warn when rustc output conflicts with existing directories When the compiled executable would conflict with a directory, display a rustc error instead of a verbose and potentially-confusing linker error. This is a usability improvement, and doesn’t actually change behaviour with regards to compilation success. This addresses the concern in #35887. Fixes #13098.
☀️ Test successful - status-appveyor, status-travis |
When the compiled executable would conflict with a directory, display a
rustc error instead of a verbose and potentially-confusing linker
error. This is a usability improvement, and doesn’t actually change
behaviour with regards to compilation success. This addresses the
concern in #35887. Fixes #13098.