Struct rustc_next_trait_solver::coherence::OrphanChecker
source · struct OrphanChecker<'a, Infcx, I: Interner, F> {
infcx: &'a Infcx,
in_crate: InCrate,
in_self_ty: bool,
lazily_normalize_ty: F,
search_first_local_ty: bool,
non_local_tys: Vec<(I::Ty, IsFirstInputType)>,
}
Fields§
§infcx: &'a Infcx
§in_crate: InCrate
§in_self_ty: bool
§lazily_normalize_ty: F
§search_first_local_ty: bool
Ignore orphan check failures and exclusively search for the first local type.
non_local_tys: Vec<(I::Ty, IsFirstInputType)>
Implementations§
source§impl<'a, Infcx, I, F, E> OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F, E> OrphanChecker<'a, Infcx, I, F>
fn new(infcx: &'a Infcx, in_crate: InCrate, lazily_normalize_ty: F) -> Self
fn found_non_local_ty( &mut self, t: I::Ty, ) -> ControlFlow<OrphanCheckEarlyExit<I, E>>
fn found_uncovered_ty_param( &mut self, ty: I::Ty, ) -> ControlFlow<OrphanCheckEarlyExit<I, E>>
fn def_id_is_local(&mut self, def_id: I::DefId) -> bool
Trait Implementations§
source§impl<'a, Infcx, I, F, E> TypeVisitor<I> for OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F, E> TypeVisitor<I> for OrphanChecker<'a, Infcx, I, F>
source§fn visit_const(&mut self, _c: I::Const) -> Self::Result
fn visit_const(&mut self, _c: I::Const) -> Self::Result
All possible values for a constant parameter already exist in the crate defining the trait, so they are always non-local1.
Because there’s no way to have an impl where the first local generic argument is a constant, we also don’t have to fail the orphan check when encountering a parameter or a generic constant.
This means that we can completely ignore constants during the orphan check.
See tests/ui/coherence/const-generics-orphan-check-ok.rs
for examples.
This might not hold for function pointers or trait objects in the future. As these should be quite rare as const arguments and especially rare as impl parameters, allowing uncovered const parameters in impls seems more useful than allowing
impl<T> Trait<local_fn_ptr, T> for i32
to compile. ↩
type Result = ControlFlow<OrphanCheckEarlyExit<I, E>>
fn visit_region(&mut self, _r: I::Region) -> Self::Result
fn visit_ty(&mut self, ty: I::Ty) -> Self::Result
fn visit_binder<T>(&mut self, t: &Binder<I, T>) -> Self::Resultwhere
T: TypeVisitable<I>,
fn visit_predicate(&mut self, p: <I as Interner>::Predicate) -> Self::Result
fn visit_clauses(&mut self, p: <I as Interner>::Clauses) -> Self::Result
fn visit_error( &mut self, _guar: <I as Interner>::ErrorGuaranteed, ) -> Self::Result
Auto Trait Implementations§
impl<'a, Infcx, I, F> Freeze for OrphanChecker<'a, Infcx, I, F>where
F: Freeze,
impl<'a, Infcx, I, F> RefUnwindSafe for OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F> Send for OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F> Sync for OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F> Unpin for OrphanChecker<'a, Infcx, I, F>
impl<'a, Infcx, I, F> UnwindSafe for OrphanChecker<'a, Infcx, I, F>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.