Remove unnecessary extension trait

This commit is contained in:
Michael Goulet 2024-06-01 13:22:35 -04:00
parent 8768db9912
commit 084ccd2390
6 changed files with 24 additions and 31 deletions

View File

@ -15,8 +15,8 @@
use crate::infer::region_constraints::{Constraint, RegionConstraintData};
use crate::infer::{DefineOpaqueTypes, InferCtxt, InferOk, InferResult};
use crate::traits::query::NoSolution;
use crate::traits::TraitEngine;
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
use crate::traits::{TraitEngine, TraitEngineExt};
use rustc_data_structures::captures::Captures;
use rustc_index::Idx;
use rustc_index::IndexVec;

View File

@ -12,7 +12,7 @@
pub use ValuePairs::*;
use crate::traits::{
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine, TraitEngineExt,
self, ObligationCause, ObligationInspector, PredicateObligations, TraitEngine,
};
use error_reporting::TypeErrCtxt;
use free_regions::RegionRelations;

View File

@ -1,7 +1,6 @@
use crate::infer::InferCtxt;
use crate::traits::Obligation;
use rustc_hir::def_id::DefId;
use rustc_macros::extension;
use rustc_middle::ty::{self, Ty, Upcast};
use super::FulfillmentError;
@ -37,11 +36,31 @@ fn register_predicate_obligation(
obligation: PredicateObligation<'tcx>,
);
fn register_predicate_obligations(
&mut self,
infcx: &InferCtxt<'tcx>,
obligations: Vec<PredicateObligation<'tcx>>,
) {
for obligation in obligations {
self.register_predicate_obligation(infcx, obligation);
}
}
#[must_use]
fn select_where_possible(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>>;
fn collect_remaining_errors(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>>;
#[must_use]
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
let errors = self.select_where_possible(infcx);
if !errors.is_empty() {
return errors;
}
self.collect_remaining_errors(infcx)
}
fn pending_obligations(&self) -> Vec<PredicateObligation<'tcx>>;
/// Among all pending obligations, collect those are stalled on a inference variable which has
@ -52,26 +71,3 @@ fn drain_unstalled_obligations(
infcx: &InferCtxt<'tcx>,
) -> Vec<PredicateObligation<'tcx>>;
}
#[extension(pub trait TraitEngineExt<'tcx>)]
impl<'tcx, T: ?Sized + TraitEngine<'tcx>> T {
fn register_predicate_obligations(
&mut self,
infcx: &InferCtxt<'tcx>,
obligations: impl IntoIterator<Item = PredicateObligation<'tcx>>,
) {
for obligation in obligations {
self.register_predicate_obligation(infcx, obligation);
}
}
#[must_use]
fn select_all_or_error(&mut self, infcx: &InferCtxt<'tcx>) -> Vec<FulfillmentError<'tcx>> {
let errors = self.select_where_possible(infcx);
if !errors.is_empty() {
return errors;
}
self.collect_remaining_errors(infcx)
}
}

View File

@ -23,7 +23,7 @@
pub use self::SelectionError::*;
use crate::infer::InferCtxt;
pub use self::engine::{TraitEngine, TraitEngineExt};
pub use self::engine::TraitEngine;
pub use self::project::MismatchedProjectionTypes;
pub(crate) use self::project::UndoLog;
pub use self::project::{

View File

@ -4,7 +4,6 @@
use rustc_data_structures::stack::ensure_sufficient_stack;
use rustc_infer::infer::at::At;
use rustc_infer::infer::InferCtxt;
use rustc_infer::traits::TraitEngineExt;
use rustc_infer::traits::{FulfillmentError, Obligation, TraitEngine};
use rustc_middle::traits::ObligationCause;
use rustc_middle::ty::{self, Ty, TyCtxt, UniverseIndex};

View File

@ -18,9 +18,7 @@
use rustc_infer::infer::outlives::env::OutlivesEnvironment;
use rustc_infer::infer::RegionResolutionError;
use rustc_infer::infer::{DefineOpaqueTypes, InferCtxt, InferOk};
use rustc_infer::traits::{
FulfillmentError, Obligation, ObligationCause, PredicateObligation, TraitEngineExt as _,
};
use rustc_infer::traits::{FulfillmentError, Obligation, ObligationCause, PredicateObligation};
use rustc_macros::extension;
use rustc_middle::arena::ArenaAllocatable;
use rustc_middle::traits::query::NoSolution;