-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Leave promoteds untainted by errors when borrowck fails #111038
Conversation
Previously, when borrowck failed it would taint all promoteds within the MIR body. An attempt to evaluated the promoteds would subsequently fail with spurious "note: erroneous constant used". For example: ```console ... note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:9 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:14 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:19 | 7 | a = &0 * &1 * &2 * &3; | ^^ note: erroneous constant used --> tests/ui/borrowck/tainted-promoteds.rs:7:24 | 7 | a = &0 * &1 * &2 * &3; | ^^ ``` Borrowck failure doesn't indicate that there is anything wrong with promoteds. Leave them untainted.
r? @lcnr (rustbot has picked a reviewer for you, use r? to override) |
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
Yeah, I have no idea why I made the I don't really think there are ways of triggering a (meaningful) borrowck error on a promoted constant anyways, though happy to be disproven by an example... I checked, it also gets rid of the "erroneous constant" note at the end of: fn main() {
println!("{}", {
let x: &str;
x
});
} error[E0381]: used binding `x` isn't initialized
--> /home/gh-compiler-errors/test.rs:4:9
|
3 | let x: &str;
| - binding declared here but left uninitialized
4 | x
| ^ `x` used here but it isn't initialized
|
help: consider assigning a value
|
3 | let x: &str = todo!();
| +++++++++
note: erroneous constant used
--> /home/gh-compiler-errors/test.rs:2:14
|
2 | println!("{}", {
| ^^^^ r=me when green |
There's the error in #71587, not sure if that counts as "meaningful" or not. |
@matthewjasper: Sorry, by "meaningful", I guess I should've been more clear. What I mean is borrowck errors that are likely to cause spurious const-eval errors or ICEs. It doesn't seem like that's the case with the class of issues you fixed in #71587, though, and it doesn't seem like any other existing UI tests were affected by this change, so I consider this PR to be pretty low-risk. The only possible issue is that we might see are spurious const eval errors or ICEs from no longer tainting these promoteds, thus leading to them being evaluated... @bors r+ |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#109540 (std docs: edit `PathBuf::set_file_name` example) - rust-lang#110093 (Add 64-bit `time_t` support on 32-bit glibc Linux to `set_times`) - rust-lang#110987 (update wasi_clock_time_api ref.) - rust-lang#111038 (Leave promoteds untainted by errors when borrowck fails) - rust-lang#111042 (Add `#[no_coverage]` to the test harness's `fn main`) - rust-lang#111057 (Make sure the implementation of TcpStream::as_raw_fd is fully inlined) - rust-lang#111065 (Explicitly document how Send and Sync relate to references) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Previously, when borrowck failed it would taint all promoteds within the MIR body. An attempt to evaluated the promoteds would subsequently fail with spurious "note: erroneous constant used". For example:
Borrowck failure doesn't indicate that there is anything wrong with promoteds. Leave them untainted.
Fixes #110856.