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§
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: Decoder> Decodable<__D> for LintExpectationId
impl<__D: Decoder> Decodable<__D> for LintExpectationId
source§impl<__E: Encoder> Encodable<__E> for LintExpectationId
impl<__E: Encoder> 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<LintExpectationId> for LintExpectationId
impl PartialEq<LintExpectationId> 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<LintExpectationId> for LintExpectationId
impl PartialOrd<LintExpectationId> 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 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§
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
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