mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
remove ClosureSubsts with SubstsRef
This commit is contained in:
@@ -896,7 +896,7 @@ fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
}
|
||||
}));
|
||||
|
||||
self.tcx.mk_closure(def_id, ty::ClosureSubsts { substs })
|
||||
self.tcx.mk_closure(def_id, substs)
|
||||
}
|
||||
|
||||
ty::Generator(def_id, substs, movability) => {
|
||||
|
||||
@@ -745,7 +745,8 @@ fn cat_upvar(
|
||||
// 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 =>
|
||||
|
||||
@@ -218,7 +218,7 @@ pub fn ty<D>(&self, local_decls: &D, tcx: TyCtxt<'tcx>) -> Ty<'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)
|
||||
|
||||
@@ -2051,7 +2051,8 @@ fn assemble_closure_candidates(
|
||||
"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 @@ fn confirm_closure_candidate(
|
||||
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 @@ fn closure_trait_ref_unnormalized(
|
||||
"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 = {:?}",
|
||||
|
||||
@@ -402,7 +402,7 @@ pub fn upvar_tys(
|
||||
) -> 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")
|
||||
|
||||
@@ -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)
|
||||
};
|
||||
|
||||
@@ -201,7 +201,9 @@ pub fn codegen_rvalue_operand(
|
||||
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))
|
||||
}
|
||||
_ => {
|
||||
|
||||
@@ -224,7 +224,7 @@ fn print_type(
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ fn print_type(
|
||||
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)?;
|
||||
}
|
||||
|
||||
@@ -509,7 +509,8 @@ fn defining_ty(&self) -> DefiningTy<'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 @@ fn compute_inputs_and_output(
|
||||
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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -75,7 +75,7 @@ pub fn cast(
|
||||
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));
|
||||
|
||||
@@ -67,7 +67,7 @@ fn print_type(mut self, ty: Ty<'tcx>) -> Result<Self::Type, Self::Error> {
|
||||
| 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, &[]),
|
||||
|
||||
@@ -581,7 +581,8 @@ fn visit_rvalue(&mut self, rvalue: &mir::Rvalue<'tcx>, location: Location) {
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -69,9 +69,7 @@
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
@@ -103,6 +103,7 @@ fn try_overloaded_call_step(
|
||||
// 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
|
||||
|
||||
@@ -132,7 +132,6 @@ fn check_closure(
|
||||
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!(
|
||||
|
||||
@@ -237,7 +237,8 @@ fn coerce(&self, a: Ty<'tcx>, b: Ty<'tcx>) -> CoerceResult<'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.
|
||||
|
||||
@@ -96,7 +96,8 @@ fn analyze_closure(
|
||||
// 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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user