refactor(rustc_middle): Substs -> GenericArg
This commit is contained in:
parent
df5c2cf9bc
commit
e55583c4b8
466 changed files with 4574 additions and 4604 deletions
|
@ -192,12 +192,12 @@ impl<'tcx, 'body> ParseCtxt<'tcx, 'body> {
|
|||
fields.iter().map(|e| self.parse_operand(*e)).collect::<Result<_, _>>()?
|
||||
))
|
||||
},
|
||||
ExprKind::Adt(box AdtExpr{ adt_def, variant_index, substs, fields, .. }) => {
|
||||
ExprKind::Adt(box AdtExpr{ adt_def, variant_index, args, fields, .. }) => {
|
||||
let is_union = adt_def.is_union();
|
||||
let active_field_index = is_union.then(|| fields[0].name);
|
||||
|
||||
Ok(Rvalue::Aggregate(
|
||||
Box::new(AggregateKind::Adt(adt_def.did(), *variant_index, substs, None, active_field_index)),
|
||||
Box::new(AggregateKind::Adt(adt_def.did(), *variant_index, args, None, active_field_index)),
|
||||
fields.iter().map(|f| self.parse_operand(f.expr)).collect::<Result<_, _>>()?
|
||||
))
|
||||
},
|
||||
|
|
|
@ -75,10 +75,10 @@ pub fn as_constant_inner<'tcx>(
|
|||
|
||||
Constant { span, user_ty, literal }
|
||||
}
|
||||
ExprKind::NamedConst { def_id, substs, ref user_ty } => {
|
||||
ExprKind::NamedConst { def_id, args, ref user_ty } => {
|
||||
let user_ty = user_ty.as_ref().and_then(push_cuta);
|
||||
|
||||
let uneval = mir::UnevaluatedConst::new(def_id, substs);
|
||||
let uneval = mir::UnevaluatedConst::new(def_id, args);
|
||||
let literal = ConstantKind::Unevaluated(uneval, ty);
|
||||
|
||||
Constant { user_ty, span, literal }
|
||||
|
@ -89,8 +89,8 @@ pub fn as_constant_inner<'tcx>(
|
|||
|
||||
Constant { user_ty: None, span, literal }
|
||||
}
|
||||
ExprKind::ConstBlock { did: def_id, substs } => {
|
||||
let uneval = mir::UnevaluatedConst::new(def_id, substs);
|
||||
ExprKind::ConstBlock { did: def_id, args } => {
|
||||
let uneval = mir::UnevaluatedConst::new(def_id, args);
|
||||
let literal = ConstantKind::Unevaluated(uneval, ty);
|
||||
|
||||
Constant { user_ty: None, span, literal }
|
||||
|
|
|
@ -16,7 +16,7 @@ use rustc_middle::mir::*;
|
|||
use rustc_middle::thir::*;
|
||||
use rustc_middle::ty::cast::{mir_cast_kind, CastTy};
|
||||
use rustc_middle::ty::layout::IntegerExt;
|
||||
use rustc_middle::ty::{self, Ty, UpvarSubsts};
|
||||
use rustc_middle::ty::{self, Ty, UpvarArgs};
|
||||
use rustc_span::Span;
|
||||
|
||||
impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
|
@ -382,7 +382,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
ExprKind::Closure(box ClosureExpr {
|
||||
closure_id,
|
||||
substs,
|
||||
args,
|
||||
ref upvars,
|
||||
movability,
|
||||
ref fake_reads,
|
||||
|
@ -470,19 +470,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
})
|
||||
.collect();
|
||||
|
||||
let result = match substs {
|
||||
UpvarSubsts::Generator(substs) => {
|
||||
let result = match args {
|
||||
UpvarArgs::Generator(args) => {
|
||||
// We implicitly set the discriminant to 0. See
|
||||
// librustc_mir/transform/deaggregator.rs for details.
|
||||
let movability = movability.unwrap();
|
||||
Box::new(AggregateKind::Generator(
|
||||
closure_id.to_def_id(),
|
||||
substs,
|
||||
movability,
|
||||
))
|
||||
Box::new(AggregateKind::Generator(closure_id.to_def_id(), args, movability))
|
||||
}
|
||||
UpvarSubsts::Closure(substs) => {
|
||||
Box::new(AggregateKind::Closure(closure_id.to_def_id(), substs))
|
||||
UpvarArgs::Closure(args) => {
|
||||
Box::new(AggregateKind::Closure(closure_id.to_def_id(), args))
|
||||
}
|
||||
};
|
||||
block.and(Rvalue::Aggregate(result, operands))
|
||||
|
|
|
@ -317,7 +317,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
ExprKind::Adt(box AdtExpr {
|
||||
adt_def,
|
||||
variant_index,
|
||||
substs,
|
||||
args,
|
||||
ref user_ty,
|
||||
ref fields,
|
||||
ref base,
|
||||
|
@ -382,7 +382,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
let adt = Box::new(AggregateKind::Adt(
|
||||
adt_def.did(),
|
||||
variant_index,
|
||||
substs,
|
||||
args,
|
||||
user_ty,
|
||||
active_field_index,
|
||||
));
|
||||
|
|
|
@ -806,7 +806,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatKind::Variant { adt_def, substs: _, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant { adt_def, args: _, variant_index, ref subpatterns } => {
|
||||
for subpattern in subpatterns {
|
||||
let subpattern_user_ty =
|
||||
pattern_user_ty.clone().variant(adt_def, variant_index, subpattern.field);
|
||||
|
|
|
@ -259,13 +259,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
PatKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant { adt_def, args, variant_index, ref subpatterns } => {
|
||||
let irrefutable = adt_def.variants().iter_enumerated().all(|(i, v)| {
|
||||
i == variant_index || {
|
||||
self.tcx.features().exhaustive_patterns
|
||||
&& !v
|
||||
.inhabited_predicate(self.tcx, adt_def)
|
||||
.subst(self.tcx, substs)
|
||||
.instantiate(self.tcx, args)
|
||||
.apply_ignore_module(self.tcx, self.param_env)
|
||||
}
|
||||
}) && (adt_def.did().is_local()
|
||||
|
|
|
@ -30,7 +30,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
/// It is a bug to call this with a not-fully-simplified pattern.
|
||||
pub(super) fn test<'pat>(&mut self, match_pair: &MatchPair<'pat, 'tcx>) -> Test<'tcx> {
|
||||
match match_pair.pattern.kind {
|
||||
PatKind::Variant { adt_def, substs: _, variant_index: _, subpatterns: _ } => Test {
|
||||
PatKind::Variant { adt_def, args: _, variant_index: _, subpatterns: _ } => Test {
|
||||
span: match_pair.pattern.span,
|
||||
kind: TestKind::Switch {
|
||||
adt_def,
|
||||
|
@ -867,7 +867,7 @@ fn trait_method<'tcx>(
|
|||
tcx: TyCtxt<'tcx>,
|
||||
trait_def_id: DefId,
|
||||
method_name: Symbol,
|
||||
substs: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
args: impl IntoIterator<Item: Into<GenericArg<'tcx>>>,
|
||||
) -> ConstantKind<'tcx> {
|
||||
// The unhygienic comparison here is acceptable because this is only
|
||||
// used on known traits.
|
||||
|
@ -877,7 +877,7 @@ fn trait_method<'tcx>(
|
|||
.find(|item| item.kind == ty::AssocKind::Fn)
|
||||
.expect("trait method not found");
|
||||
|
||||
let method_ty = Ty::new_fn_def(tcx, item.def_id, substs);
|
||||
let method_ty = Ty::new_fn_def(tcx, item.def_id, args);
|
||||
|
||||
ConstantKind::zero_sized(method_ty)
|
||||
}
|
||||
|
|
|
@ -482,7 +482,7 @@ fn construct_fn<'tcx>(
|
|||
let (yield_ty, return_ty) = if generator_kind.is_some() {
|
||||
let gen_ty = arguments[thir::UPVAR_ENV_PARAM].ty;
|
||||
let gen_sig = match gen_ty.kind() {
|
||||
ty::Generator(_, gen_substs, ..) => gen_substs.as_generator().sig(),
|
||||
ty::Generator(_, gen_args, ..) => gen_args.as_generator().sig(),
|
||||
_ => {
|
||||
span_bug!(span, "generator w/o generator type: {:?}", gen_ty)
|
||||
}
|
||||
|
@ -627,11 +627,9 @@ fn construct_error(tcx: TyCtxt<'_>, def: LocalDefId, err: ErrorGuaranteed) -> Bo
|
|||
let num_params = match body_owner_kind {
|
||||
hir::BodyOwnerKind::Fn => tcx.fn_sig(def).skip_binder().inputs().skip_binder().len(),
|
||||
hir::BodyOwnerKind::Closure => {
|
||||
let ty = tcx.type_of(def).subst_identity();
|
||||
let ty = tcx.type_of(def).instantiate_identity();
|
||||
match ty.kind() {
|
||||
ty::Closure(_, substs) => {
|
||||
1 + substs.as_closure().sig().inputs().skip_binder().len()
|
||||
}
|
||||
ty::Closure(_, args) => 1 + args.as_closure().sig().inputs().skip_binder().len(),
|
||||
ty::Generator(..) => 2,
|
||||
_ => bug!("expected closure or generator, found {ty:?}"),
|
||||
}
|
||||
|
@ -778,9 +776,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
closure_ty = *ty;
|
||||
}
|
||||
|
||||
let upvar_substs = match closure_ty.kind() {
|
||||
ty::Closure(_, substs) => ty::UpvarSubsts::Closure(substs),
|
||||
ty::Generator(_, substs, _) => ty::UpvarSubsts::Generator(substs),
|
||||
let upvar_args = match closure_ty.kind() {
|
||||
ty::Closure(_, args) => ty::UpvarArgs::Closure(args),
|
||||
ty::Generator(_, args, _) => ty::UpvarArgs::Generator(args),
|
||||
_ => return,
|
||||
};
|
||||
|
||||
|
@ -789,7 +787,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
// with the closure's DefId. Here, we run through that vec of UpvarIds for
|
||||
// the given closure and use the necessary information to create upvar
|
||||
// debuginfo and to fill `self.upvars`.
|
||||
let capture_tys = upvar_substs.upvar_tys();
|
||||
let capture_tys = upvar_args.upvar_tys();
|
||||
|
||||
let tcx = self.tcx;
|
||||
self.upvars = tcx
|
||||
|
|
|
@ -383,7 +383,7 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||
ExprKind::Adt(box AdtExpr {
|
||||
adt_def,
|
||||
variant_index: _,
|
||||
substs: _,
|
||||
args: _,
|
||||
user_ty: _,
|
||||
fields: _,
|
||||
base: _,
|
||||
|
@ -393,14 +393,14 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> {
|
|||
},
|
||||
ExprKind::Closure(box ClosureExpr {
|
||||
closure_id,
|
||||
substs: _,
|
||||
args: _,
|
||||
upvars: _,
|
||||
movability: _,
|
||||
fake_reads: _,
|
||||
}) => {
|
||||
self.visit_inner_body(closure_id);
|
||||
}
|
||||
ExprKind::ConstBlock { did, substs: _ } => {
|
||||
ExprKind::ConstBlock { did, args: _ } => {
|
||||
let def_id = did.expect_local();
|
||||
self.visit_inner_body(def_id);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use rustc_data_structures::graph::iterate::{
|
|||
};
|
||||
use rustc_hir::def::DefKind;
|
||||
use rustc_middle::mir::{self, BasicBlock, BasicBlocks, Body, Operand, TerminatorKind};
|
||||
use rustc_middle::ty::subst::{GenericArg, InternalSubsts};
|
||||
use rustc_middle::ty::{self, Instance, TyCtxt};
|
||||
use rustc_middle::ty::{GenericArg, GenericArgs};
|
||||
use rustc_session::lint::builtin::UNCONDITIONAL_RECURSION;
|
||||
use rustc_span::Span;
|
||||
use std::ops::ControlFlow;
|
||||
|
@ -14,16 +14,16 @@ pub(crate) fn check<'tcx>(tcx: TyCtxt<'tcx>, body: &Body<'tcx>) {
|
|||
let def_id = body.source.def_id().expect_local();
|
||||
|
||||
if let DefKind::Fn | DefKind::AssocFn = tcx.def_kind(def_id) {
|
||||
// If this is trait/impl method, extract the trait's substs.
|
||||
let trait_substs = match tcx.trait_of_item(def_id.to_def_id()) {
|
||||
// If this is trait/impl method, extract the trait's args.
|
||||
let trait_args = match tcx.trait_of_item(def_id.to_def_id()) {
|
||||
Some(trait_def_id) => {
|
||||
let trait_substs_count = tcx.generics_of(trait_def_id).count();
|
||||
&InternalSubsts::identity_for_item(tcx, def_id)[..trait_substs_count]
|
||||
let trait_args_count = tcx.generics_of(trait_def_id).count();
|
||||
&GenericArgs::identity_for_item(tcx, def_id)[..trait_args_count]
|
||||
}
|
||||
_ => &[],
|
||||
};
|
||||
|
||||
let mut vis = Search { tcx, body, reachable_recursive_calls: vec![], trait_substs };
|
||||
let mut vis = Search { tcx, body, reachable_recursive_calls: vec![], trait_args };
|
||||
if let Some(NonRecursive) =
|
||||
TriColorDepthFirstSearch::new(&body.basic_blocks).run_from_start(&mut vis)
|
||||
{
|
||||
|
@ -51,7 +51,7 @@ struct NonRecursive;
|
|||
struct Search<'mir, 'tcx> {
|
||||
tcx: TyCtxt<'tcx>,
|
||||
body: &'mir Body<'tcx>,
|
||||
trait_substs: &'tcx [GenericArg<'tcx>],
|
||||
trait_args: &'tcx [GenericArg<'tcx>],
|
||||
|
||||
reachable_recursive_calls: Vec<Span>,
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ struct Search<'mir, 'tcx> {
|
|||
impl<'mir, 'tcx> Search<'mir, 'tcx> {
|
||||
/// Returns `true` if `func` refers to the function we are searching in.
|
||||
fn is_recursive_call(&self, func: &Operand<'tcx>, args: &[Operand<'tcx>]) -> bool {
|
||||
let Search { tcx, body, trait_substs, .. } = *self;
|
||||
let Search { tcx, body, trait_args, .. } = *self;
|
||||
// Resolving function type to a specific instance that is being called is expensive. To
|
||||
// avoid the cost we check the number of arguments first, which is sufficient to reject
|
||||
// most of calls as non-recursive.
|
||||
|
@ -70,23 +70,23 @@ impl<'mir, 'tcx> Search<'mir, 'tcx> {
|
|||
let param_env = tcx.param_env(caller);
|
||||
|
||||
let func_ty = func.ty(body, tcx);
|
||||
if let ty::FnDef(callee, substs) = *func_ty.kind() {
|
||||
let normalized_substs = tcx.normalize_erasing_regions(param_env, substs);
|
||||
let (callee, call_substs) = if let Ok(Some(instance)) =
|
||||
Instance::resolve(tcx, param_env, callee, normalized_substs)
|
||||
if let ty::FnDef(callee, args) = *func_ty.kind() {
|
||||
let normalized_args = tcx.normalize_erasing_regions(param_env, args);
|
||||
let (callee, call_args) = if let Ok(Some(instance)) =
|
||||
Instance::resolve(tcx, param_env, callee, normalized_args)
|
||||
{
|
||||
(instance.def_id(), instance.substs)
|
||||
(instance.def_id(), instance.args)
|
||||
} else {
|
||||
(callee, normalized_substs)
|
||||
(callee, normalized_args)
|
||||
};
|
||||
|
||||
// FIXME(#57965): Make this work across function boundaries
|
||||
|
||||
// If this is a trait fn, the substs on the trait have to match, or we might be
|
||||
// If this is a trait fn, the args on the trait have to match, or we might be
|
||||
// calling into an entirely different method (for example, a call from the default
|
||||
// method in the trait to `<A as Trait<B>>::method`, where `A` and/or `B` are
|
||||
// specific types).
|
||||
return callee == caller && &call_substs[..trait_substs.len()] == trait_substs;
|
||||
return callee == caller && &call_args[..trait_args.len()] == trait_args;
|
||||
}
|
||||
|
||||
false
|
||||
|
|
|
@ -15,9 +15,9 @@ use rustc_middle::thir::*;
|
|||
use rustc_middle::ty::adjustment::{
|
||||
Adjust, Adjustment, AutoBorrow, AutoBorrowMutability, PointerCoercion,
|
||||
};
|
||||
use rustc_middle::ty::subst::InternalSubsts;
|
||||
use rustc_middle::ty::GenericArgs;
|
||||
use rustc_middle::ty::{
|
||||
self, AdtKind, InlineConstSubsts, InlineConstSubstsParts, ScalarInt, Ty, UpvarSubsts, UserType,
|
||||
self, AdtKind, InlineConstArgs, InlineConstArgsParts, ScalarInt, Ty, UpvarArgs, UserType,
|
||||
};
|
||||
use rustc_span::{sym, Span};
|
||||
use rustc_target::abi::{FieldIdx, FIRST_VARIANT};
|
||||
|
@ -210,7 +210,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
let res = self.typeck_results().qpath_res(qpath, source.hir_id);
|
||||
let ty = self.typeck_results().node_type(source.hir_id);
|
||||
let ty::Adt(adt_def, substs) = ty.kind() else {
|
||||
let ty::Adt(adt_def, args) = ty.kind() else {
|
||||
return ExprKind::Cast { source: self.mirror_expr(source) };
|
||||
};
|
||||
|
||||
|
@ -242,7 +242,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
// in case we are offsetting from a computed discriminant
|
||||
// and not the beginning of discriminants (which is always `0`)
|
||||
Some(did) => {
|
||||
let kind = ExprKind::NamedConst { def_id: did, substs, user_ty: None };
|
||||
let kind = ExprKind::NamedConst { def_id: did, args, user_ty: None };
|
||||
let lhs =
|
||||
self.thir.exprs.push(Expr { temp_lifetime, ty: discr_ty, span, kind });
|
||||
let bin = ExprKind::Binary { op: BinOp::Add, lhs, rhs: offset };
|
||||
|
@ -372,7 +372,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
None
|
||||
};
|
||||
if let Some((adt_def, index)) = adt_data {
|
||||
let substs = self.typeck_results().node_substs(fun.hir_id);
|
||||
let node_args = self.typeck_results().node_args(fun.hir_id);
|
||||
let user_provided_types = self.typeck_results().user_provided_types();
|
||||
let user_ty =
|
||||
user_provided_types.get(fun.hir_id).copied().map(|mut u_ty| {
|
||||
|
@ -393,7 +393,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
.collect();
|
||||
ExprKind::Adt(Box::new(AdtExpr {
|
||||
adt_def,
|
||||
substs,
|
||||
args: node_args,
|
||||
variant_index: index,
|
||||
fields: field_refs,
|
||||
user_ty,
|
||||
|
@ -511,7 +511,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
}
|
||||
|
||||
hir::ExprKind::Struct(ref qpath, ref fields, ref base) => match expr_ty.kind() {
|
||||
ty::Adt(adt, substs) => match adt.adt_kind() {
|
||||
ty::Adt(adt, args) => match adt.adt_kind() {
|
||||
AdtKind::Struct | AdtKind::Union => {
|
||||
let user_provided_types = self.typeck_results().user_provided_types();
|
||||
let user_ty = user_provided_types.get(expr.hir_id).copied().map(Box::new);
|
||||
|
@ -519,7 +519,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
ExprKind::Adt(Box::new(AdtExpr {
|
||||
adt_def: *adt,
|
||||
variant_index: FIRST_VARIANT,
|
||||
substs,
|
||||
args,
|
||||
user_ty,
|
||||
fields: self.field_refs(fields),
|
||||
base: base.map(|base| FruInfo {
|
||||
|
@ -546,7 +546,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
ExprKind::Adt(Box::new(AdtExpr {
|
||||
adt_def: *adt,
|
||||
variant_index: index,
|
||||
substs,
|
||||
args,
|
||||
user_ty,
|
||||
fields: self.field_refs(fields),
|
||||
base: None,
|
||||
|
@ -565,10 +565,10 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
hir::ExprKind::Closure { .. } => {
|
||||
let closure_ty = self.typeck_results().expr_ty(expr);
|
||||
let (def_id, substs, movability) = match *closure_ty.kind() {
|
||||
ty::Closure(def_id, substs) => (def_id, UpvarSubsts::Closure(substs), None),
|
||||
ty::Generator(def_id, substs, movability) => {
|
||||
(def_id, UpvarSubsts::Generator(substs), Some(movability))
|
||||
let (def_id, args, movability) = match *closure_ty.kind() {
|
||||
ty::Closure(def_id, args) => (def_id, UpvarArgs::Closure(args), None),
|
||||
ty::Generator(def_id, args, movability) => {
|
||||
(def_id, UpvarArgs::Generator(args), Some(movability))
|
||||
}
|
||||
_ => {
|
||||
span_bug!(expr.span, "closure expr w/o closure type: {:?}", closure_ty);
|
||||
|
@ -580,7 +580,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
.tcx
|
||||
.closure_captures(def_id)
|
||||
.iter()
|
||||
.zip(substs.upvar_tys())
|
||||
.zip(args.upvar_tys())
|
||||
.map(|(captured_place, ty)| {
|
||||
let upvars = self.capture_upvar(expr, captured_place, ty);
|
||||
self.thir.exprs.push(upvars)
|
||||
|
@ -601,7 +601,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
ExprKind::Closure(Box::new(ClosureExpr {
|
||||
closure_id: def_id,
|
||||
substs,
|
||||
args,
|
||||
upvars,
|
||||
movability,
|
||||
fake_reads,
|
||||
|
@ -684,13 +684,11 @@ impl<'tcx> Cx<'tcx> {
|
|||
let ty = self.typeck_results().node_type(anon_const.hir_id);
|
||||
let did = anon_const.def_id.to_def_id();
|
||||
let typeck_root_def_id = tcx.typeck_root_def_id(did);
|
||||
let parent_substs =
|
||||
tcx.erase_regions(InternalSubsts::identity_for_item(tcx, typeck_root_def_id));
|
||||
let substs =
|
||||
InlineConstSubsts::new(tcx, InlineConstSubstsParts { parent_substs, ty })
|
||||
.substs;
|
||||
let parent_args =
|
||||
tcx.erase_regions(GenericArgs::identity_for_item(tcx, typeck_root_def_id));
|
||||
let args = InlineConstArgs::new(tcx, InlineConstArgsParts { parent_args, ty }).args;
|
||||
|
||||
ExprKind::ConstBlock { did, substs }
|
||||
ExprKind::ConstBlock { did, args }
|
||||
}
|
||||
// Now comes the rote stuff:
|
||||
hir::ExprKind::Repeat(ref v, _) => {
|
||||
|
@ -809,12 +807,12 @@ impl<'tcx> Cx<'tcx> {
|
|||
Expr { temp_lifetime, ty: expr_ty, span: expr.span, kind }
|
||||
}
|
||||
|
||||
fn user_substs_applied_to_res(
|
||||
fn user_args_applied_to_res(
|
||||
&mut self,
|
||||
hir_id: hir::HirId,
|
||||
res: Res,
|
||||
) -> Option<Box<ty::CanonicalUserType<'tcx>>> {
|
||||
debug!("user_substs_applied_to_res: res={:?}", res);
|
||||
debug!("user_args_applied_to_res: res={:?}", res);
|
||||
let user_provided_type = match res {
|
||||
// A reference to something callable -- e.g., a fn, method, or
|
||||
// a tuple-struct or tuple-variant. This has the type of a
|
||||
|
@ -832,15 +830,15 @@ impl<'tcx> Cx<'tcx> {
|
|||
// this variant -- but with the substitutions given by the
|
||||
// user.
|
||||
Res::Def(DefKind::Ctor(_, CtorKind::Const), _) => {
|
||||
self.user_substs_applied_to_ty_of_hir_id(hir_id).map(Box::new)
|
||||
self.user_args_applied_to_ty_of_hir_id(hir_id).map(Box::new)
|
||||
}
|
||||
|
||||
// `Self` is used in expression as a tuple struct constructor or a unit struct constructor
|
||||
Res::SelfCtor(_) => self.user_substs_applied_to_ty_of_hir_id(hir_id).map(Box::new),
|
||||
Res::SelfCtor(_) => self.user_args_applied_to_ty_of_hir_id(hir_id).map(Box::new),
|
||||
|
||||
_ => bug!("user_substs_applied_to_res: unexpected res {:?} at {:?}", res, hir_id),
|
||||
_ => bug!("user_args_applied_to_res: unexpected res {:?} at {:?}", res, hir_id),
|
||||
};
|
||||
debug!("user_substs_applied_to_res: user_provided_type={:?}", user_provided_type);
|
||||
debug!("user_args_applied_to_res: user_provided_type={:?}", user_provided_type);
|
||||
user_provided_type
|
||||
}
|
||||
|
||||
|
@ -859,13 +857,13 @@ impl<'tcx> Cx<'tcx> {
|
|||
self.typeck_results().type_dependent_def(expr.hir_id).unwrap_or_else(|| {
|
||||
span_bug!(expr.span, "no type-dependent def for method callee")
|
||||
});
|
||||
let user_ty = self.user_substs_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
|
||||
let user_ty = self.user_args_applied_to_res(expr.hir_id, Res::Def(kind, def_id));
|
||||
debug!("method_callee: user_ty={:?}", user_ty);
|
||||
(
|
||||
Ty::new_fn_def(
|
||||
self.tcx(),
|
||||
def_id,
|
||||
self.typeck_results().node_substs(expr.hir_id),
|
||||
self.typeck_results().node_args(expr.hir_id),
|
||||
),
|
||||
user_ty,
|
||||
)
|
||||
|
@ -892,14 +890,14 @@ impl<'tcx> Cx<'tcx> {
|
|||
}
|
||||
|
||||
fn convert_path_expr(&mut self, expr: &'tcx hir::Expr<'tcx>, res: Res) -> ExprKind<'tcx> {
|
||||
let substs = self.typeck_results().node_substs(expr.hir_id);
|
||||
let args = self.typeck_results().node_args(expr.hir_id);
|
||||
match res {
|
||||
// A regular function, constructor function or a constant.
|
||||
Res::Def(DefKind::Fn, _)
|
||||
| Res::Def(DefKind::AssocFn, _)
|
||||
| Res::Def(DefKind::Ctor(_, CtorKind::Fn), _)
|
||||
| Res::SelfCtor(_) => {
|
||||
let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
|
||||
let user_ty = self.user_args_applied_to_res(expr.hir_id, res);
|
||||
ExprKind::ZstLiteral { user_ty }
|
||||
}
|
||||
|
||||
|
@ -914,8 +912,8 @@ impl<'tcx> Cx<'tcx> {
|
|||
}
|
||||
|
||||
Res::Def(DefKind::Const, def_id) | Res::Def(DefKind::AssocConst, def_id) => {
|
||||
let user_ty = self.user_substs_applied_to_res(expr.hir_id, res);
|
||||
ExprKind::NamedConst { def_id, substs, user_ty }
|
||||
let user_ty = self.user_args_applied_to_res(expr.hir_id, res);
|
||||
ExprKind::NamedConst { def_id, args, user_ty }
|
||||
}
|
||||
|
||||
Res::Def(DefKind::Ctor(_, CtorKind::Const), def_id) => {
|
||||
|
@ -926,10 +924,10 @@ impl<'tcx> Cx<'tcx> {
|
|||
match ty.kind() {
|
||||
// A unit struct/variant which is used as a value.
|
||||
// We return a completely different ExprKind here to account for this special case.
|
||||
ty::Adt(adt_def, substs) => ExprKind::Adt(Box::new(AdtExpr {
|
||||
ty::Adt(adt_def, args) => ExprKind::Adt(Box::new(AdtExpr {
|
||||
adt_def: *adt_def,
|
||||
variant_index: adt_def.variant_index_with_ctor_id(def_id),
|
||||
substs,
|
||||
args,
|
||||
user_ty,
|
||||
fields: Box::new([]),
|
||||
base: None,
|
||||
|
|
|
@ -122,7 +122,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
DefKind::Closure => {
|
||||
let closure_ty = self.typeck_results.node_type(owner_id);
|
||||
|
||||
let ty::Closure(closure_def_id, closure_substs) = *closure_ty.kind() else {
|
||||
let ty::Closure(closure_def_id, closure_args) = *closure_ty.kind() else {
|
||||
bug!("closure expr does not have closure type: {:?}", closure_ty);
|
||||
};
|
||||
|
||||
|
@ -134,7 +134,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
};
|
||||
let env_region = ty::Region::new_late_bound(self.tcx, ty::INNERMOST, br);
|
||||
let closure_env_ty =
|
||||
self.tcx.closure_env_ty(closure_def_id, closure_substs, env_region).unwrap();
|
||||
self.tcx.closure_env_ty(closure_def_id, closure_args, env_region).unwrap();
|
||||
let liberated_closure_env_ty = self.tcx.erase_late_bound_regions(
|
||||
ty::Binder::bind_with_vars(closure_env_ty, bound_vars),
|
||||
);
|
||||
|
@ -186,7 +186,7 @@ impl<'tcx> Cx<'tcx> {
|
|||
|
||||
self.tcx
|
||||
.type_of(va_list_did)
|
||||
.subst(self.tcx, &[self.tcx.lifetimes.re_erased.into()])
|
||||
.instantiate(self.tcx, &[self.tcx.lifetimes.re_erased.into()])
|
||||
} else {
|
||||
fn_sig.inputs()[index]
|
||||
};
|
||||
|
|
|
@ -501,12 +501,12 @@ impl<'p, 'tcx> MatchVisitor<'_, 'p, 'tcx> {
|
|||
let witness_1_is_privately_uninhabited =
|
||||
if cx.tcx.features().exhaustive_patterns
|
||||
&& let Some(witness_1) = witnesses.get(0)
|
||||
&& let ty::Adt(adt, substs) = witness_1.ty().kind()
|
||||
&& let ty::Adt(adt, args) = witness_1.ty().kind()
|
||||
&& adt.is_enum()
|
||||
&& let Constructor::Variant(variant_index) = witness_1.ctor()
|
||||
{
|
||||
let variant = adt.variant(*variant_index);
|
||||
let inhabited = variant.inhabited_predicate(cx.tcx, *adt).subst(cx.tcx, substs);
|
||||
let inhabited = variant.inhabited_predicate(cx.tcx, *adt).instantiate(cx.tcx, args);
|
||||
assert!(inhabited.apply(cx.tcx, cx.param_env, cx.module));
|
||||
!inhabited.apply_ignore_module(cx.tcx, cx.param_env)
|
||||
} else {
|
||||
|
|
|
@ -332,20 +332,20 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
tcx.sess.emit_err(err);
|
||||
PatKind::Wild
|
||||
}
|
||||
ty::Adt(adt_def, substs) if adt_def.is_enum() => {
|
||||
ty::Adt(adt_def, args) if adt_def.is_enum() => {
|
||||
let (&variant_index, fields) = cv.unwrap_branch().split_first().unwrap();
|
||||
let variant_index =
|
||||
VariantIdx::from_u32(variant_index.unwrap_leaf().try_to_u32().ok().unwrap());
|
||||
PatKind::Variant {
|
||||
adt_def: *adt_def,
|
||||
substs,
|
||||
args,
|
||||
variant_index,
|
||||
subpatterns: self.field_pats(
|
||||
fields.iter().copied().zip(
|
||||
adt_def.variants()[variant_index]
|
||||
.fields
|
||||
.iter()
|
||||
.map(|field| field.ty(self.tcx(), substs)),
|
||||
.map(|field| field.ty(self.tcx(), args)),
|
||||
),
|
||||
)?,
|
||||
}
|
||||
|
@ -354,9 +354,9 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
subpatterns: self
|
||||
.field_pats(cv.unwrap_branch().iter().copied().zip(fields.iter()))?,
|
||||
},
|
||||
ty::Adt(def, substs) => PatKind::Leaf {
|
||||
ty::Adt(def, args) => PatKind::Leaf {
|
||||
subpatterns: self.field_pats(cv.unwrap_branch().iter().copied().zip(
|
||||
def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx(), substs)),
|
||||
def.non_enum_variant().fields.iter().map(|field| field.ty(self.tcx(), args)),
|
||||
))?,
|
||||
},
|
||||
ty::Slice(elem_ty) => PatKind::Slice {
|
||||
|
|
|
@ -922,7 +922,7 @@ impl<'tcx> SplitWildcard<'tcx> {
|
|||
let kind = if cx.is_uninhabited(*sub_ty) { FixedLen(0) } else { VarLen(0, 0) };
|
||||
smallvec![Slice(Slice::new(None, kind))]
|
||||
}
|
||||
ty::Adt(def, substs) if def.is_enum() => {
|
||||
ty::Adt(def, args) if def.is_enum() => {
|
||||
// If the enum is declared as `#[non_exhaustive]`, we treat it as if it had an
|
||||
// additional "unknown" constructor.
|
||||
// There is no point in enumerating all possible variants, because the user can't
|
||||
|
@ -950,21 +950,19 @@ impl<'tcx> SplitWildcard<'tcx> {
|
|||
let is_secretly_empty =
|
||||
def.variants().is_empty() && !is_exhaustive_pat_feature && !pcx.is_top_level;
|
||||
|
||||
let mut ctors: SmallVec<[_; 1]> = def
|
||||
.variants()
|
||||
.iter_enumerated()
|
||||
.filter(|(_, v)| {
|
||||
// If `exhaustive_patterns` is enabled, we exclude variants known to be
|
||||
// uninhabited.
|
||||
!is_exhaustive_pat_feature
|
||||
|| v.inhabited_predicate(cx.tcx, *def).subst(cx.tcx, substs).apply(
|
||||
cx.tcx,
|
||||
cx.param_env,
|
||||
cx.module,
|
||||
)
|
||||
})
|
||||
.map(|(idx, _)| Variant(idx))
|
||||
.collect();
|
||||
let mut ctors: SmallVec<[_; 1]> =
|
||||
def.variants()
|
||||
.iter_enumerated()
|
||||
.filter(|(_, v)| {
|
||||
// If `exhaustive_patterns` is enabled, we exclude variants known to be
|
||||
// uninhabited.
|
||||
!is_exhaustive_pat_feature
|
||||
|| v.inhabited_predicate(cx.tcx, *def)
|
||||
.instantiate(cx.tcx, args)
|
||||
.apply(cx.tcx, cx.param_env, cx.module)
|
||||
})
|
||||
.map(|(idx, _)| Variant(idx))
|
||||
.collect();
|
||||
|
||||
if is_secretly_empty || is_declared_nonexhaustive {
|
||||
ctors.push(NonExhaustive);
|
||||
|
@ -1156,12 +1154,12 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
|
|||
ty: Ty<'tcx>,
|
||||
variant: &'a VariantDef,
|
||||
) -> impl Iterator<Item = (FieldIdx, Ty<'tcx>)> + Captures<'a> + Captures<'p> {
|
||||
let ty::Adt(adt, substs) = ty.kind() else { bug!() };
|
||||
let ty::Adt(adt, args) = ty.kind() else { bug!() };
|
||||
// Whether we must not match the fields of this variant exhaustively.
|
||||
let is_non_exhaustive = variant.is_field_list_non_exhaustive() && !adt.did().is_local();
|
||||
|
||||
variant.fields.iter().enumerate().filter_map(move |(i, field)| {
|
||||
let ty = field.ty(cx.tcx, substs);
|
||||
let ty = field.ty(cx.tcx, args);
|
||||
// `field.ty()` doesn't normalize after substituting.
|
||||
let ty = cx.tcx.normalize_erasing_regions(cx.param_env, ty);
|
||||
let is_visible = adt.is_enum() || field.vis.is_accessible_from(cx.module, cx.tcx);
|
||||
|
@ -1183,11 +1181,11 @@ impl<'p, 'tcx> Fields<'p, 'tcx> {
|
|||
Single | Variant(_) => match pcx.ty.kind() {
|
||||
ty::Tuple(fs) => Fields::wildcards_from_tys(pcx.cx, fs.iter(), pcx.span),
|
||||
ty::Ref(_, rty, _) => Fields::wildcards_from_tys(pcx.cx, once(*rty), pcx.span),
|
||||
ty::Adt(adt, substs) => {
|
||||
ty::Adt(adt, args) => {
|
||||
if adt.is_box() {
|
||||
// The only legal patterns of type `Box` (outside `std`) are `_` and box
|
||||
// patterns. If we're here we can assume this is a box pattern.
|
||||
Fields::wildcards_from_tys(pcx.cx, once(substs.type_at(0)), pcx.span)
|
||||
Fields::wildcards_from_tys(pcx.cx, once(args.type_at(0)), pcx.span)
|
||||
} else {
|
||||
let variant = &adt.variant(constructor.variant_index_for_adt(*adt));
|
||||
let tys = Fields::list_variant_nonhidden_fields(pcx.cx, pcx.ty, variant)
|
||||
|
@ -1294,7 +1292,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
}
|
||||
fields = Fields::from_iter(cx, wilds);
|
||||
}
|
||||
ty::Adt(adt, substs) if adt.is_box() => {
|
||||
ty::Adt(adt, args) if adt.is_box() => {
|
||||
// The only legal patterns of type `Box` (outside `std`) are `_` and box
|
||||
// patterns. If we're here we can assume this is a box pattern.
|
||||
// FIXME(Nadrieril): A `Box` can in theory be matched either with `Box(_,
|
||||
|
@ -1311,7 +1309,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
let pat = if let Some(pat) = pattern {
|
||||
mkpat(&pat.pattern)
|
||||
} else {
|
||||
DeconstructedPat::wildcard(substs.type_at(0), pat.span)
|
||||
DeconstructedPat::wildcard(args.type_at(0), pat.span)
|
||||
};
|
||||
ctor = Single;
|
||||
fields = Fields::singleton(cx, pat);
|
||||
|
@ -1437,7 +1435,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
// the pattern is a box pattern.
|
||||
PatKind::Deref { subpattern: subpatterns.next().unwrap() }
|
||||
}
|
||||
ty::Adt(adt_def, substs) => {
|
||||
ty::Adt(adt_def, args) => {
|
||||
let variant_index = self.ctor.variant_index_for_adt(*adt_def);
|
||||
let variant = &adt_def.variant(variant_index);
|
||||
let subpatterns = Fields::list_variant_nonhidden_fields(cx, self.ty, variant)
|
||||
|
@ -1446,7 +1444,7 @@ impl<'p, 'tcx> DeconstructedPat<'p, 'tcx> {
|
|||
.collect();
|
||||
|
||||
if adt_def.is_enum() {
|
||||
PatKind::Variant { adt_def: *adt_def, substs, variant_index, subpatterns }
|
||||
PatKind::Variant { adt_def: *adt_def, args, variant_index, subpatterns }
|
||||
} else {
|
||||
PatKind::Leaf { subpatterns }
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ use rustc_middle::mir::interpret::{
|
|||
use rustc_middle::mir::{self, ConstantKind, UserTypeProjection};
|
||||
use rustc_middle::mir::{BorrowKind, Mutability};
|
||||
use rustc_middle::thir::{Ascription, BindingMode, FieldPat, LocalVarId, Pat, PatKind, PatRange};
|
||||
use rustc_middle::ty::subst::{GenericArg, SubstsRef};
|
||||
use rustc_middle::ty::CanonicalUserTypeAnnotation;
|
||||
use rustc_middle::ty::TypeVisitableExt;
|
||||
use rustc_middle::ty::{self, AdtDef, Region, Ty, TyCtxt, UserType};
|
||||
use rustc_middle::ty::{GenericArg, GenericArgsRef};
|
||||
use rustc_span::{Span, Symbol};
|
||||
use rustc_target::abi::FieldIdx;
|
||||
|
||||
|
@ -416,8 +416,8 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
let enum_id = self.tcx.parent(variant_id);
|
||||
let adt_def = self.tcx.adt_def(enum_id);
|
||||
if adt_def.is_enum() {
|
||||
let substs = match ty.kind() {
|
||||
ty::Adt(_, substs) | ty::FnDef(_, substs) => substs,
|
||||
let args = match ty.kind() {
|
||||
ty::Adt(_, args) | ty::FnDef(_, args) => args,
|
||||
ty::Error(_) => {
|
||||
// Avoid ICE (#50585)
|
||||
return PatKind::Wild;
|
||||
|
@ -426,7 +426,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
};
|
||||
PatKind::Variant {
|
||||
adt_def,
|
||||
substs,
|
||||
args,
|
||||
variant_index: adt_def.variant_index_with_id(variant_id),
|
||||
subpatterns,
|
||||
}
|
||||
|
@ -460,7 +460,7 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(user_ty) = self.user_substs_applied_to_ty_of_hir_id(hir_id) {
|
||||
if let Some(user_ty) = self.user_args_applied_to_ty_of_hir_id(hir_id) {
|
||||
debug!("lower_variant_or_leaf: kind={:?} user_ty={:?} span={:?}", kind, user_ty, span);
|
||||
let annotation = CanonicalUserTypeAnnotation {
|
||||
user_ty: Box::new(user_ty),
|
||||
|
@ -496,13 +496,13 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
// Use `Reveal::All` here because patterns are always monomorphic even if their function
|
||||
// isn't.
|
||||
let param_env_reveal_all = self.param_env.with_reveal_all_normalized(self.tcx);
|
||||
// N.B. There is no guarantee that substs collected in typeck results are fully normalized,
|
||||
// N.B. There is no guarantee that args collected in typeck results are fully normalized,
|
||||
// so they need to be normalized in order to pass to `Instance::resolve`, which will ICE
|
||||
// if given unnormalized types.
|
||||
let substs = self
|
||||
let args = self
|
||||
.tcx
|
||||
.normalize_erasing_regions(param_env_reveal_all, self.typeck_results.node_substs(id));
|
||||
let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, substs) {
|
||||
.normalize_erasing_regions(param_env_reveal_all, self.typeck_results.node_args(id));
|
||||
let instance = match ty::Instance::resolve(self.tcx, param_env_reveal_all, def_id, args) {
|
||||
Ok(Some(i)) => i,
|
||||
Ok(None) => {
|
||||
// It should be assoc consts if there's no error but we cannot resolve it.
|
||||
|
@ -617,16 +617,14 @@ impl<'a, 'tcx> PatCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let typeck_root_def_id = tcx.typeck_root_def_id(def_id.to_def_id());
|
||||
let parent_substs =
|
||||
tcx.erase_regions(ty::InternalSubsts::identity_for_item(tcx, typeck_root_def_id));
|
||||
let substs =
|
||||
ty::InlineConstSubsts::new(tcx, ty::InlineConstSubstsParts { parent_substs, ty })
|
||||
.substs;
|
||||
let parent_args =
|
||||
tcx.erase_regions(ty::GenericArgs::identity_for_item(tcx, typeck_root_def_id));
|
||||
let args = ty::InlineConstArgs::new(tcx, ty::InlineConstArgsParts { parent_args, ty }).args;
|
||||
|
||||
let uneval = mir::UnevaluatedConst { def: def_id.to_def_id(), substs, promoted: None };
|
||||
debug_assert!(!substs.has_free_regions());
|
||||
let uneval = mir::UnevaluatedConst { def: def_id.to_def_id(), args, promoted: None };
|
||||
debug_assert!(!args.has_free_regions());
|
||||
|
||||
let ct = ty::UnevaluatedConst { def: def_id.to_def_id(), substs: substs };
|
||||
let ct = ty::UnevaluatedConst { def: def_id.to_def_id(), args: args };
|
||||
// First try using a valtree in order to destructure the constant into a pattern.
|
||||
if let Ok(Some(valtree)) =
|
||||
self.tcx.const_eval_resolve_for_typeck(self.param_env, ct, Some(span))
|
||||
|
@ -754,7 +752,7 @@ macro_rules! ClonePatternFoldableImpls {
|
|||
ClonePatternFoldableImpls! { <'tcx>
|
||||
Span, FieldIdx, Mutability, Symbol, LocalVarId, usize,
|
||||
Region<'tcx>, Ty<'tcx>, BindingMode, AdtDef<'tcx>,
|
||||
SubstsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
|
||||
GenericArgsRef<'tcx>, &'tcx GenericArg<'tcx>, UserType<'tcx>,
|
||||
UserTypeProjection, CanonicalUserTypeAnnotation<'tcx>
|
||||
}
|
||||
|
||||
|
@ -804,10 +802,10 @@ impl<'tcx> PatternFoldable<'tcx> for PatKind<'tcx> {
|
|||
is_primary,
|
||||
}
|
||||
}
|
||||
PatKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant { adt_def, args, variant_index, ref subpatterns } => {
|
||||
PatKind::Variant {
|
||||
adt_def: adt_def.fold_with(folder),
|
||||
substs: substs.fold_with(folder),
|
||||
args: args.fold_with(folder),
|
||||
variant_index,
|
||||
subpatterns: subpatterns.fold_with(folder),
|
||||
}
|
||||
|
|
|
@ -427,10 +427,10 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
self.print_expr(*value, depth_lvl + 2);
|
||||
print_indented!(self, "}", depth_lvl);
|
||||
}
|
||||
ConstBlock { did, substs } => {
|
||||
ConstBlock { did, args } => {
|
||||
print_indented!(self, "ConstBlock {", depth_lvl);
|
||||
print_indented!(self, format!("did: {:?}", did), depth_lvl + 1);
|
||||
print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
|
||||
print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
|
||||
print_indented!(self, "}", depth_lvl);
|
||||
}
|
||||
Repeat { value, count } => {
|
||||
|
@ -499,11 +499,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
ZstLiteral { user_ty } => {
|
||||
print_indented!(self, format!("ZstLiteral(user_ty: {:?})", user_ty), depth_lvl);
|
||||
}
|
||||
NamedConst { def_id, substs, user_ty } => {
|
||||
NamedConst { def_id, args, user_ty } => {
|
||||
print_indented!(self, "NamedConst {", depth_lvl);
|
||||
print_indented!(self, format!("def_id: {:?}", def_id), depth_lvl + 1);
|
||||
print_indented!(self, format!("user_ty: {:?}", user_ty), depth_lvl + 1);
|
||||
print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
|
||||
print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
|
||||
print_indented!(self, "}", depth_lvl);
|
||||
}
|
||||
ConstParam { param, def_id } => {
|
||||
|
@ -560,7 +560,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
format!("variant_index: {:?}", adt_expr.variant_index),
|
||||
depth_lvl + 1
|
||||
);
|
||||
print_indented!(self, format!("substs: {:?}", adt_expr.substs), depth_lvl + 1);
|
||||
print_indented!(self, format!("args: {:?}", adt_expr.args), depth_lvl + 1);
|
||||
print_indented!(self, format!("user_ty: {:?}", adt_expr.user_ty), depth_lvl + 1);
|
||||
|
||||
for (i, field_expr) in adt_expr.fields.iter().enumerate() {
|
||||
|
@ -662,11 +662,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
|
||||
print_indented!(self, "}", depth_lvl + 1);
|
||||
}
|
||||
PatKind::Variant { adt_def, substs, variant_index, subpatterns } => {
|
||||
PatKind::Variant { adt_def, args, variant_index, subpatterns } => {
|
||||
print_indented!(self, "Variant {", depth_lvl + 1);
|
||||
print_indented!(self, "adt_def: ", depth_lvl + 2);
|
||||
self.print_adt_def(*adt_def, depth_lvl + 3);
|
||||
print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 2);
|
||||
print_indented!(self, format!("args: {:?}", args), depth_lvl + 2);
|
||||
print_indented!(self, format!("variant_index: {:?}", variant_index), depth_lvl + 2);
|
||||
|
||||
if subpatterns.len() > 0 {
|
||||
|
@ -784,11 +784,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn print_closure_expr(&mut self, expr: &ClosureExpr<'tcx>, depth_lvl: usize) {
|
||||
let ClosureExpr { closure_id, substs, upvars, movability, fake_reads } = expr;
|
||||
let ClosureExpr { closure_id, args, upvars, movability, fake_reads } = expr;
|
||||
|
||||
print_indented!(self, "ClosureExpr {", depth_lvl);
|
||||
print_indented!(self, format!("closure_id: {:?}", closure_id), depth_lvl + 1);
|
||||
print_indented!(self, format!("substs: {:?}", substs), depth_lvl + 1);
|
||||
print_indented!(self, format!("args: {:?}", args), depth_lvl + 1);
|
||||
|
||||
if upvars.len() > 0 {
|
||||
print_indented!(self, "upvars: [", depth_lvl + 1);
|
||||
|
|
|
@ -9,7 +9,7 @@ pub(crate) trait UserAnnotatedTyHelpers<'tcx> {
|
|||
/// Looks up the type associated with this hir-id and applies the
|
||||
/// user-given substitutions; the hir-id must map to a suitable
|
||||
/// type.
|
||||
fn user_substs_applied_to_ty_of_hir_id(
|
||||
fn user_args_applied_to_ty_of_hir_id(
|
||||
&self,
|
||||
hir_id: hir::HirId,
|
||||
) -> Option<CanonicalUserType<'tcx>> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue