Skip to content

Commit 7d7a531

Browse files
committed
Use polymorphic drop shim from upstream
1 parent ec0ee82 commit 7d7a531

9 files changed

Lines changed: 30 additions & 2116 deletions

File tree

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ extern crate rustc_lint;
3636
extern crate rustc_log;
3737
extern crate rustc_metadata;
3838
extern crate rustc_mir_dataflow;
39+
extern crate rustc_mir_transform;
3940
extern crate rustc_monomorphize;
4041
extern crate rustc_serialize;
4142
extern crate rustc_session;

src/mir.rs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,13 @@
22
//
33
// SPDX-License-Identifier: MIT OR Apache-2.0
44

5-
pub mod drop_shim;
6-
pub mod elaborate_drop;
7-
pub mod patch;
8-
95
use rustc_hir::{self as hir, def::DefKind};
106
use rustc_middle::mir::CallSource;
117
use rustc_middle::mir::{
128
Body, ConstOperand, LocalDecl, Operand, Place, ProjectionElem, Rvalue, SourceInfo, Statement,
139
StatementKind, TerminatorKind, WithRetag,
1410
};
15-
use rustc_middle::ty::{self, TyCtxt};
11+
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypingEnv};
1612
use rustc_span::def_id::{CrateNum, DefId, DefIndex, LocalDefId};
1713
use rustc_span::{DUMMY_SP, Spanned, sym};
1814

@@ -140,6 +136,22 @@ impl PersistentQuery for analysis_mir {
140136
}
141137
}
142138

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+
143155
impl<'tcx> AnalysisCtxt<'tcx> {
144156
/// Save all MIRs defined in the current crate to the database.
145157
pub fn encode_mir(&self) {

src/mir/drop_shim.rs

Lines changed: 0 additions & 213 deletions
This file was deleted.

0 commit comments

Comments
 (0)