Make selfless dyn AstConv methods into toplevel functions

This commit is contained in:
Maybe Waffle 2023-01-11 19:07:03 +00:00
parent 89f1555824
commit d642781708
4 changed files with 610 additions and 619 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,11 @@
//! instance of `AstConv`.
mod errors;
mod generics;
pub mod generics;
use crate::astconv::generics::{
check_generic_arg_count, create_substs_for_generic_args, prohibit_assoc_ty_binding,
};
use crate::bounds::Bounds;
use crate::collect::HirPlaceholderCollector;
use crate::errors::{
@ -286,7 +289,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
ty::BoundConstness::NotConst,
);
if let Some(b) = item_segment.args().bindings.first() {
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
prohibit_assoc_ty_binding(self.tcx(), b.span);
}
substs
@ -356,7 +359,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
assert!(self_ty.is_none());
}
let arg_count = Self::check_generic_arg_count(
let arg_count = check_generic_arg_count(
tcx,
span,
def_id,
@ -531,7 +534,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
inferred_params: vec![],
infer_args,
};
let substs = Self::create_substs_for_generic_args(
let substs = create_substs_for_generic_args(
tcx,
def_id,
parent_substs,
@ -617,7 +620,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
);
if let Some(b) = item_segment.args().bindings.first() {
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
prohibit_assoc_ty_binding(self.tcx(), b.span);
}
args
@ -811,7 +814,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
constness,
);
if let Some(b) = trait_segment.args().bindings.first() {
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
prohibit_assoc_ty_binding(self.tcx(), b.span);
}
self.tcx().mk_trait_ref(trait_def_id, substs)
}
@ -2308,7 +2311,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
for segment in segments {
// Only emit the first error to avoid overloading the user with error messages.
if let Some(b) = segment.args().bindings.first() {
Self::prohibit_assoc_ty_binding(self.tcx(), b.span);
prohibit_assoc_ty_binding(self.tcx(), b.span);
return true;
}
}

View File

@ -10,6 +10,9 @@ use rustc_hir::def::{CtorOf, DefKind, Res};
use rustc_hir::def_id::DefId;
use rustc_hir::lang_items::LangItem;
use rustc_hir::{ExprKind, GenericArg, Node, QPath};
use rustc_hir_analysis::astconv::generics::{
check_generic_arg_count_for_call, create_substs_for_generic_args,
};
use rustc_hir_analysis::astconv::{
AstConv, CreateSubstsForGenericArgsCtxt, ExplicitLateBound, GenericArgCountMismatch,
GenericArgCountResult, IsMethodCall, PathSeg,
@ -1067,7 +1070,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// parameter internally, but we don't allow users to specify the
// parameter's value explicitly, so we have to do some error-
// checking here.
let arg_count = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
let arg_count = check_generic_arg_count_for_call(
tcx,
span,
def_id,
@ -1233,7 +1236,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
let substs_raw = self_ctor_substs.unwrap_or_else(|| {
<dyn AstConv<'_>>::create_substs_for_generic_args(
create_substs_for_generic_args(
tcx,
def_id,
&[],

View File

@ -4,6 +4,9 @@ use crate::{callee, FnCtxt};
use rustc_hir as hir;
use rustc_hir::def_id::DefId;
use rustc_hir::GenericArg;
use rustc_hir_analysis::astconv::generics::{
check_generic_arg_count_for_call, create_substs_for_generic_args,
};
use rustc_hir_analysis::astconv::{AstConv, CreateSubstsForGenericArgsCtxt, IsMethodCall};
use rustc_infer::infer::{self, InferOk};
use rustc_middle::traits::{ObligationCauseCode, UnifyReceiverContext};
@ -331,7 +334,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
// variables.
let generics = self.tcx.generics_of(pick.item.def_id);
let arg_count_correct = <dyn AstConv<'_>>::check_generic_arg_count_for_call(
let arg_count_correct = check_generic_arg_count_for_call(
self.tcx,
self.span,
pick.item.def_id,
@ -398,7 +401,7 @@ impl<'a, 'tcx> ConfirmContext<'a, 'tcx> {
}
}
let substs = <dyn AstConv<'_>>::create_substs_for_generic_args(
let substs = create_substs_for_generic_args(
self.tcx,
pick.item.def_id,
parent_substs,