pub enum LintExpectationId {
Unstable {
attr_id: AttrId,
lint_index: Option<u16>,
},
Stable {
hir_id: HirId,
attr_index: u16,
lint_index: Option<u16>,
attr_id: Option<AttrId>,
},
}Expand description
Each lint expectation has a LintExpectationId assigned by the LintLevelsBuilder.
Expected diagnostics get the lint level Expect which stores the LintExpectationId
to match it with the actual expectation later on.
The LintExpectationId has to be stable between compilations, as diagnostic
instances might be loaded from cache. Lint messages can be emitted during an
EarlyLintPass operating on the AST and during a LateLintPass traversing the
HIR tree. The AST doesn’t have enough information to create a stable id. The
LintExpectationId will instead store the AttrId defining the expectation.
These LintExpectationId will be updated to use the stable [HirId] once the
AST has been lowered. The transformation is done by the LintLevelsBuilder
Each lint inside the expect attribute is tracked individually, the lint_index
identifies the lint inside the attribute and ensures that the IDs are unique.
The index values have a type of u16 to reduce the size of the LintExpectationId.
It’s reasonable to assume that no user will define 2^16 attributes on one node or
have that amount of lints listed. u16 values should therefore suffice.
Variants§
Unstable
Used for lints emitted during the EarlyLintPass. This id is not
hash stable and should not be cached.
Stable
The [HirId] that the lint expectation is attached to. This id is
stable and can be cached. The additional index ensures that nodes with
several expectations can correctly match diagnostics to the individual
expectation.
Implementations§
Trait Implementations§
source§impl Clone for LintExpectationId
impl Clone for LintExpectationId
source§fn clone(&self) -> LintExpectationId
fn clone(&self) -> LintExpectationId
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for LintExpectationId
impl Debug for LintExpectationId
source§impl<__D: SpanDecoder> Decodable<__D> for LintExpectationId
impl<__D: SpanDecoder> Decodable<__D> for LintExpectationId
source§impl<__E: SpanEncoder> Encodable<__E> for LintExpectationId
impl<__E: SpanEncoder> Encodable<__E> for LintExpectationId
source§impl Hash for LintExpectationId
impl Hash for LintExpectationId
source§impl<HCX: HashStableContext> HashStable<HCX> for LintExpectationId
impl<HCX: HashStableContext> HashStable<HCX> for LintExpectationId
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
source§impl Ord for LintExpectationId
impl Ord for LintExpectationId
source§fn cmp(&self, other: &LintExpectationId) -> Ordering
fn cmp(&self, other: &LintExpectationId) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for LintExpectationId
impl PartialEq for LintExpectationId
source§fn eq(&self, other: &LintExpectationId) -> bool
fn eq(&self, other: &LintExpectationId) -> bool
self and other values to be equal, and is used
by ==.source§impl PartialOrd for LintExpectationId
impl PartialOrd for LintExpectationId
source§fn partial_cmp(&self, other: &LintExpectationId) -> Option<Ordering>
fn partial_cmp(&self, other: &LintExpectationId) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self and other) and is used by the <=
operator. Read moresource§impl<HCX: HashStableContext> ToStableHashKey<HCX> for LintExpectationId
impl<HCX: HashStableContext> ToStableHashKey<HCX> for LintExpectationId
impl Copy for LintExpectationId
impl Eq for LintExpectationId
impl StructuralPartialEq for LintExpectationId
Auto Trait Implementations§
impl DynSend for LintExpectationId
impl DynSync for LintExpectationId
impl Freeze for LintExpectationId
impl RefUnwindSafe for LintExpectationId
impl Send for LintExpectationId
impl Sync for LintExpectationId
impl Unpin for LintExpectationId
impl UnwindSafe for LintExpectationId
Blanket Implementations§
§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T
fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'a mut [T]
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.source§impl<T> Filterable for T
impl<T> Filterable for T
source§fn filterable(
self,
filter_name: &'static str,
) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>
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<T> Pointable for T
impl<T> Pointable for 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,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
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: 20 bytes
Size for each variant:
Unstable: 10 bytesStable: 18 bytes