-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 generation cleanup #59560
MIR generation cleanup #59560
Conversation
r? @varkor (rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc_mir/build/mod.rs
Outdated
@@ -147,7 +147,21 @@ pub fn mir_build<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> Mir<'t | |||
build::construct_fn(cx, id, arguments, safety, abi, | |||
return_ty, yield_ty, return_ty_span, body) | |||
} else { | |||
build::construct_const(cx, body_id, return_ty_span) | |||
// Get the revealed type of this const. This is *not* the adjusted | |||
// type of it's body, which may be a subtype of this type. For |
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.
// type of it's body, which may be a subtype of this type. For | |
// type of its body, which may be a subtype of this type. For |
This looks reasonable to me, but I'm not so familiar with the MIR design choices, so it'd be good for someone to double-check. r? @oli-obk |
ping from triage @oli-obk waiting for your review on this |
☔ The latest upstream changes (presumably #59987) made this pull request unmergeable. Please resolve the merge conflicts. |
95b5423
to
d3518a2
Compare
☔ The latest upstream changes (presumably #60224) made this pull request unmergeable. Please resolve the merge conflicts. |
lgtm. r=me after a rebase sorry about taking so long |
Cast type may be a subtype of the destination type. There is a later assertion that they have the same layout.
Fixes an ICE for the following code: fn foo(_ : &()) {} static X: fn(&'static ()) = foo;
This avoids some unnecessary moves
d3518a2
to
e9c687b
Compare
@bors r=oli-obk |
📌 Commit e9c687b has been approved by |
…p, r=oli-obk MIR generation cleanup * Handle the case where the body of a constant is a subtype of the type of the constant (see `mir_static_subtype.rs`). * Move the evaluation of `ExprKind::Use` into `into.rs`, saving an unnecessary copy.
Rollup of 6 pull requests Successful merges: - #59560 (MIR generation cleanup) - #59697 (tweak unresolved label suggestion) - #60038 (Add codegen test for PGO instrumentation.) - #60160 (Fix #58270, fix off-by-one error in error diagnostics.) - #60185 (Reexport IntErrorKind in std) - #60243 (Add regression test for #53249.) Failed merges: r? @ghost
mir_static_subtype.rs
).ExprKind::Use
intointo.rs
, saving an unnecessary copy.