|
2 | 2 | // |
3 | 3 | // SPDX-License-Identifier: MIT OR Apache-2.0 |
4 | 4 |
|
5 | | -pub mod drop_shim; |
6 | | -pub mod elaborate_drop; |
7 | | -pub mod patch; |
8 | | - |
9 | 5 | use rustc_hir::{self as hir, def::DefKind}; |
10 | 6 | use rustc_middle::mir::CallSource; |
11 | 7 | use rustc_middle::mir::{ |
12 | 8 | Body, ConstOperand, LocalDecl, Operand, Place, ProjectionElem, Rvalue, SourceInfo, Statement, |
13 | 9 | StatementKind, TerminatorKind, WithRetag, |
14 | 10 | }; |
15 | | -use rustc_middle::ty::{self, TyCtxt}; |
| 11 | +use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypingEnv}; |
16 | 12 | use rustc_span::def_id::{CrateNum, DefId, DefIndex, LocalDefId}; |
17 | 13 | use rustc_span::{DUMMY_SP, Spanned, sym}; |
18 | 14 |
|
@@ -140,6 +136,22 @@ impl PersistentQuery for analysis_mir { |
140 | 136 | } |
141 | 137 | } |
142 | 138 |
|
| 139 | +pub fn build_drop_shim<'tcx>( |
| 140 | + cx: &AnalysisCtxt<'tcx>, |
| 141 | + def_id: DefId, |
| 142 | + typing_env: TypingEnv<'tcx>, |
| 143 | + ty: Ty<'tcx>, |
| 144 | +) -> Body<'tcx> { |
| 145 | + // TODO: Replicate coroutine handling in rustc_mir_transform/shim.rs |
| 146 | + if let ty::Coroutine(gen_def_id, args) = ty.kind() { |
| 147 | + let body = cx.analysis_mir(*gen_def_id).coroutine_drop().unwrap(); |
| 148 | + let body = EarlyBinder::bind(body.clone()).instantiate(cx.tcx, args); |
| 149 | + return body.skip_norm_wip(); |
| 150 | + } |
| 151 | + |
| 152 | + rustc_mir_transform::build_drop_shim(cx.tcx, def_id, Some(ty), typing_env) |
| 153 | +} |
| 154 | + |
143 | 155 | impl<'tcx> AnalysisCtxt<'tcx> { |
144 | 156 | /// Save all MIRs defined in the current crate to the database. |
145 | 157 | pub fn encode_mir(&self) { |
|
0 commit comments