summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_trait_selection/src/solve/assembly/mod.rs')
-rw-r--r--compiler/rustc_trait_selection/src/solve/assembly/mod.rs78
1 files changed, 9 insertions, 69 deletions
diff --git a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
index 36194f973..23d2c0c4e 100644
--- a/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
+++ b/compiler/rustc_trait_selection/src/solve/assembly/mod.rs
@@ -5,8 +5,10 @@ use crate::traits::coherence;
use rustc_hir::def_id::DefId;
use rustc_infer::traits::query::NoSolution;
use rustc_infer::traits::Reveal;
-use rustc_middle::traits::solve::inspect::CandidateKind;
-use rustc_middle::traits::solve::{CanonicalResponse, Certainty, Goal, QueryResult};
+use rustc_middle::traits::solve::inspect::ProbeKind;
+use rustc_middle::traits::solve::{
+ CandidateSource, CanonicalResponse, Certainty, Goal, QueryResult,
+};
use rustc_middle::traits::BuiltinImplSource;
use rustc_middle::ty::fast_reject::{SimplifiedType, TreatParams};
use rustc_middle::ty::{self, Ty, TyCtxt};
@@ -27,66 +29,6 @@ pub(super) struct Candidate<'tcx> {
pub(super) result: CanonicalResponse<'tcx>,
}
-/// Possible ways the given goal can be proven.
-#[derive(Debug, Clone, Copy)]
-pub(super) enum CandidateSource {
- /// A user written impl.
- ///
- /// ## Examples
- ///
- /// ```rust
- /// fn main() {
- /// let x: Vec<u32> = Vec::new();
- /// // This uses the impl from the standard library to prove `Vec<T>: Clone`.
- /// let y = x.clone();
- /// }
- /// ```
- Impl(DefId),
- /// A builtin impl generated by the compiler. When adding a new special
- /// trait, try to use actual impls whenever possible. Builtin impls should
- /// only be used in cases where the impl cannot be manually be written.
- ///
- /// Notable examples are auto traits, `Sized`, and `DiscriminantKind`.
- /// For a list of all traits with builtin impls, check out the
- /// [`EvalCtxt::assemble_builtin_impl_candidates`] method. Not
- BuiltinImpl(BuiltinImplSource),
- /// An assumption from the environment.
- ///
- /// More precisely we've used the `n-th` assumption in the `param_env`.
- ///
- /// ## Examples
- ///
- /// ```rust
- /// fn is_clone<T: Clone>(x: T) -> (T, T) {
- /// // This uses the assumption `T: Clone` from the `where`-bounds
- /// // to prove `T: Clone`.
- /// (x.clone(), x)
- /// }
- /// ```
- ParamEnv(usize),
- /// If the self type is an alias type, e.g. an opaque type or a projection,
- /// we know the bounds on that alias to hold even without knowing its concrete
- /// underlying type.
- ///
- /// More precisely this candidate is using the `n-th` bound in the `item_bounds` of
- /// the self type.
- ///
- /// ## Examples
- ///
- /// ```rust
- /// trait Trait {
- /// type Assoc: Clone;
- /// }
- ///
- /// fn foo<T: Trait>(x: <T as Trait>::Assoc) {
- /// // We prove `<T as Trait>::Assoc` by looking at the bounds on `Assoc` in
- /// // in the trait definition.
- /// let _y = x.clone();
- /// }
- /// ```
- AliasBound,
-}
-
/// Methods used to assemble candidates for either trait or projection goals.
pub(super) trait GoalKind<'tcx>:
TypeFoldable<TyCtxt<'tcx>> + Copy + Eq + std::fmt::Display
@@ -399,7 +341,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
let tcx = self.tcx();
let &ty::Alias(_, projection_ty) = goal.predicate.self_ty().kind() else { return };
- candidates.extend(self.probe(|_| CandidateKind::NormalizedSelfTyAssembly).enter(|ecx| {
+ candidates.extend(self.probe(|_| ProbeKind::NormalizedSelfTyAssembly).enter(|ecx| {
if num_steps < ecx.local_overflow_limit() {
let normalized_ty = ecx.next_ty_infer();
let normalizes_to_goal = goal.with(
@@ -527,7 +469,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
// FIXME: These should ideally not exist as a self type. It would be nice for
// the builtin auto trait impls of generators to instead directly recurse
// into the witness.
- ty::GeneratorWitness(_) | ty::GeneratorWitnessMIR(_, _) => (),
+ ty::GeneratorWitness(..) => (),
// These variants should not exist as a self type.
ty::Infer(ty::TyVar(_) | ty::FreshTy(_) | ty::FreshIntTy(_) | ty::FreshFloatTy(_))
@@ -679,8 +621,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
| ty::Dynamic(..)
| ty::Closure(..)
| ty::Generator(..)
- | ty::GeneratorWitness(_)
- | ty::GeneratorWitnessMIR(..)
+ | ty::GeneratorWitness(..)
| ty::Never
| ty::Tuple(_)
| ty::Param(_)
@@ -836,8 +777,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
| ty::Alias(..)
| ty::Closure(..)
| ty::Generator(..)
- | ty::GeneratorWitness(_)
- | ty::GeneratorWitnessMIR(..)
+ | ty::GeneratorWitness(..)
| ty::Never
| ty::Tuple(_)
| ty::Param(_)
@@ -910,7 +850,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
SolverMode::Coherence => {}
};
- let result = self.probe_candidate("coherence unknowable").enter(|ecx| {
+ let result = self.probe_misc_candidate("coherence unknowable").enter(|ecx| {
let trait_ref = goal.predicate.trait_ref(tcx);
#[derive(Debug)]