pub(crate) struct DelegationResolver<'a, 'hir>(&'a LoweringContext<'a, 'hir>);Expand description
Abstracts operations that are needed for delegation’s resolution, so resolution
is independent of LoweringContext. Placed in a separate module so LoweringContext
can not be accessed directly.
Tuple Fields§
§0: &'a LoweringContext<'a, 'hir>Implementations§
Source§impl<'hir> DelegationResolver<'_, 'hir>
impl<'hir> DelegationResolver<'_, 'hir>
fn resolve_generics<'a>( &self, delegation: &'a Delegation, sig_id: DefId, ) -> Result<GenericsResolution<'a, 'hir>, ErrorGuaranteed>
fn get_user_args<'a>( &self, segment: &'a PathSegment, ) -> Option<&'a AngleBracketedArgs>
pub(super) fn resolve_and_generate_generics( &self, delegation: &Delegation, sig_id: DefId, ) -> Result<GenericsGenerationResults<'hir>, ErrorGuaranteed>
Sourcefn create_slots_from_args(
tcx: TyCtxt<'_>,
args: &AngleBracketedArgs,
params: &'hir [GenericParamDef],
add_first_self: bool,
) -> Vec<GenericArgSlot<&'hir GenericParamDef>>
fn create_slots_from_args( tcx: TyCtxt<'_>, args: &AngleBracketedArgs, params: &'hir [GenericParamDef], add_first_self: bool, ) -> Vec<GenericArgSlot<&'hir GenericParamDef>>
Generates generic argument slots for user-specified args and
generic params of the signature function. This function checks whether
there are infers (kw::UnderscoreLifetime or kw::Underscore) in
user-specified args, and if so we add Generate slot meaning we have to
generate generic param for delegation and propagate it instead of this infer.
We zip over user-specified args and signature generic params, so if there are more
infers than generic params then we will not process all infers thus not generating
more generic params then needed (anyway it is an error).
Source§impl<'a, 'tcx> DelegationResolver<'a, 'tcx>
impl<'a, 'tcx> DelegationResolver<'a, 'tcx>
pub(crate) fn new(ctx: &'a LoweringContext<'a, 'tcx>) -> Self
pub(crate) fn tcx(&self) -> TyCtxt<'tcx>
pub(crate) fn owner_id(&self) -> LocalDefId
Sourcepub(crate) fn is_definition(&self, id: NodeId) -> bool
pub(crate) fn is_definition(&self, id: NodeId) -> bool
(from tests\ui\delegation\target-expr-removal-defs-inside.rs):
reuse impl Trait for S1 {
some::path::<{ fn foo() {} }>::xd();
fn foo() {}
self.0
}Constant from unresolved path will be in node_id_to_def_id,
fn foo() {} will not be in node_id_to_def_id but will be in owners,
both have LocalDefId, so we check those two maps.
pub(crate) fn get_resolution_id( &self, id: NodeId, ) -> Result<DefId, ErrorGuaranteed>
Source§impl<'tcx> DelegationResolver<'_, 'tcx>
impl<'tcx> DelegationResolver<'_, 'tcx>
pub(super) fn resolve_delegation( &self, delegation: &Delegation, span: Span, ) -> Result<(DelegationResolution, GenericsGenerationResults<'tcx>), ErrorGuaranteed>
fn check_for_cycles( &self, def_id: DefId, span: Span, ) -> Result<(), ErrorGuaranteed>
fn check_block_soundness( &self, delegation: &Delegation, sig_id: DefId, is_method: bool, param_count: usize, ) -> Result<(bool, bool), ErrorGuaranteed>
fn create_sig_mapping( &self, delegation: &Delegation, span: Span, should_generate_block: bool, parent: LocalDefId, sig: FnSig<'tcx>, contains_defs: bool, ) -> Result<SigMapping, ErrorGuaranteed>
fn can_perform_self_mapping( &self, delegation: &Delegation, parent: LocalDefId, ) -> Result<bool, ErrorGuaranteed>
Auto Trait Implementations§
impl<'a, 'hir> !DynSend for DelegationResolver<'a, 'hir>
impl<'a, 'hir> !DynSync for DelegationResolver<'a, 'hir>
impl<'a, 'hir> !RefUnwindSafe for DelegationResolver<'a, 'hir>
impl<'a, 'hir> !Send for DelegationResolver<'a, 'hir>
impl<'a, 'hir> !Sync for DelegationResolver<'a, 'hir>
impl<'a, 'hir> !UnwindSafe for DelegationResolver<'a, 'hir>
impl<'a, 'hir> Freeze for DelegationResolver<'a, 'hir>
impl<'a, 'hir> Unpin for DelegationResolver<'a, 'hir>
impl<'a, 'hir> UnsafeUnpin for DelegationResolver<'a, 'hir>
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
impl<T> ErasedDestructor for Twhere
T: 'static,
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<K> IntoQueryKey<K> for K
impl<K> IntoQueryKey<K> for K
Source§fn into_query_key(self) -> K
fn into_query_key(self) -> K
Self to K.
This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§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>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 8 bytes