-
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
No uninitalized report in a pre-returned match arm #126295
Conversation
This comment has been minimized.
This comment has been minimized.
a8d2bd1
to
5d8f40a
Compare
This solution does not cover all the cases I can imagine, but it is an improvement over the prior overall behavior, so I'm going to r+ it. In particular, special casing return statements does not cover other kinds of non-local control-flow operations, such as The big picture problem here is that precisely identifying which match arms both A. can reach a use of the variable and B. fail to initialize the variable requires a control-flow analysis. Which you can get from the MIR, but you're trying to report a diagnostic with respect to the HIR. (My suspicion is that a fully precise solution would work by using the MIR to identify the relevant spans that meet condition A and B in the previous paragraph, and then seek out the match arms here that overlap such spans. Or at least, that would be how I might investigate trying to attack a fully precise solution. But there are probably other rustc developers with alternative approaches in mind.) |
@bors r+ |
@bors rollup |
…llaumeGomez Rollup of 9 pull requests Successful merges: - rust-lang#126039 (Promote `arm64ec-pc-windows-msvc` to tier 2) - rust-lang#126075 (Remove `DebugWithInfcx` machinery) - rust-lang#126228 (Provide correct parent for nested anon const) - rust-lang#126232 (interpret: dyn trait metadata check: equate traits in a proper way) - rust-lang#126242 (Simplify provider api to improve llvm ir) - rust-lang#126294 (coverage: Replace the old span refiner with a single function) - rust-lang#126295 (No uninitalized report in a pre-returned match arm) - rust-lang#126312 (Update `rustc-perf` submodule) - rust-lang#126322 (Follow up to splitting core's PanicInfo and std's PanicInfo) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#126295 - linyihai:uninitalized-in-match-arm, r=pnkfelix No uninitalized report in a pre-returned match arm This is a attemp to address rust-lang#126133
This is an attemp to address #126133