Repository navigation
create mir for direct-rhs consts - #165070
Conversation
|
|
||
| let root = tcx.typeck_root_def_id_local(def); | ||
| if let Err(e) = tcx.check_transmutes(root) { | ||
| if !tcx.is_synthetic_mir(root) |
There was a problem hiding this comment.
why this :3
There was a problem hiding this comment.
check_transmutes calls typeck, typeck requires HIR, synthetic MIR does not have HIR.
previously, the only synthetic MIR was DefKind::SyntheticCoroutineBody, which is a typeck child, so this call to check_transmutes (which must be called on typeck roots) didn't care and we just happened to be correct here
|
|
|
The test differences are generally due to, if the direct const item being referenced by a
|
6bdcf68 to
beca84e
Compare
This comment has been minimized.
This comment has been minimized.
beca84e to
6a9928d
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
| } else { | ||
| let args = ty::GenericArgs::identity_for_item(tcx, def_id); | ||
| let kind = ty::AliasConstKind::InherentImpl { def_id: def_id.into() }; | ||
| ty::AliasConst::new(tcx, kind, args) |
There was a problem hiding this comment.
can you add a comment for why we don't use mir::Const::Ty(const_of_item(...)), then r=me
|
@rustbot author this is a much smaller hack and doesn't touch const eval so im comfortable approving this without talking to const eval folks |
6a9928d to
f29e22f
Compare
|
@bors r=BoxyUwU rollup |
…uwer Rollup of 6 pull requests Successful merges: - #163764 (Tweak suggestion of "unreachable due to never pattern") - #164771 (std: fix platform checks for hermit) - #165070 (create mir for direct-rhs consts) - #165121 (test DSL evaluate sequentially) - #165288 (Add assembly test for masked index without redundant shifts) - #165307 (test(lexer): Add test that ZWJ/ZWNJ are accepted in identifiers)
Rollup merge of #165070 - khyperia:mir_for_direct_const, r=BoxyUwU create mir for direct-rhs consts Alternative to #164982 - see that PR for context. When referring to a direct constant via a `mir::Const::Unevaluated`, synthesize a MIR body, whose contents are simply returning a `mir::Const::Ty` of itself. This effectively provides both a MIR view, as well as a typesystem view, of the same constant, without risking representing the same constant in different ways in the two different representations, because one is just referring to the other. r? @BoxyUwU fyi @oli-obk @lcnr
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (e7363cb): comparison URL. Overall result: ❌✅ regressions and improvements - please read:Our benchmarks found a performance regression caused by this PR. Next Steps:
@rustbot label: +perf-regression Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary -3.6%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Artifact size: 406.63 MiB -> 406.59 MiB (-0.01%) |
Alternative to #164982 - see that PR for context.
When referring to a direct constant via a
mir::Const::Unevaluated, synthesize a MIR body, whose contents are simply returning amir::Const::Tyof itself. This effectively provides both a MIR view, as well as a typesystem view, of the same constant, without risking representing the same constant in different ways in the two different representations, because one is just referring to the other.r? @BoxyUwU
fyi @oli-obk @lcnr