pub enum LintExpectationId {
Unstable {
attr_id: AttrId,
lint_index: Option<u16>,
},
Stable {
hir_id: HirId,
attr_index: u16,
lint_index: Option<u16>,
},
}
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
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§impl PartialEq for LintExpectationId
impl PartialEq for LintExpectationId
Source§impl PartialOrd for LintExpectationId
impl PartialOrd for LintExpectationId
Source§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(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx 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§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: 16 bytes
Size for each variant:
Unstable
: 10 bytesStable
: 14 bytes