Fix inline const pattern unsafety checking in THIR
THIR unsafety checking was getting a cycle of function unsafety checking -> building THIR for the function -> evaluating pattern inline constants in the function -> building MIR for the inline constant -> checking unsafety of functions (so that THIR can be stolen) This is fixed by not stealing THIR when generating MIR but instead when unsafety checking. This leaves an issue with pattern inline constants not being unsafety checked because they are evaluated away when generating THIR. To fix that we now represent inline constants in THIR patterns and visit them in THIR unsafety checking.
This commit is contained in:
parent
e7bdc5f9f8
commit
5cc83fd4a5
24 changed files with 239 additions and 50 deletions
|
@ -775,12 +775,16 @@ fn analysis(tcx: TyCtxt<'_>, (): ()) -> Result<()> {
|
|||
rustc_hir_analysis::check_crate(tcx)?;
|
||||
|
||||
sess.time("MIR_borrow_checking", || {
|
||||
tcx.hir().par_body_owners(|def_id| tcx.ensure().mir_borrowck(def_id));
|
||||
tcx.hir().par_body_owners(|def_id| {
|
||||
// Run THIR unsafety check because it's responsible for stealing
|
||||
// and deallocating THIR when enabled.
|
||||
tcx.ensure().thir_check_unsafety(def_id);
|
||||
tcx.ensure().mir_borrowck(def_id)
|
||||
});
|
||||
});
|
||||
|
||||
sess.time("MIR_effect_checking", || {
|
||||
for def_id in tcx.hir().body_owners() {
|
||||
tcx.ensure().thir_check_unsafety(def_id);
|
||||
if !tcx.sess.opts.unstable_opts.thir_unsafeck {
|
||||
rustc_mir_transform::check_unsafety::check_unsafety(tcx, def_id);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue