-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
MIR-borrowck: ICE during diagnostic search for assignment (unwrap of None) #45199
Comments
Its worth noting that the diagnostic reported by AST-borrowck is very different from that for MIR-borrowck. This is almost certainly because the MIR-borrowck is seeing a desugared for-loop (and thus we're seeing reports of an assignment to Nonetheless, part of resolving this bug might include trying figure out how to make the MIR-borrowck diagnostic more understandable to the end user in this scenario. |
(another approach that I did not consider earlier: Change the MIR construction to accommodate |
Working on this (and this error message in general) |
@matthewjasper nice! please stop in on gitter with any questions, if you've not done so already. |
Minified case (that still ICEs after #45936) fn main() {
let x = String::new();
x = String::new();
} |
…rror, r=arielb1 Mir Borrowck: Parity with Ast for E0384 (Cannot assign twice to immutable) - Closes rust-lang#45199 - Don't allow assigning to dropped immutable variables - Show the "first assignment" note on the first assignment that can actually come before the second assignment. - Make "first assignment" notes point to function parameters if needed. - Don't show a "first assignment" note if the first and second assignment have the same span (in a loop). This matches ast borrowck for now, but maybe this we should add "in previous loop iteration" as with some other borrowck errors. (Commit 2) - Use revisions to check mir borrowck for the existing tests for this error. (Commit 3) ~~Still working on a less ad-hoc way to get 'first assignment' notes to show on the correct assignment. Also need to check mutating function arguments.~~ Now using a new dataflow pass.
…elb1 Mir Borrowck: Parity with Ast for E0384 (Cannot assign twice to immutable) - Closes #45199 - Don't allow assigning to dropped immutable variables - Show the "first assignment" note on the first assignment that can actually come before the second assignment. - Make "first assignment" notes point to function parameters if needed. - Don't show a "first assignment" note if the first and second assignment have the same span (in a loop). This matches ast borrowck for now, but maybe this we should add "in previous loop iteration" as with some other borrowck errors. (Commit 2) - Use revisions to check mir borrowck for the existing tests for this error. (Commit 3) ~~Still working on a less ad-hoc way to get 'first assignment' notes to show on the correct assignment. Also need to check mutating function arguments.~~ Now using a new dataflow pass.
PR #44806 added some code to search for the lexically first assignment in order to report an illegal assignment.
However, oddly enough, for some tests this search, which ends in an
unwrap
, is causing the compiler to ICE.For example:
The text was updated successfully, but these errors were encountered: