-
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
Custom MIR: Parse ExprKind::Use
correctly
#109160
Conversation
Hmm, I don't think the test you added is what we want. Either we should emit an actual |
I agree, although the Cast was already removed in THIR, not here. I can look into this
We could prohibit identity cast in MIR entirely, though I don't see a good reason for this restriction (cc @RalfJung). It's failing currently but for the wrong reason (trying to parse a non-operand as an operand).
I'm building a fuzzer that generates MIR through the |
We can allow it in Mir without parsing it in custom mir. That isn't great, but it's not the worst thing ever either. This of course does give your fuzzer less coverage, but I think I would rather fail to parse this entirely than parse it into what seems to me to be the wrong thing. Edit: although, now that I say that, this PR doesn't actually fix the coverage problem so that can't really be the motivation either |
Even if we accept that identity cast isn't parsed by custom MIR, we still need to parse |
We currently can't have identity casts in MIR? That can't be entirely right, I can write a generic |
Since identity casts are removed in THIR, I believe it is never actually emitted as MIR (whether compiling normally from Rust or through custom MIR). We probably should allow it, but we aren't generating it atm.
Do we ever emit monomorphized MIR? |
We don't manifest it, no. But conceptually this is what the interpreter and codegen are dealing with, so from their perspective identity casts already exist.
That seems like the most sensible choice to me, to make |
☔ The latest upstream changes (presumably #109442) made this pull request unmergeable. Please resolve the merge conflicts. |
If I read the conversation correctly this PR can switch to waiting on author for some design work. Feel free to request a review with @rustbot author |
Ping from triage: I'm closing this due to inactivity, Please reopen when you are ready to continue with this. @rustbot label: +S-inactive |
ExprKind::Use
isn't parsed properly in the custom MIR builder as the fall-through case attempts to parse the wholeExprId
as an operand, but only thesource
field inside theUse
variant is.One instance where
ExprKind::Use
is emitted is an identityas
cast.r? @oli-obk or @tmiasko or @JakobDegen