diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc/infer/opaque_types/mod.rs | 2 | ||||
| -rw-r--r-- | src/librustc/middle/mem_categorization.rs | 3 | ||||
| -rw-r--r-- | src/librustc/mir/tcx.rs | 2 | ||||
| -rw-r--r-- | src/librustc/traits/select.rs | 9 | ||||
| -rw-r--r-- | src/librustc/ty/subst.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/mod.rs | 3 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/rvalue.rs | 4 | ||||
| -rw-r--r-- | src/librustc_codegen_utils/symbol_names/legacy.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_utils/symbol_names/v0.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/borrow_check/nll/universal_regions.rs | 5 | ||||
| -rw-r--r-- | src/librustc_mir/hair/cx/expr.rs | 8 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/cast.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/intrinsics/type_name.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 3 | ||||
| -rw-r--r-- | src/librustc_traits/generic_types.rs | 4 | ||||
| -rw-r--r-- | src/librustc_typeck/check/callee.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/check/closure.rs | 1 | ||||
| -rw-r--r-- | src/librustc_typeck/check/coercion.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/check/upvar.rs | 3 | ||||
| -rw-r--r-- | src/librustc_typeck/collect.rs | 5 |
20 files changed, 37 insertions, 29 deletions
diff --git a/src/librustc/infer/opaque_types/mod.rs b/src/librustc/infer/opaque_types/mod.rs index ff7cd59720f..8cc7dbb3c5c 100644 --- a/src/librustc/infer/opaque_types/mod.rs +++ b/src/librustc/infer/opaque_types/mod.rs @@ -896,7 +896,7 @@ impl TypeFolder<'tcx> for ReverseMapper<'tcx> { } })); - self.tcx.mk_closure(def_id, ty::ClosureSubsts { substs }) + self.tcx.mk_closure(def_id, substs) } ty::Generator(def_id, substs, movability) => { diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 5595047831c..522c0e55b85 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -745,7 +745,8 @@ impl<'a, 'tcx> MemCategorizationContext<'a, 'tcx> { // During upvar inference we may not know the // closure kind, just use the LATTICE_BOTTOM value. Some(infcx) => - infcx.closure_kind(closure_def_id, ty::ClosureSubsts::from_ref(closure_substs)) + infcx.closure_kind(closure_def_id, + ty::ClosureSubsts::from_ref(closure_substs)) .unwrap_or(ty::ClosureKind::LATTICE_BOTTOM), None => diff --git a/src/librustc/mir/tcx.rs b/src/librustc/mir/tcx.rs index 26f718e858d..44829f670fa 100644 --- a/src/librustc/mir/tcx.rs +++ b/src/librustc/mir/tcx.rs @@ -218,7 +218,7 @@ impl<'tcx> Rvalue<'tcx> { tcx.type_of(def.did).subst(tcx, substs) } AggregateKind::Closure(did, substs) => { - tcx.mk_closure(did, substs) + tcx.mk_closure(did, &substs.substs) } AggregateKind::Generator(did, substs, movability) => { tcx.mk_generator(did, substs, movability) diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index 4d025fe7318..3450f3fc865 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -2051,7 +2051,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { "assemble_unboxed_candidates: kind={:?} obligation={:?}", kind, obligation ); - match self.infcx.closure_kind(closure_def_id, closure_substs) { + match self.infcx.closure_kind(closure_def_id, + ty::ClosureSubsts::from_ref(closure_substs)) { Some(closure_kind) => { debug!( "assemble_unboxed_candidates: closure_kind = {:?}", @@ -3375,7 +3376,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { obligations.push(Obligation::new( obligation.cause.clone(), obligation.param_env, - ty::Predicate::ClosureKind(closure_def_id, ty::ClosureSubsts::from_ref(substs.clone()), kind), + ty::Predicate::ClosureKind(closure_def_id, + ty::ClosureSubsts::from_ref(substs.clone()), kind), )); } @@ -3876,7 +3878,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { "closure_trait_ref_unnormalized(obligation={:?}, closure_def_id={:?}, substs={:?})", obligation, closure_def_id, substs, ); - let closure_type = self.infcx.closure_sig(closure_def_id, substs); + let closure_type = self.infcx.closure_sig(closure_def_id, + ty::ClosureSubsts::from_ref(substs)); debug!( "closure_trait_ref_unnormalized: closure_type = {:?}", diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index 6e00c6b29ec..05042ccf9a1 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -402,7 +402,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> { ) -> impl Iterator<Item = Ty<'a>> + 'a { let SplitClosureSubsts { upvar_kinds, .. } = self.split(def_id, tcx); upvar_kinds.iter().map(|t| { - if let UnpackedKind::Type(ty) = t.unpack() { + if let GenericArgKind::Type(ty) = t.unpack() { ty } else { bug!("upvar should be type") diff --git a/src/librustc_codegen_ssa/mir/mod.rs b/src/librustc_codegen_ssa/mir/mod.rs index 4f3a8bdb540..30d519c8733 100644 --- a/src/librustc_codegen_ssa/mir/mod.rs +++ b/src/librustc_codegen_ssa/mir/mod.rs @@ -615,7 +615,8 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( }; let (def_id, upvar_substs) = match closure_layout.ty.kind { - ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), + ty::Closure(def_id, substs) => (def_id, + UpvarSubsts::Closure(rustc::ty::ClosureSubsts::from_ref(substs))), ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), _ => bug!("upvar debuginfo with non-closure arg0 type `{}`", closure_layout.ty) }; diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 9b69383b455..9cc21a28b27 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -201,7 +201,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { match operand.layout.ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - bx.cx().tcx(), def_id, substs, ty::ClosureKind::FnOnce); + bx.cx().tcx(), def_id, + rustc::ty::ClosureSubsts::from_ref(substs), + ty::ClosureKind::FnOnce); OperandValue::Immediate(bx.cx().get_fn(instance)) } _ => { diff --git a/src/librustc_codegen_utils/symbol_names/legacy.rs b/src/librustc_codegen_utils/symbol_names/legacy.rs index a9866c8c0b2..5bcb3b4ceb3 100644 --- a/src/librustc_codegen_utils/symbol_names/legacy.rs +++ b/src/librustc_codegen_utils/symbol_names/legacy.rs @@ -224,7 +224,7 @@ impl Printer<'tcx> for SymbolPrinter<'tcx> { ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | - ty::Closure(def_id, ty::ClosureSubsts { substs }) | + ty::Closure(def_id, substs) | ty::Generator(def_id, ty::GeneratorSubsts { substs }, _) => { self.print_def_path(def_id, substs) } diff --git a/src/librustc_codegen_utils/symbol_names/v0.rs b/src/librustc_codegen_utils/symbol_names/v0.rs index a63236305dc..2ad699d7c6f 100644 --- a/src/librustc_codegen_utils/symbol_names/v0.rs +++ b/src/librustc_codegen_utils/symbol_names/v0.rs @@ -414,7 +414,7 @@ impl Printer<'tcx> for SymbolMangler<'tcx> { ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) | - ty::Closure(def_id, ty::ClosureSubsts { substs }) | + ty::Closure(def_id, substs) | ty::Generator(def_id, ty::GeneratorSubsts { substs }, _) => { self = self.print_def_path(def_id, substs)?; } diff --git a/src/librustc_mir/borrow_check/nll/universal_regions.rs b/src/librustc_mir/borrow_check/nll/universal_regions.rs index 7053bdca259..80ed90ede4d 100644 --- a/src/librustc_mir/borrow_check/nll/universal_regions.rs +++ b/src/librustc_mir/borrow_check/nll/universal_regions.rs @@ -509,7 +509,8 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { .replace_free_regions_with_nll_infer_vars(FR, &defining_ty); match defining_ty.kind { - ty::Closure(def_id, substs) => DefiningTy::Closure(def_id, substs), + ty::Closure(def_id, substs) => DefiningTy::Closure(def_id, + rustc::ty::ClosureSubsts::from_ref(substs)), ty::Generator(def_id, substs, movability) => { DefiningTy::Generator(def_id, substs, movability) } @@ -584,7 +585,7 @@ impl<'cx, 'tcx> UniversalRegionsBuilder<'cx, 'tcx> { assert_eq!(self.mir_def_id, def_id); let closure_sig = substs.closure_sig_ty(def_id, tcx).fn_sig(tcx); let inputs_and_output = closure_sig.inputs_and_output(); - let closure_ty = tcx.closure_env_ty(def_id, substs).unwrap(); + let closure_ty = tcx.closure_env_ty(def_id, substs.substs).unwrap(); ty::Binder::fuse( closure_ty, inputs_and_output, diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index eed51cdab8c..e4d26bda40f 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -506,7 +506,8 @@ fn make_mirror_unadjusted<'a, 'tcx>( hir::ExprKind::Closure(..) => { let closure_ty = cx.tables().expr_ty(expr); let (def_id, substs, movability) = match closure_ty.kind { - ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None), + ty::Closure(def_id, substs) => (def_id, + UpvarSubsts::Closure(rustc::ty::ClosureSubsts::from_ref(substs)), None), ty::Generator(def_id, substs, movability) => { (def_id, UpvarSubsts::Generator(substs), Some(movability)) } @@ -1002,7 +1003,8 @@ fn convert_var( let region = cx.tcx.mk_region(region); let self_expr = if let ty::Closure(_, closure_substs) = closure_ty.kind { - match cx.infcx.closure_kind(closure_def_id, closure_substs).unwrap() { + match cx.infcx.closure_kind(closure_def_id, + rustc::ty::ClosureSubsts::from_ref(closure_substs)).unwrap() { ty::ClosureKind::Fn => { let ref_closure_ty = cx.tcx.mk_ref(region, ty::TypeAndMut { @@ -1011,7 +1013,7 @@ fn convert_var( }); Expr { ty: closure_ty, - temp_lifetime: temp_lifetime, + temp_lifetime, span: expr.span, kind: ExprKind::Deref { arg: Expr { diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index d120412c901..943054cc696 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -75,7 +75,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { let instance = ty::Instance::resolve_closure( *self.tcx, def_id, - substs, + rustc::ty::ClosureSubsts::from_ref(substs), ty::ClosureKind::FnOnce, ); let fn_ptr = self.memory.create_fn_alloc(FnVal::Instance(instance)); diff --git a/src/librustc_mir/interpret/intrinsics/type_name.rs b/src/librustc_mir/interpret/intrinsics/type_name.rs index a8b4d65e7d4..dc3b7694c35 100644 --- a/src/librustc_mir/interpret/intrinsics/type_name.rs +++ b/src/librustc_mir/interpret/intrinsics/type_name.rs @@ -67,7 +67,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> { | ty::Opaque(def_id, substs) | ty::Projection(ty::ProjectionTy { item_def_id: def_id, substs }) | ty::UnnormalizedProjection(ty::ProjectionTy { item_def_id: def_id, substs }) - | ty::Closure(def_id, ty::ClosureSubsts { substs }) + | ty::Closure(def_id, substs) | ty::Generator(def_id, ty::GeneratorSubsts { substs }, _) => self.print_def_path(def_id, substs), ty::Foreign(def_id) => self.print_def_path(def_id, &[]), diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index cc8f4759e18..21aea5593ee 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -581,7 +581,8 @@ impl<'a, 'tcx> MirVisitor<'tcx> for MirNeighborCollector<'a, 'tcx> { match source_ty.kind { ty::Closure(def_id, substs) => { let instance = Instance::resolve_closure( - self.tcx, def_id, substs, ty::ClosureKind::FnOnce); + self.tcx, def_id, + rustc::ty::ClosureSubsts::from_ref(substs), ty::ClosureKind::FnOnce); if should_monomorphize_locally(self.tcx, &instance) { self.output.push(create_fn_mono_item(instance)); } diff --git a/src/librustc_traits/generic_types.rs b/src/librustc_traits/generic_types.rs index e4d15a35137..91ca6415bdc 100644 --- a/src/librustc_traits/generic_types.rs +++ b/src/librustc_traits/generic_types.rs @@ -69,9 +69,7 @@ crate fn fn_def(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { } crate fn closure(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { - tcx.mk_closure(def_id, ty::ClosureSubsts { - substs: InternalSubsts::bound_vars_for_item(tcx, def_id), - }) + tcx.mk_closure(def_id, InternalSubsts::bound_vars_for_item(tcx, def_id)) } crate fn generator(tcx: TyCtxt<'tcx>, def_id: DefId) -> Ty<'tcx> { diff --git a/src/librustc_typeck/check/callee.rs b/src/librustc_typeck/check/callee.rs index 290b87388eb..3a169268720 100644 --- a/src/librustc_typeck/check/callee.rs +++ b/src/librustc_typeck/check/callee.rs @@ -103,6 +103,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Check whether this is a call to a closure where we // haven't yet decided on whether the closure is fn vs // fnmut vs fnonce. If so, we have to defer further processing. + let substs = rustc::ty::ClosureSubsts::from_ref(substs); if self.closure_kind(def_id, substs).is_none() { let closure_ty = self.closure_sig(def_id, substs); let fn_sig = self diff --git a/src/librustc_typeck/check/closure.rs b/src/librustc_typeck/check/closure.rs index bdf8f3b1d4a..09dcce003fe 100644 --- a/src/librustc_typeck/check/closure.rs +++ b/src/librustc_typeck/check/closure.rs @@ -132,7 +132,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { return self.tcx.mk_generator(expr_def_id, substs, movability); } - let substs = ty::ClosureSubsts { substs }; let closure_type = self.tcx.mk_closure(expr_def_id, substs); debug!( diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index 564a0eac755..c10279022bd 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -237,7 +237,8 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> { // Non-capturing closures are coercible to // function pointers or unsafe function pointers. // It cannot convert closures that require unsafe. - self.coerce_closure_to_fn(a, def_id_a, substs_a, b) + self.coerce_closure_to_fn(a, def_id_a, + rustc::ty::ClosureSubsts::from_ref(substs_a), b) } _ => { // Otherwise, just use unification rules. diff --git a/src/librustc_typeck/check/upvar.rs b/src/librustc_typeck/check/upvar.rs index 71ea938a803..5b7c5c04e44 100644 --- a/src/librustc_typeck/check/upvar.rs +++ b/src/librustc_typeck/check/upvar.rs @@ -96,7 +96,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { // Extract the type of the closure. let ty = self.node_ty(closure_hir_id); let (closure_def_id, substs) = match ty.kind { - ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs)), + ty::Closure(def_id, substs) => (def_id, + UpvarSubsts::Closure(rustc::ty::ClosureSubsts::from_ref(substs))), ty::Generator(def_id, substs, _) => (def_id, UpvarSubsts::Generator(substs)), ty::Error => { // #51714: skip analysis when we have already encountered type errors diff --git a/src/librustc_typeck/collect.rs b/src/librustc_typeck/collect.rs index 8c3d6357f0b..1690ae7635f 100644 --- a/src/librustc_typeck/collect.rs +++ b/src/librustc_typeck/collect.rs @@ -1362,10 +1362,7 @@ pub fn checked_type_of(tcx: TyCtxt<'_>, def_id: DefId, fail: bool) -> Option<Ty< return Some(tcx.typeck_tables_of(def_id).node_type(hir_id)); } - let substs = ty::ClosureSubsts { - substs: InternalSubsts::identity_for_item(tcx, def_id), - }; - + let substs = InternalSubsts::identity_for_item(tcx, def_id); tcx.mk_closure(def_id, substs) } |
