Skip to content

Commit dbcabc2

Browse files
committed
instantiate_opaque_types LocalDefId
1 parent 20d6941 commit dbcabc2

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

src/librustc_mir/borrow_check/type_check/input_output.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
122122
if let Err(terr) = self.eq_opaque_type_and_type(
123123
mir_output_ty,
124124
normalized_output_ty,
125-
self.mir_def_id.to_def_id(),
125+
self.mir_def_id,
126126
Locations::All(output_span),
127127
ConstraintCategory::BoringNoLocation,
128128
) {
@@ -145,7 +145,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
145145
if let Err(err) = self.eq_opaque_type_and_type(
146146
mir_output_ty,
147147
user_provided_output_ty,
148-
self.mir_def_id.to_def_id(),
148+
self.mir_def_id,
149149
Locations::All(output_span),
150150
ConstraintCategory::BoringNoLocation,
151151
) {

src/librustc_mir/borrow_check/type_check/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,8 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
11441144
// When you have `let x: impl Foo = ...` in a closure,
11451145
// the resulting inferend values are stored with the
11461146
// def-id of the base function.
1147-
let parent_def_id = self.tcx().closure_base_def_id(self.mir_def_id.to_def_id());
1147+
let parent_def_id =
1148+
self.tcx().closure_base_def_id(self.mir_def_id.to_def_id()).expect_local();
11481149
return self.eq_opaque_type_and_type(sub, sup, parent_def_id, locations, category);
11491150
} else {
11501151
return Err(terr);
@@ -1208,7 +1209,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12081209
&mut self,
12091210
revealed_ty: Ty<'tcx>,
12101211
anon_ty: Ty<'tcx>,
1211-
anon_owner_def_id: DefId,
1212+
anon_owner_def_id: LocalDefId,
12121213
locations: Locations,
12131214
category: ConstraintCategory,
12141215
) -> Fallible<()> {
@@ -1238,8 +1239,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12381239
let tcx = infcx.tcx;
12391240
let param_env = self.param_env;
12401241
let body = self.body;
1241-
let concrete_opaque_types =
1242-
&tcx.typeck_tables_of(anon_owner_def_id.expect_local()).concrete_opaque_types;
1242+
let concrete_opaque_types = &tcx.typeck_tables_of(anon_owner_def_id).concrete_opaque_types;
12431243
let mut opaque_type_values = Vec::new();
12441244

12451245
debug!("eq_opaque_type_and_type: mir_def_id={:?}", self.mir_def_id);

src/librustc_trait_selection/opaque_types.rs

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ pub enum GenerateMemberConstraints {
108108
pub trait InferCtxtExt<'tcx> {
109109
fn instantiate_opaque_types<T: TypeFoldable<'tcx>>(
110110
&self,
111-
parent_def_id: DefId,
111+
parent_def_id: LocalDefId,
112112
body_id: hir::HirId,
113113
param_env: ty::ParamEnv<'tcx>,
114114
value: &T,
@@ -184,7 +184,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
184184
/// - `value_span` -- the span where the value came from, used in error reporting
185185
fn instantiate_opaque_types<T: TypeFoldable<'tcx>>(
186186
&self,
187-
parent_def_id: DefId,
187+
parent_def_id: LocalDefId,
188188
body_id: hir::HirId,
189189
param_env: ty::ParamEnv<'tcx>,
190190
value: &T,
@@ -986,7 +986,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> {
986986

987987
struct Instantiator<'a, 'tcx> {
988988
infcx: &'a InferCtxt<'a, 'tcx>,
989-
parent_def_id: DefId,
989+
parent_def_id: LocalDefId,
990990
body_id: hir::HirId,
991991
param_env: ty::ParamEnv<'tcx>,
992992
value_span: Span,
@@ -1043,8 +1043,7 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10431043
let parent_def_id = self.parent_def_id;
10441044
let def_scope_default = || {
10451045
let opaque_parent_hir_id = tcx.hir().get_parent_item(opaque_hir_id);
1046-
parent_def_id
1047-
== tcx.hir().local_def_id(opaque_parent_hir_id).to_def_id()
1046+
parent_def_id == tcx.hir().local_def_id(opaque_parent_hir_id)
10481047
};
10491048
let (in_definition_scope, origin) = match tcx.hir().find(opaque_hir_id) {
10501049
Some(Node::Item(item)) => match item.kind {
@@ -1053,18 +1052,14 @@ impl<'a, 'tcx> Instantiator<'a, 'tcx> {
10531052
impl_trait_fn: Some(parent),
10541053
origin,
10551054
..
1056-
}) => (parent == self.parent_def_id, origin),
1055+
}) => (parent == self.parent_def_id.to_def_id(), origin),
10571056
// Named `type Foo = impl Bar;`
10581057
hir::ItemKind::OpaqueTy(hir::OpaqueTy {
10591058
impl_trait_fn: None,
10601059
origin,
10611060
..
10621061
}) => (
1063-
may_define_opaque_type(
1064-
tcx,
1065-
self.parent_def_id.expect_local(),
1066-
opaque_hir_id,
1067-
),
1062+
may_define_opaque_type(tcx, self.parent_def_id, opaque_hir_id),
10681063
origin,
10691064
),
10701065
_ => (def_scope_default(), hir::OpaqueTyOrigin::Misc),

src/librustc_typeck/check/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1321,8 +1321,8 @@ fn check_fn<'a, 'tcx>(
13211321
fcx.resume_yield_tys = Some((resume_ty, yield_ty));
13221322
}
13231323

1324-
let outer_def_id = tcx.closure_base_def_id(hir.local_def_id(fn_id).to_def_id());
1325-
let outer_hir_id = hir.as_local_hir_id(outer_def_id.expect_local());
1324+
let outer_def_id = tcx.closure_base_def_id(hir.local_def_id(fn_id).to_def_id()).expect_local();
1325+
let outer_hir_id = hir.as_local_hir_id(outer_def_id);
13261326
GatherLocalsVisitor { fcx: &fcx, parent_id: outer_hir_id }.visit_body(body);
13271327

13281328
// C-variadic fns also have a `VaList` input that's not listed in `fn_sig`
@@ -3427,7 +3427,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
34273427

34283428
let (value, opaque_type_map) =
34293429
self.register_infer_ok_obligations(self.instantiate_opaque_types(
3430-
parent_def_id.to_def_id(),
3430+
parent_def_id,
34313431
self.body_id,
34323432
self.param_env,
34333433
value,

0 commit comments

Comments
 (0)