Rename unpack to kind
This commit is contained in:
parent
d76fe15402
commit
29c3babd7c
80 changed files with 165 additions and 165 deletions
|
|
@ -607,7 +607,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
|||
search_stack: &mut Vec<(Ty<'tcx>, &'hir hir::Ty<'hir>)>,
|
||||
) -> Option<&'hir hir::Lifetime> {
|
||||
for (kind, hir_arg) in iter::zip(args, hir_args.args) {
|
||||
match (kind.unpack(), hir_arg) {
|
||||
match (kind.kind(), hir_arg) {
|
||||
(GenericArgKind::Lifetime(r), hir::GenericArg::Lifetime(lt)) => {
|
||||
if r.as_var() == needle_fr {
|
||||
return Some(lt);
|
||||
|
|
@ -997,7 +997,7 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, 'tcx> {
|
|||
) -> bool {
|
||||
let tcx = self.infcx.tcx;
|
||||
ty.walk().any(|arg| {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Param(_) = ty.kind()
|
||||
{
|
||||
clauses.iter().any(|pred| {
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ impl<'a, 'tcx> ConstraintConversion<'a, 'tcx> {
|
|||
|
||||
let mut next_outlives_predicates = vec![];
|
||||
for (ty::OutlivesPredicate(k1, r2), constraint_category) in outlives_predicates {
|
||||
match k1.unpack() {
|
||||
match k1.kind() {
|
||||
GenericArgKind::Lifetime(r1) => {
|
||||
let r1_vid = self.to_region_vid(r1);
|
||||
let r2_vid = self.to_region_vid(r2);
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ fn register_member_constraints<'tcx>(
|
|||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(i, _)| variances[*i] == ty::Invariant)
|
||||
.filter_map(|(_, arg)| match arg.unpack() {
|
||||
.filter_map(|(_, arg)| match arg.kind() {
|
||||
GenericArgKind::Lifetime(r) => Some(typeck.to_region_vid(r)),
|
||||
GenericArgKind::Type(_) | GenericArgKind::Const(_) => None,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ fn dyn_trait_in_self<'tcx>(
|
|||
ty: Ty<'tcx>,
|
||||
) -> Option<ty::ExistentialTraitRef<'tcx>> {
|
||||
for arg in ty.peel_refs().walk() {
|
||||
if let GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Dynamic(data, _, _) = ty.kind()
|
||||
{
|
||||
// FIXME(arbitrary_self_types): This is likely broken for receivers which
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ fn build_error_for_const_call<'tcx>(
|
|||
let mut sugg = None;
|
||||
|
||||
if ccx.tcx.is_lang_item(trait_id, LangItem::PartialEq) {
|
||||
match (args[0].unpack(), args[1].unpack()) {
|
||||
match (args[0].kind(), args[1].kind()) {
|
||||
(GenericArgKind::Type(self_ty), GenericArgKind::Type(rhs_ty))
|
||||
if self_ty == rhs_ty
|
||||
&& self_ty.is_ref()
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ impl<'tcx> Printer<'tcx> for AbsolutePathPrinter<'tcx> {
|
|||
) -> Result<(), PrintError> {
|
||||
print_prefix(self)?;
|
||||
let args =
|
||||
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
|
||||
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
|
||||
if args.clone().next().is_some() {
|
||||
self.generic_delimiters(|cx| cx.comma_sep(args))
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1575,7 +1575,7 @@ fn check_type_alias_type_params_are_used<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalD
|
|||
|
||||
let mut params_used = DenseBitSet::new_empty(generics.own_params.len());
|
||||
for leaf in ty.walk() {
|
||||
if let GenericArgKind::Type(leaf_ty) = leaf.unpack()
|
||||
if let GenericArgKind::Type(leaf_ty) = leaf.kind()
|
||||
&& let ty::Param(param) = leaf_ty.kind()
|
||||
{
|
||||
debug!("found use of ty param {:?}", param);
|
||||
|
|
@ -1700,7 +1700,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, opaque_def_id: LocalDefId) -> ErrorG
|
|||
|
||||
let mut label_match = |ty: Ty<'_>, span| {
|
||||
for arg in ty.walk() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Alias(
|
||||
ty::Opaque,
|
||||
ty::AliasTy { def_id: captured_def_id, .. },
|
||||
|
|
|
|||
|
|
@ -1231,7 +1231,7 @@ fn check_region_late_boundedness<'tcx>(
|
|||
for (id_arg, arg) in
|
||||
std::iter::zip(ty::GenericArgs::identity_for_item(tcx, impl_m.def_id), impl_m_args)
|
||||
{
|
||||
if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
|
||||
if let ty::GenericArgKind::Lifetime(r) = arg.kind()
|
||||
&& let ty::ReVar(vid) = r.kind()
|
||||
&& let r = infcx
|
||||
.inner
|
||||
|
|
@ -1256,7 +1256,7 @@ fn check_region_late_boundedness<'tcx>(
|
|||
for (id_arg, arg) in
|
||||
std::iter::zip(ty::GenericArgs::identity_for_item(tcx, trait_m.def_id), trait_m_args)
|
||||
{
|
||||
if let ty::GenericArgKind::Lifetime(r) = arg.unpack()
|
||||
if let ty::GenericArgKind::Lifetime(r) = arg.kind()
|
||||
&& let ty::ReVar(vid) = r.kind()
|
||||
&& let r = infcx
|
||||
.inner
|
||||
|
|
|
|||
|
|
@ -427,7 +427,7 @@ fn report_mismatched_rpitit_captures<'tcx>(
|
|||
};
|
||||
|
||||
trait_captured_args
|
||||
.sort_by_cached_key(|arg| !matches!(arg.unpack(), ty::GenericArgKind::Lifetime(_)));
|
||||
.sort_by_cached_key(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
|
||||
let suggestion = format!("use<{}>", trait_captured_args.iter().join(", "));
|
||||
|
||||
tcx.emit_node_span_lint(
|
||||
|
|
|
|||
|
|
@ -819,7 +819,7 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for GATArgsCollector<'tcx> {
|
|||
match t.kind() {
|
||||
ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
|
||||
for (idx, arg) in p.args.iter().enumerate() {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(lt) if !lt.is_bound() => {
|
||||
self.regions.insert((lt, idx));
|
||||
}
|
||||
|
|
@ -1517,7 +1517,7 @@ fn check_where_clauses<'tcx>(wfcx: &WfCheckingCtxt<'_, 'tcx>, span: Span, def_id
|
|||
} else {
|
||||
// If we've got a generic const parameter we still want to check its
|
||||
// type is correct in case both it and the param type are fully concrete.
|
||||
let GenericArgKind::Const(ct) = default.unpack() else {
|
||||
let GenericArgKind::Const(ct) = default.kind() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ fn remap_gat_vars_and_recurse_into_nested_projections<'tcx>(
|
|||
let mut mapping = FxIndexMap::default();
|
||||
let generics = tcx.generics_of(assoc_item_def_id);
|
||||
for (param, var) in std::iter::zip(&generics.own_params, gat_vars) {
|
||||
let existing = match var.unpack() {
|
||||
let existing = match var.kind() {
|
||||
ty::GenericArgKind::Lifetime(re) => {
|
||||
if let ty::RegionKind::ReBound(ty::INNERMOST, bv) = re.kind() {
|
||||
mapping.insert(bv.var, tcx.mk_param_from_def(param))
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
let pred = bound_predicate.rebind(pred);
|
||||
// A `Self` within the original bound will be instantiated with a
|
||||
// `trait_object_dummy_self`, so check for that.
|
||||
let references_self = match pred.skip_binder().term.unpack() {
|
||||
let references_self = match pred.skip_binder().term.kind() {
|
||||
ty::TermKind::Ty(ty) => ty.walk().any(|arg| arg == dummy_self.into()),
|
||||
// FIXME(associated_const_equality): We should walk the const instead of not doing anything
|
||||
ty::TermKind::Const(_) => false,
|
||||
|
|
|
|||
|
|
@ -607,7 +607,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
|
|||
if !infer_args && has_default {
|
||||
// No type parameter provided, but a default exists.
|
||||
if let Some(prev) =
|
||||
preceding_args.iter().find_map(|arg| match arg.unpack() {
|
||||
preceding_args.iter().find_map(|arg| match arg.kind() {
|
||||
GenericArgKind::Type(ty) => ty.error_reported().err(),
|
||||
_ => None,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
|
|||
explicit_map: &mut ExplicitPredicatesMap<'tcx>,
|
||||
) {
|
||||
for arg in ty.walk() {
|
||||
let leaf_ty = match arg.unpack() {
|
||||
let leaf_ty = match arg.kind() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
|
||||
// No predicates from lifetimes or constants, except potentially
|
||||
|
|
@ -299,7 +299,7 @@ fn check_explicit_predicates<'tcx>(
|
|||
// binding) and thus infer an outlives requirement that `X:
|
||||
// 'b`.
|
||||
if let Some(self_ty) = ignored_self_ty
|
||||
&& let GenericArgKind::Type(ty) = outlives_predicate.0.unpack()
|
||||
&& let GenericArgKind::Type(ty) = outlives_predicate.0.kind()
|
||||
&& ty.walk().any(|arg| arg == self_ty.into())
|
||||
{
|
||||
debug!("skipping self ty = {ty:?}");
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ fn inferred_outlives_crate(tcx: TyCtxt<'_>, (): ()) -> CratePredicatesMap<'_> {
|
|||
let predicates =
|
||||
&*tcx.arena.alloc_from_iter(set.as_ref().skip_binder().iter().filter_map(
|
||||
|(ty::OutlivesPredicate(kind1, region2), &span)| {
|
||||
match kind1.unpack() {
|
||||
match kind1.kind() {
|
||||
GenericArgKind::Type(ty1) => Some((
|
||||
ty::ClauseKind::TypeOutlives(ty::OutlivesPredicate(ty1, *region2))
|
||||
.upcast(tcx),
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub(crate) fn insert_outlives_predicate<'tcx>(
|
|||
return;
|
||||
}
|
||||
|
||||
match kind.unpack() {
|
||||
match kind.kind() {
|
||||
GenericArgKind::Type(ty) => {
|
||||
// `T: 'outlived_region` for some type `T`
|
||||
// But T could be a lot of things:
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
let variance_i = self.invariant(variance);
|
||||
|
||||
for k in args {
|
||||
match k.unpack() {
|
||||
match k.kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
self.add_constraints_from_region(current, lt, variance_i)
|
||||
}
|
||||
|
|
@ -294,7 +294,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
}
|
||||
|
||||
for projection in data.projection_bounds() {
|
||||
match projection.skip_binder().term.unpack() {
|
||||
match projection.skip_binder().term.kind() {
|
||||
ty::TermKind::Ty(ty) => {
|
||||
self.add_constraints_from_ty(current, ty, self.invariant);
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
"add_constraints_from_args: variance_decl={:?} variance_i={:?}",
|
||||
variance_decl, variance_i
|
||||
);
|
||||
match k.unpack() {
|
||||
match k.kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
self.add_constraints_from_region(current, lt, variance_i)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,12 +80,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let find_param_matching = |matches: &dyn Fn(ty::ParamTerm) -> bool| {
|
||||
predicate_args.iter().find_map(|arg| {
|
||||
arg.walk().find_map(|arg| {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Param(param_ty) = *ty.kind()
|
||||
&& matches(ty::ParamTerm::Ty(param_ty))
|
||||
{
|
||||
Some(arg)
|
||||
} else if let ty::GenericArgKind::Const(ct) = arg.unpack()
|
||||
} else if let ty::GenericArgKind::Const(ct) = arg.kind()
|
||||
&& let ty::ConstKind::Param(param_ct) = ct.kind()
|
||||
&& matches(ty::ParamTerm::Const(param_ct))
|
||||
{
|
||||
|
|
@ -373,7 +373,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// Handle `Self` param specifically, since it's separated in
|
||||
// the path representation
|
||||
if let Some(self_ty) = self_ty
|
||||
&& let ty::GenericArgKind::Type(ty) = param.unpack()
|
||||
&& let ty::GenericArgKind::Type(ty) = param.kind()
|
||||
&& ty == self.tcx.types.self_param
|
||||
{
|
||||
error.obligation.cause.span = self_ty
|
||||
|
|
@ -389,7 +389,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
}
|
||||
// Handle `Self` param specifically, since it's separated in
|
||||
// the path representation
|
||||
if let ty::GenericArgKind::Type(ty) = param.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = param.kind()
|
||||
&& ty == self.tcx.types.self_param
|
||||
{
|
||||
error.obligation.cause.span = self_ty
|
||||
|
|
@ -424,10 +424,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
// the args list does not, then we should chop off all of the lifetimes,
|
||||
// since they're all elided.
|
||||
let segment_args = segment.args().args;
|
||||
if matches!(own_args[0].unpack(), ty::GenericArgKind::Lifetime(_))
|
||||
if matches!(own_args[0].kind(), ty::GenericArgKind::Lifetime(_))
|
||||
&& segment_args.first().is_some_and(|arg| arg.is_ty_or_const())
|
||||
&& let Some(offset) = own_args.iter().position(|arg| {
|
||||
matches!(arg.unpack(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
|
||||
matches!(arg.kind(), ty::GenericArgKind::Type(_) | ty::GenericArgKind::Const(_))
|
||||
})
|
||||
&& let Some(new_index) = index.checked_sub(offset)
|
||||
{
|
||||
|
|
@ -750,7 +750,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return Ok(expr);
|
||||
}
|
||||
|
||||
let ty::GenericArgKind::Type(in_ty) = in_ty.unpack() else {
|
||||
let ty::GenericArgKind::Type(in_ty) = in_ty.kind() else {
|
||||
return Err(expr);
|
||||
};
|
||||
|
||||
|
|
@ -1045,7 +1045,7 @@ fn find_param_in_ty<'tcx>(
|
|||
if arg == param_to_point_at {
|
||||
return true;
|
||||
}
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Alias(ty::Projection | ty::Inherent, ..) = ty.kind()
|
||||
{
|
||||
// This logic may seem a bit strange, but typically when
|
||||
|
|
|
|||
|
|
@ -2226,7 +2226,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let infer_args = self.tcx.mk_args_from_iter(args.into_iter().map(|arg| {
|
||||
if !arg.is_suggestable(self.tcx, true) {
|
||||
has_unsuggestable_args = true;
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(_) => self
|
||||
.next_region_var(RegionVariableOrigin::MiscVariable(DUMMY_SP))
|
||||
.into(),
|
||||
|
|
@ -2843,7 +2843,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let [first] = ***args else {
|
||||
return;
|
||||
};
|
||||
let ty::GenericArgKind::Type(ty) = first.unpack() else {
|
||||
let ty::GenericArgKind::Type(ty) = first.kind() else {
|
||||
return;
|
||||
};
|
||||
let Ok(pick) = self.lookup_probe_for_diagnostic(
|
||||
|
|
|
|||
|
|
@ -347,7 +347,7 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
|
|||
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
|
||||
TypeTrace {
|
||||
cause: cause.clone(),
|
||||
values: match (a.unpack(), b.unpack()) {
|
||||
values: match (a.kind(), b.kind()) {
|
||||
(GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
|
||||
ValuePairs::Regions(ExpectedFound::new(a, b))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,15 +61,15 @@ where
|
|||
value
|
||||
} else {
|
||||
let delegate = FnMutDelegate {
|
||||
regions: &mut |br: ty::BoundRegion| match var_values[br.var].unpack() {
|
||||
regions: &mut |br: ty::BoundRegion| match var_values[br.var].kind() {
|
||||
GenericArgKind::Lifetime(l) => l,
|
||||
r => bug!("{:?} is a region but value is {:?}", br, r),
|
||||
},
|
||||
types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].unpack() {
|
||||
types: &mut |bound_ty: ty::BoundTy| match var_values[bound_ty.var].kind() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
r => bug!("{:?} is a type but value is {:?}", bound_ty, r),
|
||||
},
|
||||
consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].unpack() {
|
||||
consts: &mut |bound_ct: ty::BoundVar| match var_values[bound_ct].kind() {
|
||||
GenericArgKind::Const(ct) => ct,
|
||||
c => bug!("{:?} is a const but value is {:?}", bound_ct, c),
|
||||
},
|
||||
|
|
|
|||
|
|
@ -245,7 +245,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
let result_value = query_response.instantiate_projected(self.tcx, &result_args, |v| {
|
||||
v.var_values[BoundVar::new(index)]
|
||||
});
|
||||
match (original_value.unpack(), result_value.unpack()) {
|
||||
match (original_value.kind(), result_value.kind()) {
|
||||
(GenericArgKind::Lifetime(re1), GenericArgKind::Lifetime(re2))
|
||||
if re1.is_erased() && re2.is_erased() =>
|
||||
{
|
||||
|
|
@ -402,7 +402,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
// [(?A, Vec<?0>), ('static, '?1), (?B, ?0)]
|
||||
for (original_value, result_value) in iter::zip(&original_values.var_values, result_values)
|
||||
{
|
||||
match result_value.unpack() {
|
||||
match result_value.kind() {
|
||||
GenericArgKind::Type(result_value) => {
|
||||
// e.g., here `result_value` might be `?0` in the example above...
|
||||
if let ty::Bound(debruijn, b) = *result_value.kind() {
|
||||
|
|
@ -533,7 +533,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
for (index, value1) in variables1.var_values.iter().enumerate() {
|
||||
let value2 = variables2(BoundVar::new(index));
|
||||
|
||||
match (value1.unpack(), value2.unpack()) {
|
||||
match (value1.kind(), value2.kind()) {
|
||||
(GenericArgKind::Type(v1), GenericArgKind::Type(v2)) => {
|
||||
obligations.extend(
|
||||
self.at(cause, param_env)
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ impl<'tcx> rustc_type_ir::InferCtxtLike for InferCtxt<'tcx> {
|
|||
}
|
||||
|
||||
fn is_changed_arg(&self, arg: ty::GenericArg<'tcx>) -> bool {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
ty::GenericArgKind::Lifetime(_) => {
|
||||
// Lifetimes should not change affect trait selection.
|
||||
false
|
||||
|
|
|
|||
|
|
@ -1372,7 +1372,7 @@ impl<'tcx> TyOrConstInferVar {
|
|||
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
|
||||
/// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
|
||||
pub fn maybe_from_generic_arg(arg: GenericArg<'tcx>) -> Option<Self> {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Type(ty) => Self::maybe_from_ty(ty),
|
||||
GenericArgKind::Const(ct) => Self::maybe_from_const(ct),
|
||||
GenericArgKind::Lifetime(_) => None,
|
||||
|
|
@ -1383,7 +1383,7 @@ impl<'tcx> TyOrConstInferVar {
|
|||
/// for types other than `ty::Infer(_)` (or `InferTy::Fresh*`) and
|
||||
/// for constants other than `ty::ConstKind::Infer(_)` (or `InferConst::Fresh`).
|
||||
pub fn maybe_from_term(term: Term<'tcx>) -> Option<Self> {
|
||||
match term.unpack() {
|
||||
match term.kind() {
|
||||
TermKind::Ty(ty) => Self::maybe_from_ty(ty),
|
||||
TermKind::Const(ct) => Self::maybe_from_const(ct),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl<'tcx> InferCtxt<'tcx> {
|
|||
ty::OutlivesPredicate(arg, r2): ty::OutlivesPredicate<'tcx, ty::GenericArg<'tcx>>,
|
||||
cause: &ObligationCause<'tcx>,
|
||||
) {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
ty::GenericArgKind::Lifetime(r1) => {
|
||||
self.register_region_outlives_constraint(ty::OutlivesPredicate(r1, r2), cause);
|
||||
}
|
||||
|
|
@ -504,7 +504,7 @@ where
|
|||
) {
|
||||
let constraint = origin.to_constraint_category();
|
||||
for (index, k) in args.iter().enumerate() {
|
||||
match k.unpack() {
|
||||
match k.kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
let variance = if let Some(variances) = opt_variances {
|
||||
variances[index]
|
||||
|
|
|
|||
|
|
@ -329,7 +329,7 @@ struct Generalizer<'me, 'tcx> {
|
|||
impl<'tcx> Generalizer<'_, 'tcx> {
|
||||
/// Create an error that corresponds to the term kind in `root_term`
|
||||
fn cyclic_term_error(&self) -> TypeError<'tcx> {
|
||||
match self.root_term.unpack() {
|
||||
match self.root_term.kind() {
|
||||
ty::TermKind::Ty(ty) => TypeError::CyclicTy(ty),
|
||||
ty::TermKind::Const(ct) => TypeError::CyclicConst(ct),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -461,7 +461,7 @@ fn extract_def_id_from_arg<'tcx>(
|
|||
generics: &'tcx ty::Generics,
|
||||
arg: ty::GenericArg<'tcx>,
|
||||
) -> DefId {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
ty::GenericArgKind::Lifetime(re) => match re.kind() {
|
||||
ty::ReEarlyParam(ebr) => generics.region_param(ebr, tcx).def_id,
|
||||
ty::ReBound(
|
||||
|
|
|
|||
|
|
@ -2781,7 +2781,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
return false;
|
||||
}
|
||||
|
||||
if !matches!(args[0].unpack(), ty::GenericArgKind::Type(_)) {
|
||||
if !matches!(args[0].kind(), ty::GenericArgKind::Type(_)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -2803,7 +2803,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
};
|
||||
|
||||
for (param, arg) in std::iter::zip(&generics.own_params, own_args) {
|
||||
match (¶m.kind, arg.unpack()) {
|
||||
match (¶m.kind, arg.kind()) {
|
||||
(ty::GenericParamDefKind::Type { .. }, ty::GenericArgKind::Type(_))
|
||||
| (ty::GenericParamDefKind::Lifetime, ty::GenericArgKind::Lifetime(_))
|
||||
| (ty::GenericParamDefKind::Const { .. }, ty::GenericArgKind::Const(_)) => {}
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for GenericArg<'tcx> {
|
|||
type Kind = GenericArgKind<'tcx>;
|
||||
|
||||
fn kind(self) -> Self::Kind {
|
||||
self.unpack()
|
||||
self.kind()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -218,7 +218,7 @@ impl<'tcx> From<ty::Const<'tcx>> for GenericArg<'tcx> {
|
|||
|
||||
impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
|
||||
fn from(value: ty::Term<'tcx>) -> Self {
|
||||
match value.unpack() {
|
||||
match value.kind() {
|
||||
ty::TermKind::Ty(t) => t.into(),
|
||||
ty::TermKind::Const(c) => c.into(),
|
||||
}
|
||||
|
|
@ -227,7 +227,7 @@ impl<'tcx> From<ty::Term<'tcx>> for GenericArg<'tcx> {
|
|||
|
||||
impl<'tcx> GenericArg<'tcx> {
|
||||
#[inline]
|
||||
pub fn unpack(self) -> GenericArgKind<'tcx> {
|
||||
pub fn kind(self) -> GenericArgKind<'tcx> {
|
||||
let ptr =
|
||||
unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
|
||||
// SAFETY: use of `Interned::new_unchecked` here is ok because these
|
||||
|
|
@ -251,7 +251,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn as_region(self) -> Option<ty::Region<'tcx>> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(re) => Some(re),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn as_type(self) -> Option<Ty<'tcx>> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Type(ty) => Some(ty),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn as_const(self) -> Option<ty::Const<'tcx>> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Const(ct) => Some(ct),
|
||||
_ => None,
|
||||
}
|
||||
|
|
@ -275,7 +275,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
|
||||
#[inline]
|
||||
pub fn as_term(self) -> Option<ty::Term<'tcx>> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(_) => None,
|
||||
GenericArgKind::Type(ty) => Some(ty.into()),
|
||||
GenericArgKind::Const(ct) => Some(ct.into()),
|
||||
|
|
@ -300,7 +300,7 @@ impl<'tcx> GenericArg<'tcx> {
|
|||
}
|
||||
|
||||
pub fn is_non_region_infer(self) -> bool {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(_) => false,
|
||||
// FIXME: This shouldn't return numerical/float.
|
||||
GenericArgKind::Type(ty) => ty.is_ty_or_numeric_infer(),
|
||||
|
|
@ -327,7 +327,7 @@ impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for GenericArg<'a> {
|
|||
type Lifted = GenericArg<'tcx>;
|
||||
|
||||
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => tcx.lift(lt).map(|lt| lt.into()),
|
||||
GenericArgKind::Type(ty) => tcx.lift(ty).map(|ty| ty.into()),
|
||||
GenericArgKind::Const(ct) => tcx.lift(ct).map(|ct| ct.into()),
|
||||
|
|
@ -340,7 +340,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
|||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self, F::Error> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => lt.try_fold_with(folder).map(Into::into),
|
||||
GenericArgKind::Type(ty) => ty.try_fold_with(folder).map(Into::into),
|
||||
GenericArgKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
|
||||
|
|
@ -348,7 +348,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
|||
}
|
||||
|
||||
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => lt.fold_with(folder).into(),
|
||||
GenericArgKind::Type(ty) => ty.fold_with(folder).into(),
|
||||
GenericArgKind::Const(ct) => ct.fold_with(folder).into(),
|
||||
|
|
@ -358,7 +358,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
|||
|
||||
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => lt.visit_with(visitor),
|
||||
GenericArgKind::Type(ty) => ty.visit_with(visitor),
|
||||
GenericArgKind::Const(ct) => ct.visit_with(visitor),
|
||||
|
|
@ -368,7 +368,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArg<'tcx> {
|
|||
|
||||
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx> {
|
||||
fn encode(&self, e: &mut E) {
|
||||
self.unpack().encode(e)
|
||||
self.kind().encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ impl<'tcx> GenericArgs<'tcx> {
|
|||
///
|
||||
/// If any of the generic arguments are not types.
|
||||
pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>> {
|
||||
tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.unpack() {
|
||||
tcx.mk_type_list_from_iter(self.iter().map(|arg| match arg.kind() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
_ => bug!("`into_type_list` called on generic arg with non-types"),
|
||||
}))
|
||||
|
|
@ -527,7 +527,7 @@ impl<'tcx> GenericArgs<'tcx> {
|
|||
/// Returns generic arguments that are not lifetimes.
|
||||
#[inline]
|
||||
pub fn non_erasable_generics(&self) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> {
|
||||
self.iter().filter_map(|k| match k.unpack() {
|
||||
self.iter().filter_map(|k| match k.kind() {
|
||||
ty::GenericArgKind::Lifetime(_) => None,
|
||||
generic => Some(generic),
|
||||
})
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ where
|
|||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for ty::GenericArg<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
self.unpack().hash_stable(hcx, hasher);
|
||||
self.kind().hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -504,7 +504,7 @@ impl<'tcx> rustc_type_ir::inherent::IntoKind for Term<'tcx> {
|
|||
type Kind = TermKind<'tcx>;
|
||||
|
||||
fn kind(self) -> Self::Kind {
|
||||
self.unpack()
|
||||
self.kind()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -521,7 +521,7 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync
|
|||
|
||||
impl Debug for Term<'_> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"),
|
||||
TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"),
|
||||
}
|
||||
|
|
@ -542,7 +542,7 @@ impl<'tcx> From<Const<'tcx>> for Term<'tcx> {
|
|||
|
||||
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for Term<'tcx> {
|
||||
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
||||
self.unpack().hash_stable(hcx, hasher);
|
||||
self.kind().hash_stable(hcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -551,14 +551,14 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
|
|||
self,
|
||||
folder: &mut F,
|
||||
) -> Result<Self, F::Error> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
ty::TermKind::Ty(ty) => ty.try_fold_with(folder).map(Into::into),
|
||||
ty::TermKind::Const(ct) => ct.try_fold_with(folder).map(Into::into),
|
||||
}
|
||||
}
|
||||
|
||||
fn fold_with<F: TypeFolder<TyCtxt<'tcx>>>(self, folder: &mut F) -> Self {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
ty::TermKind::Ty(ty) => ty.fold_with(folder).into(),
|
||||
ty::TermKind::Const(ct) => ct.fold_with(folder).into(),
|
||||
}
|
||||
|
|
@ -567,7 +567,7 @@ impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for Term<'tcx> {
|
|||
|
||||
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
|
||||
fn visit_with<V: TypeVisitor<TyCtxt<'tcx>>>(&self, visitor: &mut V) -> V::Result {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
ty::TermKind::Ty(ty) => ty.visit_with(visitor),
|
||||
ty::TermKind::Const(ct) => ct.visit_with(visitor),
|
||||
}
|
||||
|
|
@ -576,7 +576,7 @@ impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for Term<'tcx> {
|
|||
|
||||
impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for Term<'tcx> {
|
||||
fn encode(&self, e: &mut E) {
|
||||
self.unpack().encode(e)
|
||||
self.kind().encode(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for Term<'tcx> {
|
|||
|
||||
impl<'tcx> Term<'tcx> {
|
||||
#[inline]
|
||||
pub fn unpack(self) -> TermKind<'tcx> {
|
||||
pub fn kind(self) -> TermKind<'tcx> {
|
||||
let ptr =
|
||||
unsafe { self.ptr.map_addr(|addr| NonZero::new_unchecked(addr.get() & !TAG_MASK)) };
|
||||
// SAFETY: use of `Interned::new_unchecked` here is ok because these
|
||||
|
|
@ -609,7 +609,7 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
|
||||
pub fn as_type(&self) -> Option<Ty<'tcx>> {
|
||||
if let TermKind::Ty(ty) = self.unpack() { Some(ty) } else { None }
|
||||
if let TermKind::Ty(ty) = self.kind() { Some(ty) } else { None }
|
||||
}
|
||||
|
||||
pub fn expect_type(&self) -> Ty<'tcx> {
|
||||
|
|
@ -617,7 +617,7 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
|
||||
pub fn as_const(&self) -> Option<Const<'tcx>> {
|
||||
if let TermKind::Const(c) = self.unpack() { Some(c) } else { None }
|
||||
if let TermKind::Const(c) = self.kind() { Some(c) } else { None }
|
||||
}
|
||||
|
||||
pub fn expect_const(&self) -> Const<'tcx> {
|
||||
|
|
@ -625,14 +625,14 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
|
||||
pub fn into_arg(self) -> GenericArg<'tcx> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
TermKind::Ty(ty) => ty.into(),
|
||||
TermKind::Const(c) => c.into(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_alias_term(self) -> Option<AliasTerm<'tcx>> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
TermKind::Ty(ty) => match *ty.kind() {
|
||||
ty::Alias(_kind, alias_ty) => Some(alias_ty.into()),
|
||||
_ => None,
|
||||
|
|
@ -645,7 +645,7 @@ impl<'tcx> Term<'tcx> {
|
|||
}
|
||||
|
||||
pub fn is_infer(&self) -> bool {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
TermKind::Ty(ty) => ty.is_ty_var(),
|
||||
TermKind::Const(ct) => ct.is_ct_infer(),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
match self.map.get(&r.into()).map(|k| k.unpack()) {
|
||||
match self.map.get(&r.into()).map(|k| k.kind()) {
|
||||
Some(GenericArgKind::Lifetime(r1)) => r1,
|
||||
Some(u) => panic!("region mapped to unexpected kind: {u:?}"),
|
||||
None if self.do_not_error => self.tcx.lifetimes.re_static,
|
||||
|
|
@ -162,7 +162,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
|||
|
||||
ty::Param(param) => {
|
||||
// Look it up in the generic parameters list.
|
||||
match self.map.get(&ty.into()).map(|k| k.unpack()) {
|
||||
match self.map.get(&ty.into()).map(|k| k.kind()) {
|
||||
// Found it in the generic parameters list; replace with the parameter from the
|
||||
// opaque type.
|
||||
Some(GenericArgKind::Type(t1)) => t1,
|
||||
|
|
@ -195,7 +195,7 @@ impl<'tcx> TypeFolder<TyCtxt<'tcx>> for ReverseMapper<'tcx> {
|
|||
match ct.kind() {
|
||||
ty::ConstKind::Param(..) => {
|
||||
// Look it up in the generic parameters list.
|
||||
match self.map.get(&ct.into()).map(|k| k.unpack()) {
|
||||
match self.map.get(&ct.into()).map(|k| k.kind()) {
|
||||
// Found it in the generic parameters list, replace with the parameter from the
|
||||
// opaque type.
|
||||
Some(GenericArgKind::Const(c1)) => c1,
|
||||
|
|
|
|||
|
|
@ -1239,7 +1239,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
|
||||
p!(write("{} = ", tcx.associated_item(assoc_item_def_id).name()));
|
||||
|
||||
match term.unpack() {
|
||||
match term.kind() {
|
||||
TermKind::Ty(ty) => p!(print(ty)),
|
||||
TermKind::Const(c) => p!(print(c)),
|
||||
};
|
||||
|
|
@ -3386,7 +3386,7 @@ define_print_and_forward_display! {
|
|||
}
|
||||
|
||||
ty::Term<'tcx> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
ty::TermKind::Ty(ty) => p!(print(ty)),
|
||||
ty::TermKind::Const(c) => p!(print(c)),
|
||||
}
|
||||
|
|
@ -3401,7 +3401,7 @@ define_print_and_forward_display! {
|
|||
}
|
||||
|
||||
GenericArg<'tcx> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => p!(print(lt)),
|
||||
GenericArgKind::Type(ty) => p!(print(ty)),
|
||||
GenericArgKind::Const(ct) => p!(print(ct)),
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::GenericArg<'tcx> {
|
|||
a: ty::GenericArg<'tcx>,
|
||||
b: ty::GenericArg<'tcx>,
|
||||
) -> RelateResult<'tcx, ty::GenericArg<'tcx>> {
|
||||
match (a.unpack(), b.unpack()) {
|
||||
match (a.kind(), b.kind()) {
|
||||
(ty::GenericArgKind::Lifetime(a_lt), ty::GenericArgKind::Lifetime(b_lt)) => {
|
||||
Ok(relation.relate(a_lt, b_lt)?.into())
|
||||
}
|
||||
|
|
@ -190,7 +190,7 @@ impl<'tcx> Relate<TyCtxt<'tcx>> for ty::Term<'tcx> {
|
|||
a: Self,
|
||||
b: Self,
|
||||
) -> RelateResult<'tcx, Self> {
|
||||
Ok(match (a.unpack(), b.unpack()) {
|
||||
Ok(match (a.kind(), b.kind()) {
|
||||
(ty::TermKind::Ty(a), ty::TermKind::Ty(b)) => relation.relate(a, b)?.into(),
|
||||
(ty::TermKind::Const(a), ty::TermKind::Const(b)) => relation.relate(a, b)?.into(),
|
||||
_ => return Err(TypeError::Mismatch),
|
||||
|
|
|
|||
|
|
@ -202,7 +202,7 @@ impl<T: fmt::Debug> fmt::Debug for ty::Placeholder<T> {
|
|||
|
||||
impl<'tcx> fmt::Debug for GenericArg<'tcx> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
GenericArgKind::Lifetime(lt) => lt.fmt(f),
|
||||
GenericArgKind::Type(ty) => ty.fmt(f),
|
||||
GenericArgKind::Const(ct) => ct.fmt(f),
|
||||
|
|
@ -326,7 +326,7 @@ impl<'tcx, T: Lift<TyCtxt<'tcx>>> Lift<TyCtxt<'tcx>> for Option<T> {
|
|||
impl<'a, 'tcx> Lift<TyCtxt<'tcx>> for Term<'a> {
|
||||
type Lifted = ty::Term<'tcx>;
|
||||
fn lift_to_interner(self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
match self.unpack() {
|
||||
match self.kind() {
|
||||
TermKind::Ty(ty) => tcx.lift(ty).map(Into::into),
|
||||
TermKind::Const(c) => tcx.lift(c).map(Into::into),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -778,7 +778,7 @@ impl<'tcx> IsIdentity for CanonicalUserType<'tcx> {
|
|||
}
|
||||
|
||||
iter::zip(user_args.args, BoundVar::ZERO..).all(|(kind, cvar)| {
|
||||
match kind.unpack() {
|
||||
match kind.kind() {
|
||||
GenericArgKind::Type(ty) => match ty.kind() {
|
||||
ty::Bound(debruijn, b) => {
|
||||
// We only allow a `ty::INNERMOST` index in generic parameters.
|
||||
|
|
|
|||
|
|
@ -517,7 +517,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
let result = iter::zip(item_args, impl_args)
|
||||
.filter(|&(_, k)| {
|
||||
match k.unpack() {
|
||||
match k.kind() {
|
||||
GenericArgKind::Lifetime(region) => match region.kind() {
|
||||
ty::ReEarlyParam(ebr) => {
|
||||
!impl_generics.region_param(ebr, self).pure_wrt_drop
|
||||
|
|
@ -554,7 +554,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
let mut seen = GrowableBitSet::default();
|
||||
let mut seen_late = FxHashSet::default();
|
||||
for arg in args {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(lt) => match (ignore_regions, lt.kind()) {
|
||||
(CheckRegions::FromFunction, ty::ReBound(di, reg)) => {
|
||||
if !seen_late.insert((di, reg)) {
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ impl<'tcx> ConstToPat<'tcx> {
|
|||
.dcx()
|
||||
.create_err(ConstPatternDependsOnGenericParameter { span: self.span });
|
||||
for arg in uv.args {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Param(param_ty) = ty.kind()
|
||||
{
|
||||
let def_id = self.tcx.hir_enclosing_body_owner(self.id);
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ fn encode_args<'tcx>(
|
|||
s.push('I');
|
||||
let def_generics = tcx.generics_of(for_def);
|
||||
for (n, arg) in args.iter().enumerate() {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(region) => {
|
||||
s.push_str(&encode_region(region, dict));
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@ fn encode_predicate<'tcx>(
|
|||
let name = encode_ty_name(tcx, projection.def_id);
|
||||
let _ = write!(s, "u{}{}", name.len(), name);
|
||||
s.push_str(&encode_args(tcx, projection.args, projection.def_id, true, dict, options));
|
||||
match projection.term.unpack() {
|
||||
match projection.term.kind() {
|
||||
TermKind::Ty(ty) => s.push_str(&encode_ty(tcx, ty, dict, options)),
|
||||
TermKind::Const(c) => s.push_str(&encode_const(
|
||||
tcx,
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ impl<'tcx> Stable<'tcx> for ty::ExistentialProjection<'tcx> {
|
|||
stable_mir::ty::ExistentialProjection {
|
||||
def_id: tables.trait_def(*def_id),
|
||||
generic_args: args.stable(tables),
|
||||
term: term.unpack().stable(tables),
|
||||
term: term.kind().stable(tables),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ impl<'tcx> Stable<'tcx> for ty::FieldDef {
|
|||
impl<'tcx> Stable<'tcx> for ty::GenericArgs<'tcx> {
|
||||
type T = stable_mir::ty::GenericArgs;
|
||||
fn stable(&self, tables: &mut Tables<'_>) -> Self::T {
|
||||
GenericArgs(self.iter().map(|arg| arg.unpack().stable(tables)).collect())
|
||||
GenericArgs(self.iter().map(|arg| arg.kind().stable(tables)).collect())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -604,8 +604,8 @@ impl<'tcx> Stable<'tcx> for ty::PredicateKind<'tcx> {
|
|||
PredicateKind::NormalizesTo(_pred) => unimplemented!(),
|
||||
PredicateKind::AliasRelate(a, b, alias_relation_direction) => {
|
||||
stable_mir::ty::PredicateKind::AliasRelate(
|
||||
a.unpack().stable(tables),
|
||||
b.unpack().stable(tables),
|
||||
a.kind().stable(tables),
|
||||
b.kind().stable(tables),
|
||||
alias_relation_direction.stable(tables),
|
||||
)
|
||||
}
|
||||
|
|
@ -640,7 +640,7 @@ impl<'tcx> Stable<'tcx> for ty::ClauseKind<'tcx> {
|
|||
ty.stable(tables),
|
||||
),
|
||||
ClauseKind::WellFormed(term) => {
|
||||
stable_mir::ty::ClauseKind::WellFormed(term.unpack().stable(tables))
|
||||
stable_mir::ty::ClauseKind::WellFormed(term.kind().stable(tables))
|
||||
}
|
||||
ClauseKind::ConstEvaluatable(const_) => {
|
||||
stable_mir::ty::ClauseKind::ConstEvaluatable(const_.stable(tables))
|
||||
|
|
@ -726,7 +726,7 @@ impl<'tcx> Stable<'tcx> for ty::ProjectionPredicate<'tcx> {
|
|||
let ty::ProjectionPredicate { projection_term, term } = self;
|
||||
stable_mir::ty::ProjectionPredicate {
|
||||
projection_term: projection_term.stable(tables),
|
||||
term: term.unpack().stable(tables),
|
||||
term: term.kind().stable(tables),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ impl<'tcx> AbiHashStable<'tcx> for ty::FnSig<'tcx> {
|
|||
|
||||
impl<'tcx> AbiHashStable<'tcx> for ty::GenericArg<'tcx> {
|
||||
fn abi_hash(&self, tcx: TyCtxt<'tcx>, hasher: &mut StableHasher) {
|
||||
self.unpack().abi_hash(tcx, hasher);
|
||||
self.kind().abi_hash(tcx, hasher);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ impl<'tcx> Printer<'tcx> for SymbolPrinter<'tcx> {
|
|||
print_prefix(self)?;
|
||||
|
||||
let args =
|
||||
args.iter().cloned().filter(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)));
|
||||
args.iter().cloned().filter(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)));
|
||||
|
||||
if args.clone().next().is_some() {
|
||||
self.generic_delimiters(|cx| cx.comma_sep(args))
|
||||
|
|
|
|||
|
|
@ -646,7 +646,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||
let name = cx.tcx.associated_item(projection.def_id).name();
|
||||
cx.push("p");
|
||||
cx.push_ident(name.as_str());
|
||||
match projection.term.unpack() {
|
||||
match projection.term.kind() {
|
||||
ty::TermKind::Ty(ty) => ty.print(cx),
|
||||
ty::TermKind::Const(c) => c.print(cx),
|
||||
}?;
|
||||
|
|
@ -912,11 +912,11 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||
args: &[GenericArg<'tcx>],
|
||||
) -> Result<(), PrintError> {
|
||||
// Don't print any regions if they're all erased.
|
||||
let print_regions = args.iter().any(|arg| match arg.unpack() {
|
||||
let print_regions = args.iter().any(|arg| match arg.kind() {
|
||||
GenericArgKind::Lifetime(r) => !r.is_erased(),
|
||||
_ => false,
|
||||
});
|
||||
let args = args.iter().cloned().filter(|arg| match arg.unpack() {
|
||||
let args = args.iter().cloned().filter(|arg| match arg.kind() {
|
||||
GenericArgKind::Lifetime(_) => print_regions,
|
||||
_ => true,
|
||||
});
|
||||
|
|
@ -928,7 +928,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
|||
self.push("I");
|
||||
print_prefix(self)?;
|
||||
for arg in args {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
lt.print(self)?;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -738,7 +738,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
value.push_normal(", ");
|
||||
}
|
||||
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
ty::GenericArgKind::Lifetime(lt) => {
|
||||
let s = lt.to_string();
|
||||
value.push_normal(if s.is_empty() { "'_" } else { &s });
|
||||
|
|
@ -1166,7 +1166,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
|
||||
for (i, (arg1, arg2)) in sub1.iter().zip(sub2).enumerate().take(len) {
|
||||
self.push_comma(&mut values.0, &mut values.1, i);
|
||||
match arg1.unpack() {
|
||||
match arg1.kind() {
|
||||
// At one point we'd like to elide all lifetimes here, they are
|
||||
// irrelevant for all diagnostics that use this output.
|
||||
//
|
||||
|
|
@ -1509,7 +1509,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
let (is_simple_error, exp_found) = match values {
|
||||
ValuePairs::Terms(ExpectedFound { expected, found }) => {
|
||||
match (expected.unpack(), found.unpack()) {
|
||||
match (expected.kind(), found.kind()) {
|
||||
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
|
||||
let is_simple_err =
|
||||
expected.is_simple_text() && found.is_simple_text();
|
||||
|
|
@ -2156,7 +2156,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
return None;
|
||||
}
|
||||
|
||||
Some(match (exp_found.expected.unpack(), exp_found.found.unpack()) {
|
||||
Some(match (exp_found.expected.kind(), exp_found.found.kind()) {
|
||||
(ty::TermKind::Ty(expected), ty::TermKind::Ty(found)) => {
|
||||
let (mut exp, mut fnd) = self.cmp(expected, found);
|
||||
// Use the terminal width as the basis to determine when to compress the printed
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ impl<'a, 'tcx> TypeFolder<TyCtxt<'tcx>> for ClosureEraser<'a, 'tcx> {
|
|||
// `_` because then we'd end up with `Vec<_, _>`, instead of
|
||||
// `Vec<_>`.
|
||||
arg
|
||||
} else if let GenericArgKind::Type(_) = arg.unpack() {
|
||||
} else if let GenericArgKind::Type(_) = arg.kind() {
|
||||
// We don't replace lifetime or const params, only type params.
|
||||
self.new_infer().into()
|
||||
} else {
|
||||
|
|
@ -347,7 +347,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
highlight: ty::print::RegionHighlightMode<'tcx>,
|
||||
) -> InferenceDiagnosticsData {
|
||||
let tcx = self.tcx;
|
||||
match term.unpack() {
|
||||
match term.kind() {
|
||||
TermKind::Ty(ty) => {
|
||||
if let ty::Infer(ty::TyVar(ty_vid)) = *ty.kind() {
|
||||
let var_origin = self.infcx.type_var_origin(ty_vid);
|
||||
|
|
@ -568,7 +568,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
return arg;
|
||||
}
|
||||
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(_) => bug!("unexpected lifetime"),
|
||||
GenericArgKind::Type(_) => self.next_ty_var(DUMMY_SP).into(),
|
||||
GenericArgKind::Const(_) => self.next_const_var(DUMMY_SP).into(),
|
||||
|
|
@ -803,7 +803,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
}
|
||||
impl<'tcx> CostCtxt<'tcx> {
|
||||
fn arg_cost(self, arg: GenericArg<'tcx>) -> usize {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
GenericArgKind::Lifetime(_) => 0, // erased
|
||||
GenericArgKind::Type(ty) => self.ty_cost(ty),
|
||||
GenericArgKind::Const(_) => 3, // some non-zero value
|
||||
|
|
@ -898,7 +898,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
return true;
|
||||
}
|
||||
|
||||
match (arg.unpack(), self.target.unpack()) {
|
||||
match (arg.kind(), self.target.kind()) {
|
||||
(GenericArgKind::Type(inner_ty), TermKind::Ty(target_ty)) => {
|
||||
use ty::{Infer, TyVar};
|
||||
match (inner_ty.kind(), target_ty.kind()) {
|
||||
|
|
@ -929,7 +929,7 @@ impl<'a, 'tcx> FindInferSourceVisitor<'a, 'tcx> {
|
|||
if self.generic_arg_is_target(inner) {
|
||||
return true;
|
||||
}
|
||||
match inner.unpack() {
|
||||
match inner.kind() {
|
||||
GenericArgKind::Lifetime(_) => {}
|
||||
GenericArgKind::Type(ty) => {
|
||||
if matches!(
|
||||
|
|
|
|||
|
|
@ -664,8 +664,8 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
|
|||
let Some(found) = exp_found.found.args.get(1) else {
|
||||
return;
|
||||
};
|
||||
let expected = expected.unpack();
|
||||
let found = found.unpack();
|
||||
let expected = expected.kind();
|
||||
let found = found.kind();
|
||||
// 3. Extract the tuple type from Fn trait and suggest the change.
|
||||
if let GenericArgKind::Type(expected) = expected
|
||||
&& let GenericArgKind::Type(found) = found
|
||||
|
|
|
|||
|
|
@ -2446,7 +2446,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
if let ty::Adt(def, args) = self_ty.kind()
|
||||
&& let [arg] = &args[..]
|
||||
&& let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
&& let ty::GenericArgKind::Type(ty) = arg.kind()
|
||||
&& let ty::Adt(inner_def, _) = ty.kind()
|
||||
&& inner_def == def
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ pub fn check_opaque_type_parameter_valid<'tcx>(
|
|||
}
|
||||
|
||||
for (i, arg) in opaque_type_key.iter_captured_args(tcx) {
|
||||
let arg_is_param = match arg.unpack() {
|
||||
let arg_is_param = match arg.kind() {
|
||||
GenericArgKind::Lifetime(lt) => match defining_scope_kind {
|
||||
DefiningScopeKind::HirTypeck => continue,
|
||||
DefiningScopeKind::MirBorrowck => {
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ impl<'tcx> rustc_next_trait_solver::delegate::SolverDelegate for SolverDelegate<
|
|||
arg: ty::GenericArg<'tcx>,
|
||||
span: Span,
|
||||
) -> ty::GenericArg<'tcx> {
|
||||
match arg.unpack() {
|
||||
match arg.kind() {
|
||||
ty::GenericArgKind::Lifetime(_) => {
|
||||
self.next_region_var(RegionVariableOrigin::MiscVariable(span)).into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ impl<'a, 'tcx> InspectCandidate<'a, 'tcx> {
|
|||
let infcx = self.goal.infcx;
|
||||
match goal.predicate.kind().no_bound_vars() {
|
||||
Some(ty::PredicateKind::NormalizesTo(ty::NormalizesTo { alias, term })) => {
|
||||
let unconstrained_term = match term.unpack() {
|
||||
let unconstrained_term = match term.kind() {
|
||||
ty::TermKind::Ty(_) => infcx.next_ty_var(span).into(),
|
||||
ty::TermKind::Const(_) => infcx.next_const_var(span).into(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1784,7 +1784,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
|||
if !generics.is_own_empty()
|
||||
&& obligation.predicate.args[generics.parent_count..].iter().any(|&p| {
|
||||
p.has_non_region_infer()
|
||||
&& match p.unpack() {
|
||||
&& match p.kind() {
|
||||
ty::GenericArgKind::Const(ct) => {
|
||||
self.infcx.shallow_resolve_const(ct) != ct
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ impl<'tcx> At<'_, 'tcx> {
|
|||
return Ok(term);
|
||||
}
|
||||
|
||||
let new_infer = match term.unpack() {
|
||||
let new_infer = match term.kind() {
|
||||
ty::TermKind::Ty(_) => self.infcx.next_ty_var(self.cause.span).into(),
|
||||
ty::TermKind::Const(_) => self.infcx.next_const_var(self.cause.span).into(),
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ pub fn obligations<'tcx>(
|
|||
span: Span,
|
||||
) -> Option<PredicateObligations<'tcx>> {
|
||||
// Handle the "cycle" case (see comment above) by bailing out if necessary.
|
||||
let term = match term.unpack() {
|
||||
let term = match term.kind() {
|
||||
TermKind::Ty(ty) => {
|
||||
match ty.kind() {
|
||||
ty::Infer(ty::TyVar(_)) => {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ fn representability_adt_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> Representab
|
|||
// but the type parameters may cause a cycle with an upstream type
|
||||
let params_in_repr = tcx.params_in_repr(adt.did());
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind() {
|
||||
if params_in_repr.contains(i as u32) {
|
||||
rtry!(representability_ty(tcx, ty));
|
||||
}
|
||||
|
|
@ -104,7 +104,7 @@ fn params_in_repr_ty<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, params_in_repr: &mut
|
|||
ty::Adt(adt, args) => {
|
||||
let inner_params_in_repr = tcx.params_in_repr(adt.did());
|
||||
for (i, arg) in args.iter().enumerate() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.kind() {
|
||||
if inner_params_in_repr.contains(i as u32) {
|
||||
params_in_repr_ty(tcx, ty, params_in_repr);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,7 +274,7 @@ fn unsizing_params_for_adt<'tcx>(tcx: TyCtxt<'tcx>, def_id: DefId) -> DenseBitSe
|
|||
let def = tcx.adt_def(def_id);
|
||||
let num_params = tcx.generics_of(def_id).count();
|
||||
|
||||
let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.unpack() {
|
||||
let maybe_unsizing_param_idx = |arg: ty::GenericArg<'tcx>| match arg.kind() {
|
||||
ty::GenericArgKind::Type(ty) => match ty.kind() {
|
||||
ty::Param(p) => Some(p.index),
|
||||
_ => None,
|
||||
|
|
|
|||
|
|
@ -449,7 +449,7 @@ fn clean_middle_term<'tcx>(
|
|||
term: ty::Binder<'tcx, ty::Term<'tcx>>,
|
||||
cx: &mut DocContext<'tcx>,
|
||||
) -> Term {
|
||||
match term.skip_binder().unpack() {
|
||||
match term.skip_binder().kind() {
|
||||
ty::TermKind::Ty(ty) => Term::Type(clean_middle_ty(term.rebind(ty), cx, None, None)),
|
||||
ty::TermKind::Const(c) => Term::Constant(clean_middle_const(term.rebind(c), cx)),
|
||||
}
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ pub(crate) fn clean_middle_generic_args<'tcx>(
|
|||
elision_has_failed_once_before = true;
|
||||
}
|
||||
|
||||
match arg.skip_binder().unpack() {
|
||||
match arg.skip_binder().kind() {
|
||||
GenericArgKind::Lifetime(lt) => {
|
||||
Some(GenericArg::Lifetime(clean_middle_region(lt).unwrap_or(Lifetime::elided())))
|
||||
}
|
||||
|
|
@ -161,7 +161,7 @@ fn can_elide_generic_arg<'tcx>(
|
|||
default: ty::Binder<'tcx, ty::GenericArg<'tcx>>,
|
||||
) -> bool {
|
||||
debug_assert_matches!(
|
||||
(actual.skip_binder().unpack(), default.skip_binder().unpack()),
|
||||
(actual.skip_binder().kind(), default.skip_binder().kind()),
|
||||
(ty::GenericArgKind::Lifetime(_), ty::GenericArgKind::Lifetime(_))
|
||||
| (ty::GenericArgKind::Type(_), ty::GenericArgKind::Type(_))
|
||||
| (ty::GenericArgKind::Const(_), ty::GenericArgKind::Const(_))
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl<'tcx> LateLintPass<'tcx> for ArcWithNonSendSync {
|
|||
&& let arg_ty = cx.typeck_results().expr_ty(arg)
|
||||
// make sure that the type is not and does not contain any type parameters
|
||||
&& arg_ty.walk().all(|arg| {
|
||||
!matches!(arg.unpack(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
|
||||
!matches!(arg.kind(), GenericArgKind::Type(ty) if matches!(ty.kind(), ty::Param(_)))
|
||||
})
|
||||
&& let Some(send) = cx.tcx.get_diagnostic_item(sym::Send)
|
||||
&& let Some(sync) = cx.tcx.lang_items().sync_trait()
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ fn check_copy_clone<'tcx>(cx: &LateContext<'tcx>, item: &Item<'_>, trait_ref: &h
|
|||
if ty_adt.repr().packed()
|
||||
&& ty_subs
|
||||
.iter()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(_) | GenericArgKind::Const(_)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
|
|||
return true;
|
||||
}
|
||||
for (from_arg, to_arg) in to_subs.iter().zip(from_subs) {
|
||||
match (from_arg.unpack(), to_arg.unpack()) {
|
||||
match (from_arg.kind(), to_arg.kind()) {
|
||||
(GenericArgKind::Lifetime(from_region), GenericArgKind::Lifetime(to_region)) => {
|
||||
if check_region(from_region, to_region) {
|
||||
return true;
|
||||
|
|
@ -354,5 +354,5 @@ fn has_late_bound_to_non_late_bound_regions(from_sig: FnSig<'_>, to_sig: FnSig<'
|
|||
|
||||
fn ty_has_static(ty: Ty<'_>) -> bool {
|
||||
ty.walk()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if re.is_static()))
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if re.is_static()))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ fn check_ty<'a>(cx: &LateContext<'a>, param: &rustc_hir::Ty<'a>, param_ty: Ty<'a
|
|||
&& is_type_diagnostic_item(cx, *opt_ty, sym::Option)
|
||||
&& let ty::Adt(_, opt_gen_args) = opt_ty.kind()
|
||||
&& let [gen_arg] = opt_gen_args.as_slice()
|
||||
&& let GenericArgKind::Type(gen_ty) = gen_arg.unpack()
|
||||
&& let GenericArgKind::Type(gen_ty) = gen_arg.kind()
|
||||
&& !gen_ty.is_ref()
|
||||
// Need to gen the original spans, so first parsing mid, and hir parsing afterward
|
||||
&& let hir::TyKind::Ref(lifetime, hir::MutTy { ty, .. }) = param.kind
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
|
|||
&& !local.span.in_external_macro(cx.tcx.sess.source_map())
|
||||
{
|
||||
let init_ty = cx.typeck_results().expr_ty(init);
|
||||
let contains_sync_guard = init_ty.walk().any(|inner| match inner.unpack() {
|
||||
let contains_sync_guard = init_ty.walk().any(|inner| match inner.kind() {
|
||||
GenericArgKind::Type(inner_ty) => inner_ty
|
||||
.ty_adt_def()
|
||||
.is_some_and(|adt| paths::PARKING_LOT_GUARDS.iter().any(|path| path.matches(cx, adt.did()))),
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ fn handle(
|
|||
&& implements_trait(cx, expr_type, default_trait_id, &[])
|
||||
// We check if the initial condition implements Default.
|
||||
&& let Some(condition_ty) = cx.typeck_results().expr_ty(condition).walk().nth(1)
|
||||
&& let GenericArgKind::Type(condition_ty) = condition_ty.unpack()
|
||||
&& let GenericArgKind::Type(condition_ty) = condition_ty.kind()
|
||||
&& implements_trait(cx, condition_ty, default_trait_id, &[])
|
||||
&& is_default_equivalent(cx, peel_blocks(body_none))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ fn find_match_true<'tcx>(
|
|||
fn try_get_generic_ty(ty: Ty<'_>, index: usize) -> Option<Ty<'_>> {
|
||||
if let ty::Adt(_, subs) = ty.kind()
|
||||
&& let Some(sub) = subs.get(index)
|
||||
&& let GenericArgKind::Type(sub_ty) = sub.unpack()
|
||||
&& let GenericArgKind::Type(sub_ty) = sub.kind()
|
||||
{
|
||||
Some(sub_ty)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -208,12 +208,12 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
|
|||
// (to avoid false positive on `Ref<'a, MutexGuard<Foo>>`)
|
||||
|| (args
|
||||
.iter()
|
||||
.all(|arg| !matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
|
||||
.all(|arg| !matches!(arg.kind(), GenericArgKind::Lifetime(_)))
|
||||
// some generic parameter has significant drop
|
||||
// (to avoid false negative on `Box<MutexGuard<Foo>>`)
|
||||
&& args
|
||||
.iter()
|
||||
.filter_map(|arg| match arg.unpack() {
|
||||
.filter_map(|arg| match arg.kind() {
|
||||
GenericArgKind::Type(ty) => Some(ty),
|
||||
_ => None,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -508,7 +508,7 @@ fn get_captured_ids(cx: &LateContext<'_>, ty: Ty<'_>) -> HirIdSet {
|
|||
match ty.kind() {
|
||||
ty::Adt(_, generics) => {
|
||||
for generic in *generics {
|
||||
if let GenericArgKind::Type(ty) = generic.unpack() {
|
||||
if let GenericArgKind::Type(ty) = generic.kind() {
|
||||
get_captured_ids_recursive(cx, ty, set);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,7 +188,7 @@ fn detect_lint(cx: &LateContext<'_>, expr: &Expr<'_>, recv: &Expr<'_>, arg: &Exp
|
|||
|
||||
fn expr_borrows(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
|
||||
let ty = cx.typeck_results().expr_ty(expr);
|
||||
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(_)))
|
||||
matches!(ty.kind(), ty::Ref(..)) || ty.walk().any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(_)))
|
||||
}
|
||||
|
||||
pub(super) fn check<'tcx>(
|
||||
|
|
|
|||
|
|
@ -608,7 +608,7 @@ fn can_change_type<'a>(cx: &LateContext<'a>, mut expr: &'a Expr<'a>, mut ty: Ty<
|
|||
}
|
||||
|
||||
fn has_lifetime(ty: Ty<'_>) -> bool {
|
||||
ty.walk().any(|t| matches!(t.unpack(), GenericArgKind::Lifetime(_)))
|
||||
ty.walk().any(|t| matches!(t.kind(), GenericArgKind::Lifetime(_)))
|
||||
}
|
||||
|
||||
/// Returns true if the named method is `Iterator::cloned` or `Iterator::copied`.
|
||||
|
|
@ -643,7 +643,7 @@ fn is_to_string_on_string_like<'a>(
|
|||
|
||||
if let Some(args) = cx.typeck_results().node_args_opt(call_expr.hir_id)
|
||||
&& let [generic_arg] = args.as_slice()
|
||||
&& let GenericArgKind::Type(ty) = generic_arg.unpack()
|
||||
&& let GenericArgKind::Type(ty) = generic_arg.kind()
|
||||
&& let Some(deref_trait_id) = cx.tcx.get_diagnostic_item(sym::Deref)
|
||||
&& let Some(as_ref_trait_id) = cx.tcx.get_diagnostic_item(sym::AsRef)
|
||||
&& (cx.get_associated_type(ty, deref_trait_id, sym::Target) == Some(cx.tcx.types.str_)
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ fn needless_borrow_count<'tcx>(
|
|||
.tcx
|
||||
.is_diagnostic_item(sym::IntoIterator, trait_predicate.trait_ref.def_id)
|
||||
&& let ty::Param(param_ty) = trait_predicate.self_ty().kind()
|
||||
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].unpack()
|
||||
&& let GenericArgKind::Type(ty) = args_with_referent_ty[param_ty.index as usize].kind()
|
||||
&& ty.is_array()
|
||||
&& !msrv.meets(cx, msrvs::ARRAY_INTO_ITERATOR)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ impl NonSendField<'_> {
|
|||
/// Example: `MyStruct<P, Box<Q, R>>` => `vec![P, Q, R]`
|
||||
fn collect_generic_params(ty: Ty<'_>) -> Vec<Ty<'_>> {
|
||||
ty.walk()
|
||||
.filter_map(|inner| match inner.unpack() {
|
||||
.filter_map(|inner| match inner.kind() {
|
||||
GenericArgKind::Type(inner_ty) => Some(inner_ty),
|
||||
_ => None,
|
||||
})
|
||||
|
|
@ -208,7 +208,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
|
|||
ty::Adt(_, args) => {
|
||||
if contains_pointer_like(cx, ty) {
|
||||
// descends only if ADT contains any raw pointers
|
||||
args.iter().all(|generic_arg| match generic_arg.unpack() {
|
||||
args.iter().all(|generic_arg| match generic_arg.kind() {
|
||||
GenericArgKind::Type(ty) => ty_allowed_with_raw_pointer_heuristic(cx, ty, send_trait),
|
||||
// Lifetimes and const generics are not solid part of ADT and ignored
|
||||
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => true,
|
||||
|
|
@ -226,7 +226,7 @@ fn ty_allowed_with_raw_pointer_heuristic<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'t
|
|||
/// Checks if the type contains any pointer-like types in args (including nested ones)
|
||||
fn contains_pointer_like<'tcx>(cx: &LateContext<'tcx>, target_ty: Ty<'tcx>) -> bool {
|
||||
for ty_node in target_ty.walk() {
|
||||
if let GenericArgKind::Type(inner_ty) = ty_node.unpack() {
|
||||
if let GenericArgKind::Type(inner_ty) = ty_node.kind() {
|
||||
match inner_ty.kind() {
|
||||
ty::RawPtr(_, _) => {
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -385,7 +385,7 @@ impl<'tcx> LateLintPass<'tcx> for OnlyUsedInRecursion {
|
|||
fn has_matching_args(kind: FnKind, args: GenericArgsRef<'_>) -> bool {
|
||||
match kind {
|
||||
FnKind::Fn => true,
|
||||
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.unpack() {
|
||||
FnKind::TraitFn => args.iter().enumerate().all(|(idx, subst)| match subst.kind() {
|
||||
GenericArgKind::Lifetime(_) => true,
|
||||
GenericArgKind::Type(ty) => matches!(*ty.kind(), ty::Param(ty) if ty.index as usize == idx),
|
||||
GenericArgKind::Const(c) => matches!(c.kind(), ConstKind::Param(c) if c.index as usize == idx),
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@ fn last_statement_borrows<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>)
|
|||
.skip_binder()
|
||||
.output()
|
||||
.walk()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
|
|||
}
|
||||
}
|
||||
for generic_arg in *b {
|
||||
if let GenericArgKind::Type(ty) = generic_arg.unpack()
|
||||
if let GenericArgKind::Type(ty) = generic_arg.kind()
|
||||
&& self.has_sig_drop_attr(ty, depth)
|
||||
{
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -319,7 +319,7 @@ fn same_lifetimes<'tcx>(a: MiddleTy<'tcx>, b: MiddleTy<'tcx>) -> bool {
|
|||
args_a
|
||||
.iter()
|
||||
.zip(args_b.iter())
|
||||
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
|
||||
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
|
||||
// TODO: Handle inferred lifetimes
|
||||
(GenericArgKind::Lifetime(inner_a), GenericArgKind::Lifetime(inner_b)) => inner_a == inner_b,
|
||||
(GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => same_lifetimes(type_a, type_b),
|
||||
|
|
@ -337,7 +337,7 @@ fn has_no_lifetime(ty: MiddleTy<'_>) -> bool {
|
|||
&Adt(_, args) => !args
|
||||
.iter()
|
||||
// TODO: Handle inferred lifetimes
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(..))),
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(..))),
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ impl LateLintPass<'_> for MsrvAttrImpl {
|
|||
.type_of(f.did)
|
||||
.instantiate_identity()
|
||||
.walk()
|
||||
.filter(|t| matches!(t.unpack(), GenericArgKind::Type(_)))
|
||||
.filter(|t| matches!(t.kind(), GenericArgKind::Type(_)))
|
||||
.any(|t| internal_paths::MSRV_STACK.matches_ty(cx, t.expect_ty()))
|
||||
})
|
||||
&& !items.iter().any(|item| item.ident.name.as_str() == "check_attributes")
|
||||
|
|
|
|||
|
|
@ -3316,7 +3316,7 @@ pub fn leaks_droppable_temporary_with_limited_lifetime<'tcx>(cx: &LateContext<'t
|
|||
if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
|
||||
&& temporary_ty
|
||||
.walk()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Lifetime(re) if !re.is_static()))
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub fn is_min_const_fn<'tcx>(cx: &LateContext<'tcx>, body: &Body<'tcx>, msrv: Ms
|
|||
|
||||
fn check_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, span: Span, msrv: Msrv) -> McfResult {
|
||||
for arg in ty.walk() {
|
||||
let ty = match arg.unpack() {
|
||||
let ty = match arg.kind() {
|
||||
GenericArgKind::Type(ty) => ty,
|
||||
|
||||
// No constraints on lifetimes or constants, except potentially
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ pub fn can_partially_move_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>) -> bool
|
|||
/// Walks into `ty` and returns `true` if any inner type is an instance of the given adt
|
||||
/// constructor.
|
||||
pub fn contains_adt_constructor<'tcx>(ty: Ty<'tcx>, adt: AdtDef<'tcx>) -> bool {
|
||||
ty.walk().any(|inner| match inner.unpack() {
|
||||
ty.walk().any(|inner| match inner.kind() {
|
||||
GenericArgKind::Type(inner_ty) => inner_ty.ty_adt_def() == Some(adt),
|
||||
GenericArgKind::Lifetime(_) | GenericArgKind::Const(_) => false,
|
||||
})
|
||||
|
|
@ -96,7 +96,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
|||
needle: Ty<'tcx>,
|
||||
seen: &mut FxHashSet<DefId>,
|
||||
) -> bool {
|
||||
ty.walk().any(|inner| match inner.unpack() {
|
||||
ty.walk().any(|inner| match inner.kind() {
|
||||
GenericArgKind::Type(inner_ty) => {
|
||||
if inner_ty == needle {
|
||||
return true;
|
||||
|
|
@ -129,7 +129,7 @@ pub fn contains_ty_adt_constructor_opaque<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'
|
|||
// For `impl Trait<Assoc=U>`, it will register a predicate of `<T as Trait>::Assoc = U`,
|
||||
// so we check the term for `U`.
|
||||
ty::ClauseKind::Projection(projection_predicate) => {
|
||||
if let ty::TermKind::Ty(ty) = projection_predicate.term.unpack()
|
||||
if let ty::TermKind::Ty(ty) = projection_predicate.term.kind()
|
||||
&& contains_ty_adt_constructor_opaque_inner(cx, ty, needle, seen)
|
||||
{
|
||||
return true;
|
||||
|
|
@ -526,7 +526,7 @@ pub fn same_type_and_consts<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
|
|||
args_a
|
||||
.iter()
|
||||
.zip(args_b.iter())
|
||||
.all(|(arg_a, arg_b)| match (arg_a.unpack(), arg_b.unpack()) {
|
||||
.all(|(arg_a, arg_b)| match (arg_a.kind(), arg_b.kind()) {
|
||||
(GenericArgKind::Const(inner_a), GenericArgKind::Const(inner_b)) => inner_a == inner_b,
|
||||
(GenericArgKind::Type(type_a), GenericArgKind::Type(type_b)) => {
|
||||
same_type_and_consts(type_a, type_b)
|
||||
|
|
@ -996,7 +996,7 @@ fn assert_generic_args_match<'tcx>(tcx: TyCtxt<'tcx>, did: DefId, args: &[Generi
|
|||
if let Some((idx, (param, arg))) =
|
||||
params
|
||||
.clone()
|
||||
.zip(args.iter().map(|&x| x.unpack()))
|
||||
.zip(args.iter().map(|&x| x.kind()))
|
||||
.enumerate()
|
||||
.find(|(_, (param, arg))| match (param, arg) {
|
||||
(GenericParamDefKind::Lifetime, GenericArgKind::Lifetime(_))
|
||||
|
|
|
|||
|
|
@ -326,5 +326,5 @@ fn adt_def_id(ty: Ty<'_>) -> Option<DefId> {
|
|||
|
||||
fn contains_param(ty: Ty<'_>, index: u32) -> bool {
|
||||
ty.walk()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Type(ty) if ty.is_param(index)))
|
||||
.any(|arg| matches!(arg.kind(), GenericArgKind::Type(ty) if ty.is_param(index)))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1775,7 +1775,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
|
|||
let is_generic = instance
|
||||
.args
|
||||
.into_iter()
|
||||
.any(|kind| !matches!(kind.unpack(), ty::GenericArgKind::Lifetime(_)));
|
||||
.any(|arg| !matches!(arg.kind(), ty::GenericArgKind::Lifetime(_)));
|
||||
let can_be_inlined = matches!(
|
||||
ecx.tcx.sess.opts.unstable_opts.cross_crate_inline_threshold,
|
||||
InliningThreshold::Always
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue