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 Diagnostic
s 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
sourceimpl Clone for LintExpectationId
impl Clone for LintExpectationId
sourcefn clone(&self) -> LintExpectationId
fn clone(&self) -> LintExpectationId
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for LintExpectationId
impl Debug for LintExpectationId
sourceimpl<__D: Decoder> Decodable<__D> for LintExpectationId
impl<__D: Decoder> Decodable<__D> for LintExpectationId
sourceimpl<__E: Encoder> Encodable<__E> for LintExpectationId
impl<__E: Encoder> Encodable<__E> for LintExpectationId
sourceimpl Hash for LintExpectationId
impl Hash for LintExpectationId
sourceimpl<HCX: HashStableContext> HashStable<HCX> for LintExpectationId
impl<HCX: HashStableContext> HashStable<HCX> for LintExpectationId
fn hash_stable(&self, hcx: &mut HCX, hasher: &mut StableHasher)
sourceimpl Ord for LintExpectationId
impl Ord for LintExpectationId
sourcefn cmp(&self, other: &LintExpectationId) -> Ordering
fn cmp(&self, other: &LintExpectationId) -> Ordering
1.21.0 · sourcefn max(self, other: Self) -> Self
fn max(self, other: Self) -> Self
1.21.0 · sourcefn min(self, other: Self) -> Self
fn min(self, other: Self) -> Self
1.50.0 · sourcefn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
fn clamp(self, min: Self, max: Self) -> Selfwhere
Self: PartialOrd<Self>,
sourceimpl PartialEq<LintExpectationId> for LintExpectationId
impl PartialEq<LintExpectationId> for LintExpectationId
sourcefn eq(&self, other: &LintExpectationId) -> bool
fn eq(&self, other: &LintExpectationId) -> bool
sourceimpl PartialOrd<LintExpectationId> for LintExpectationId
impl PartialOrd<LintExpectationId> for LintExpectationId
sourcefn partial_cmp(&self, other: &LintExpectationId) -> Option<Ordering>
fn partial_cmp(&self, other: &LintExpectationId) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresourceimpl<HCX: HashStableContext> ToStableHashKey<HCX> for LintExpectationId
impl<HCX: HashStableContext> ToStableHashKey<HCX> for LintExpectationId
impl Copy for LintExpectationId
impl Eq for LintExpectationId
impl StructuralEq for LintExpectationId
impl StructuralPartialEq for LintExpectationId
Auto Trait Implementations
impl RefUnwindSafe for LintExpectationId
impl Send for LintExpectationId
impl Sync for LintExpectationId
impl Unpin for LintExpectationId
impl UnwindSafe for LintExpectationId
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut 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