Closed
Metadata
Metadata
Assignees
Labels
Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
jonas-schievink commentedon Jun 14, 2020
Instructions:
Extend the validation pass in
src/librustc_mir/transform/validate.rs
by implementingvisit_local
for theTypeChecker
MIR visitor:rust/src/librustc_mir/transform/validate.rs
Line 88 in 4fb54ed
The
Visitor
trait is documented here.The method should check that the local exists in
self.body.local_decls
, and fail with a descriptive error message if not (by callingself.fail
, not by panicking directly).yerke commentedon Jun 14, 2020
@rustbot claim
jonas-schievink commentedon Jun 14, 2020
@yerke FYI, the validation pass currently fails on even libcore until #73175 is merged, so you need to either wait for that, or cherry-pick some commits from there to get it to work.
You can test your changes by running
RUSTFLAGS_NOT_BOOTSTRAP="-Zvalidate-mir" ./x.py test --stage=1 src/test/ui
(the validator only runs on very little code by default,-Zvalidate-mir
turns it on for everything).yerke commentedon Jun 15, 2020
@jonas-schievink I wanted to double check, running
RUSTFLAGS_NOT_BOOTSTRAP="-Zvalidate-mir" ./x.py test --stage=1 src/test/ui
should fail when I run it, right? It actually passed for me after I merged in your branch from #73359.I wonder if I should try clean and build stage 1 again. :\
jonas-schievink commentedon Jun 15, 2020
It should pass with #73359 applied, but fail on current master.
yerke commentedon Jun 15, 2020
@jonas-schievink So your PR fixes this issue (#73356) as well?
jonas-schievink commentedon Jun 15, 2020
Ah, no, this issue is just about adding additional validation. It shouldn't actually detect any locals that don't exist. So the command should work both before and after implementing this. If it fails after implementing this, something else is going on that we should look into.
pitaj commentedon Oct 15, 2020
@yerke are you still working on this?
yerke commentedon Oct 15, 2020
No, sorry. Didn’t have time for it. Go ahead.
jonas-schievink commentedon Nov 7, 2020
@rustbot release-assignment
natsukagami commentedon Nov 8, 2020
Would like to work on this, but it seems there is another check, not on the declaration like this one, but on the memory liveness. This should cover the case that the local is not declared (I think), or would it not?
rust/compiler/rustc_mir/src/transform/validate.rs
Lines 187 to 192 in 1773f60
LocalDecl
#79031