-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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] A pass to type-check MIR #31474
Conversation
r? @jroesch (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -974,6 +978,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options { | |||
let parse_only = debugging_opts.parse_only; | |||
let no_trans = debugging_opts.no_trans; | |||
let treat_err_as_bug = debugging_opts.treat_err_as_bug; | |||
let mir_opt_level = debugging_opts.mir_opt_level.unwrap_or(1); |
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 was considering a default of 1 + -C opt-level
. This way the level of MIR “optimisations” would automatically get attached to the -O
and -C opt-level
flags as well.
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.
First make opt-levels greater than 1 do something, then we can talk.
☔ The latest upstream changes (presumably #31425) made this pull request unmergeable. Please resolve the merge conflicts. |
How fast do you expect the check to be? It would be nice if we could run the check between each pass, probably based on a -Z flag. |
cc me |
This pass should not take too much time. |
Let me know when you think this is ready for review, reading over it right now. |
the rvalue-type-checking code can be improved, but I will leave that to a separate PR - this one is growing too big. |
59b1dd5
to
d210962
Compare
span_mirbug_and_err!(self, parent, "bad type {:?}", ty) | ||
} | ||
|
||
fn sanitize_lvalue(&mut self, lvalue: &Lvalue<'tcx>) -> LvalueTy<'tcx> { |
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 prefix sanitize
strikes me as odd. To me, it suggests something which will mutate the lvalue in place, removing artifacts or normalizing it in some way. But in fact sanitize_lvalue
seems to compute the type of an lvalue.
There is also an unfortunate amount of overlap with the lvalue_ty
routine -- these basically do the same thing, but just handle the error cases differently. Perhaps we could make lvalue_ty
return a Result
instead to eliminate the overlap?
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, reading a bit further I see that sanitize_projection
actually does more consistency checking, so perhaps it is good to keep these two routines as separate. I think I would change sanitize
to typeck_
or type_
or just check_
.
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.
Perhaps verify_
would be the best name, given that this is part of the type verifier.
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 returns the sanitized lvalue ty, which will be TyErr
if there are are late-bound regions etc. in the type.
☔ The latest upstream changes (presumably #31600) made this pull request unmergeable. Please resolve the merge conflicts. |
setting -Z mir-opt-level=0 will disable all MIR optimizations for easier debugging
this makes the the MIR assignment pass complete successfully
TODO: find a correct borrow region Fixes rust-lang#31482
also fix translation of "rust-call" functions, although that could use more optimizations
rather than being implicit quasi-subtyping. Nothing good can come out of quasi-subtyping.
@bors r=nikomatsakis |
📌 Commit 626dc3b has been approved by |
⌛ Testing commit 626dc3b with merge e768394... |
💔 Test failed - auto-mac-64-opt |
@bors r=nikomatsakis |
📌 Commit d84658e has been approved by |
⌛ Testing commit d84658e with merge 6c751e0... |
This should stop broken MIR from annoying us when we try to implement things
This should stop broken MIR from annoying us when we try to implement things