1
Fork 0

Stop taking ParamTy/ParamConst/EarlyParamRegion/AliasTy by ref

This commit is contained in:
Michael Goulet 2024-04-19 21:09:51 -04:00
parent f9b1614920
commit 86756c1804
14 changed files with 38 additions and 38 deletions

View file

@ -124,7 +124,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
msg: &str,
err: &mut Diag<'_, G>,
fn_sig: Option<&hir::FnSig<'_>>,
projection: Option<&ty::AliasTy<'_>>,
projection: Option<ty::AliasTy<'_>>,
trait_pred: ty::PolyTraitPredicate<'tcx>,
// When we are dealing with a trait, `super_traits` will be `Some`:
// Given `trait T: A + B + C {}`
@ -142,7 +142,7 @@ pub fn suggest_restriction<'tcx, G: EmissionGuarantee>(
let generics = tcx.generics_of(item_id);
// Given `fn foo(t: impl Trait)` where `Trait` requires assoc type `A`...
if let Some((param, bound_str, fn_sig)) =
fn_sig.zip(projection).and_then(|(sig, p)| match p.self_ty().kind() {
fn_sig.zip(projection).and_then(|(sig, p)| match *p.self_ty().kind() {
// Shenanigans to get the `Trait` from the `impl Trait`.
ty::Param(param) => {
let param_def = generics.type_param(param, tcx);
@ -252,7 +252,7 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
let trait_pred = self.resolve_numeric_literals_with_default(trait_pred);
let self_ty = trait_pred.skip_binder().self_ty();
let (param_ty, projection) = match self_ty.kind() {
let (param_ty, projection) = match *self_ty.kind() {
ty::Param(_) => (true, None),
ty::Alias(ty::Projection, projection) => (false, Some(projection)),
_ => (false, None),

View file

@ -482,7 +482,7 @@ fn is_impossible_associated_item(
type Result = ControlFlow<()>;
fn visit_ty(&mut self, t: Ty<'tcx>) -> Self::Result {
// If this is a parameter from the trait item's own generics, then bail
if let ty::Param(param) = t.kind()
if let ty::Param(param) = *t.kind()
&& let param_def_id = self.generics.type_param(param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
@ -492,7 +492,7 @@ fn is_impossible_associated_item(
}
fn visit_region(&mut self, r: ty::Region<'tcx>) -> Self::Result {
if let ty::ReEarlyParam(param) = r.kind()
&& let param_def_id = self.generics.region_param(&param, self.tcx).def_id
&& let param_def_id = self.generics.region_param(param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
return ControlFlow::Break(());
@ -501,7 +501,7 @@ fn is_impossible_associated_item(
}
fn visit_const(&mut self, ct: ty::Const<'tcx>) -> Self::Result {
if let ty::ConstKind::Param(param) = ct.kind()
&& let param_def_id = self.generics.const_param(&param, self.tcx).def_id
&& let param_def_id = self.generics.const_param(param, self.tcx).def_id
&& self.tcx.parent(param_def_id) == self.trait_item_def_id
{
return ControlFlow::Break(());