always use GenericArgsRef

This commit is contained in:
lcnr 2024-05-09 19:47:08 +00:00
parent 8c7c151a7a
commit 8f9062530b
9 changed files with 19 additions and 15 deletions

View File

@ -315,7 +315,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
trait_def_id: DefId, trait_def_id: DefId,
self_ty: Ty<'tcx>, self_ty: Ty<'tcx>,
opt_input_types: Option<&[Ty<'tcx>]>, opt_input_types: Option<&[Ty<'tcx>]>,
) -> (traits::PredicateObligation<'tcx>, &'tcx ty::List<ty::GenericArg<'tcx>>) { ) -> (traits::PredicateObligation<'tcx>, ty::GenericArgsRef<'tcx>) {
// Construct a trait-reference `self_ty : Trait<input_tys>` // Construct a trait-reference `self_ty : Trait<input_tys>`
let args = GenericArgs::for_item(self.tcx, trait_def_id, |param, _| { let args = GenericArgs::for_item(self.tcx, trait_def_id, |param, _| {
match param.kind { match param.kind {
@ -365,7 +365,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
m_name: Ident, m_name: Ident,
trait_def_id: DefId, trait_def_id: DefId,
obligation: traits::PredicateObligation<'tcx>, obligation: traits::PredicateObligation<'tcx>,
args: &'tcx ty::List<ty::GenericArg<'tcx>>, args: ty::GenericArgsRef<'tcx>,
) -> Option<InferOk<'tcx, MethodCallee<'tcx>>> { ) -> Option<InferOk<'tcx, MethodCallee<'tcx>>> {
debug!(?obligation); debug!(?obligation);

View File

@ -1676,7 +1676,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
unmentioned_fields: &mut Vec<(&'tcx ty::FieldDef, Ident)>, unmentioned_fields: &mut Vec<(&'tcx ty::FieldDef, Ident)>,
pat: &'tcx Pat<'tcx>, pat: &'tcx Pat<'tcx>,
variant: &ty::VariantDef, variant: &ty::VariantDef,
args: &'tcx ty::List<ty::GenericArg<'tcx>>, args: ty::GenericArgsRef<'tcx>,
) -> Diag<'tcx> { ) -> Diag<'tcx> {
let tcx = self.tcx; let tcx = self.tcx;
let (field_names, t, plural) = if let [field] = inexistent_fields { let (field_names, t, plural) = if let [field] = inexistent_fields {

View File

@ -9,7 +9,7 @@ use crate::{
use hir::{Expr, Pat}; use hir::{Expr, Pat};
use rustc_hir as hir; use rustc_hir as hir;
use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause}; use rustc_infer::{infer::TyCtxtInferExt, traits::ObligationCause};
use rustc_middle::ty::{self, List}; use rustc_middle::ty;
use rustc_session::{declare_lint, declare_lint_pass}; use rustc_session::{declare_lint, declare_lint_pass};
use rustc_span::{sym, Span}; use rustc_span::{sym, Span};
use rustc_trait_selection::traits::ObligationCtxt; use rustc_trait_selection::traits::ObligationCtxt;
@ -123,7 +123,7 @@ fn extract_iterator_next_call<'tcx>(
fn suggest_question_mark<'tcx>( fn suggest_question_mark<'tcx>(
cx: &LateContext<'tcx>, cx: &LateContext<'tcx>,
adt: ty::AdtDef<'tcx>, adt: ty::AdtDef<'tcx>,
args: &List<ty::GenericArg<'tcx>>, args: ty::GenericArgsRef<'tcx>,
span: Span, span: Span,
) -> bool { ) -> bool {
let Some(body_id) = cx.enclosing_body else { return false }; let Some(body_id) = cx.enclosing_body else { return false };

View File

@ -2331,7 +2331,7 @@ impl<'tcx> TyCtxt<'tcx> {
pub fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output pub fn mk_args_from_iter<I, T>(self, iter: I) -> T::Output
where where
I: Iterator<Item = T>, I: Iterator<Item = T>,
T: CollectAndApply<GenericArg<'tcx>, &'tcx List<GenericArg<'tcx>>>, T: CollectAndApply<GenericArg<'tcx>, ty::GenericArgsRef<'tcx>>,
{ {
T::collect_and_apply(iter, |xs| self.mk_args(xs)) T::collect_and_apply(iter, |xs| self.mk_args(xs))
} }

View File

@ -977,7 +977,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
fn pretty_print_opaque_impl_type( fn pretty_print_opaque_impl_type(
&mut self, &mut self,
def_id: DefId, def_id: DefId,
args: &'tcx ty::List<ty::GenericArg<'tcx>>, args: ty::GenericArgsRef<'tcx>,
) -> Result<(), PrintError> { ) -> Result<(), PrintError> {
let tcx = self.tcx(); let tcx = self.tcx();

View File

@ -10,7 +10,7 @@ use rustc_infer::infer::canonical::Canonical;
use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt}; use rustc_infer::infer::{RegionResolutionError, TyCtxtInferExt};
use rustc_infer::traits::query::NoSolution; use rustc_infer::traits::query::NoSolution;
use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError}; use rustc_infer::{infer::outlives::env::OutlivesEnvironment, traits::FulfillmentError};
use rustc_middle::ty::{self, AdtDef, GenericArg, List, Ty, TyCtxt, TypeVisitableExt}; use rustc_middle::ty::{self, AdtDef, Ty, TyCtxt, TypeVisitableExt};
use rustc_span::DUMMY_SP; use rustc_span::DUMMY_SP;
use super::outlives_bounds::InferCtxtExt; use super::outlives_bounds::InferCtxtExt;
@ -129,7 +129,7 @@ pub fn all_fields_implement_trait<'tcx>(
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
self_type: Ty<'tcx>, self_type: Ty<'tcx>,
adt: AdtDef<'tcx>, adt: AdtDef<'tcx>,
args: &'tcx List<GenericArg<'tcx>>, args: ty::GenericArgsRef<'tcx>,
parent_cause: ObligationCause<'tcx>, parent_cause: ObligationCause<'tcx>,
lang_item: LangItem, lang_item: LangItem,
) -> Result<(), Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>> { ) -> Result<(), Vec<(&'tcx ty::FieldDef, Ty<'tcx>, InfringingFieldsReason<'tcx>)>> {

View File

@ -2,7 +2,7 @@ use clippy_utils::diagnostics::span_lint_and_help;
use rustc_hir::{HirId, Item, ItemKind}; use rustc_hir::{HirId, Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::layout::LayoutOf; use rustc_middle::ty::layout::LayoutOf;
use rustc_middle::ty::{self, FieldDef, GenericArg, List}; use rustc_middle::ty::{self, FieldDef};
use rustc_session::declare_lint_pass; use rustc_session::declare_lint_pass;
use rustc_span::sym; use rustc_span::sym;
@ -85,7 +85,7 @@ fn is_union_with_two_non_zst_fields<'tcx>(cx: &LateContext<'tcx>, item: &Item<'t
} }
} }
fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: &'tcx List<GenericArg<'tcx>>) -> bool { fn is_zst<'tcx>(cx: &LateContext<'tcx>, field: &FieldDef, args: ty::GenericArgsRef<'tcx>) -> bool {
let ty = field.ty(cx.tcx, args); let ty = field.ty(cx.tcx, args);
if let Ok(layout) = cx.layout_of(ty) { if let Ok(layout) = cx.layout_of(ty) {
layout.is_zst() layout.is_zst()

View File

@ -13,7 +13,7 @@ use rustc_infer::infer::TyCtxtInferExt;
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::mir::{Rvalue, StatementKind}; use rustc_middle::mir::{Rvalue, StatementKind};
use rustc_middle::ty::{ use rustc_middle::ty::{
self, ClauseKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, List, ParamTy, ProjectionPredicate, Ty, self, ClauseKind, EarlyBinder, FnSig, GenericArg, GenericArgKind, ParamTy, ProjectionPredicate, Ty,
}; };
use rustc_session::impl_lint_pass; use rustc_session::impl_lint_pass;
use rustc_span::symbol::sym; use rustc_span::symbol::sym;
@ -161,7 +161,7 @@ fn needless_borrow_count<'tcx>(
cx: &LateContext<'tcx>, cx: &LateContext<'tcx>,
possible_borrowers: &mut Vec<(LocalDefId, PossibleBorrowerMap<'tcx, 'tcx>)>, possible_borrowers: &mut Vec<(LocalDefId, PossibleBorrowerMap<'tcx, 'tcx>)>,
fn_id: DefId, fn_id: DefId,
callee_args: &'tcx List<GenericArg<'tcx>>, callee_args: ty::GenericArgsRef<'tcx>,
arg_index: usize, arg_index: usize,
param_ty: ParamTy, param_ty: ParamTy,
mut expr: &Expr<'tcx>, mut expr: &Expr<'tcx>,

View File

@ -19,7 +19,7 @@ use rustc_middle::traits::EvaluationResult;
use rustc_middle::ty::layout::ValidityRequirement; use rustc_middle::ty::layout::ValidityRequirement;
use rustc_middle::ty::{ use rustc_middle::ty::{
self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, FnSig, GenericArg, GenericArgKind, GenericArgsRef, self, AdtDef, AliasTy, AssocKind, Binder, BoundRegion, FnSig, GenericArg, GenericArgKind, GenericArgsRef,
GenericParamDefKind, IntTy, List, ParamEnv, Region, RegionKind, ToPredicate, TraitRef, Ty, TyCtxt, GenericParamDefKind, IntTy, ParamEnv, Region, RegionKind, ToPredicate, TraitRef, Ty, TyCtxt,
TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, VariantDef, VariantDiscr, TypeSuperVisitable, TypeVisitable, TypeVisitableExt, TypeVisitor, UintTy, VariantDef, VariantDiscr,
}; };
use rustc_span::symbol::Ident; use rustc_span::symbol::Ident;
@ -961,7 +961,11 @@ pub struct AdtVariantInfo {
impl AdtVariantInfo { impl AdtVariantInfo {
/// Returns ADT variants ordered by size /// Returns ADT variants ordered by size
pub fn new<'tcx>(cx: &LateContext<'tcx>, adt: AdtDef<'tcx>, subst: &'tcx List<GenericArg<'tcx>>) -> Vec<Self> { pub fn new<'tcx>(
cx: &LateContext<'tcx>,
adt: AdtDef<'tcx>,
subst: GenericArgsRef<'tcx>
) -> Vec<Self> {
let mut variants_size = adt let mut variants_size = adt
.variants() .variants()
.iter() .iter()