refactor(rustc_middle): Substs -> GenericArg
This commit is contained in:
@@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxHashSet;
|
||||
use rustc_errors::Diagnostic;
|
||||
use rustc_hir::def_id::DefId;
|
||||
use rustc_infer::infer::InferOk;
|
||||
use rustc_middle::ty::SubstsRef;
|
||||
use rustc_middle::ty::GenericArgsRef;
|
||||
use rustc_middle::ty::{self, ImplSubject, ToPredicate, Ty, TyCtxt, TypeVisitableExt};
|
||||
use rustc_span::Span;
|
||||
use smallvec::SmallVec;
|
||||
@@ -194,24 +194,24 @@ impl Iterator for SupertraitDefIds<'_> {
|
||||
// Other
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/// Instantiate all bound parameters of the impl subject with the given substs,
|
||||
/// Instantiate all bound parameters of the impl subject with the given args,
|
||||
/// returning the resulting subject and all obligations that arise.
|
||||
/// The obligations are closed under normalization.
|
||||
pub fn impl_subject_and_oblig<'a, 'tcx>(
|
||||
selcx: &mut SelectionContext<'a, 'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
impl_def_id: DefId,
|
||||
impl_substs: SubstsRef<'tcx>,
|
||||
impl_args: GenericArgsRef<'tcx>,
|
||||
cause: impl Fn(usize, Span) -> ObligationCause<'tcx>,
|
||||
) -> (ImplSubject<'tcx>, impl Iterator<Item = PredicateObligation<'tcx>>) {
|
||||
let subject = selcx.tcx().impl_subject(impl_def_id);
|
||||
let subject = subject.subst(selcx.tcx(), impl_substs);
|
||||
let subject = subject.instantiate(selcx.tcx(), impl_args);
|
||||
|
||||
let InferOk { value: subject, obligations: normalization_obligations1 } =
|
||||
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(subject);
|
||||
|
||||
let predicates = selcx.tcx().predicates_of(impl_def_id);
|
||||
let predicates = predicates.instantiate(selcx.tcx(), impl_substs);
|
||||
let predicates = predicates.instantiate(selcx.tcx(), impl_args);
|
||||
let InferOk { value: predicates, obligations: normalization_obligations2 } =
|
||||
selcx.infcx.at(&ObligationCause::dummy(), param_env).normalize(predicates);
|
||||
let impl_obligations = super::predicates_for_generics(cause, param_env, predicates);
|
||||
@@ -303,13 +303,13 @@ pub enum TupleArgumentsFlag {
|
||||
No,
|
||||
}
|
||||
|
||||
// Verify that the trait item and its implementation have compatible substs lists
|
||||
pub fn check_substs_compatible<'tcx>(
|
||||
// Verify that the trait item and its implementation have compatible args lists
|
||||
pub fn check_args_compatible<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
assoc_item: ty::AssocItem,
|
||||
substs: ty::SubstsRef<'tcx>,
|
||||
args: ty::GenericArgsRef<'tcx>,
|
||||
) -> bool {
|
||||
fn check_substs_compatible_inner<'tcx>(
|
||||
fn check_args_compatible_inner<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
generics: &'tcx ty::Generics,
|
||||
args: &'tcx [ty::GenericArg<'tcx>],
|
||||
@@ -322,7 +322,7 @@ pub fn check_substs_compatible<'tcx>(
|
||||
|
||||
if let Some(parent) = generics.parent
|
||||
&& let parent_generics = tcx.generics_of(parent)
|
||||
&& !check_substs_compatible_inner(tcx, parent_generics, parent_args) {
|
||||
&& !check_args_compatible_inner(tcx, parent_generics, parent_args) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -339,7 +339,7 @@ pub fn check_substs_compatible<'tcx>(
|
||||
}
|
||||
|
||||
let generics = tcx.generics_of(assoc_item.def_id);
|
||||
// Chop off any additional substs (RPITIT) substs
|
||||
let substs = &substs[0..generics.count().min(substs.len())];
|
||||
check_substs_compatible_inner(tcx, generics, substs)
|
||||
// Chop off any additional args (RPITIT) args
|
||||
let args = &args[0..generics.count().min(args.len())];
|
||||
check_args_compatible_inner(tcx, generics, args)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user