pub struct DeclFingerprint {
pub name: String,
pub kind: DeclKind,
pub body_hash: u64,
}Expand description
A stable, span-independent identity hash for a top-level declaration.
Two declarations with the same DeclFingerprint are structurally identical
modulo source positions. The body_hash is computed over the Debug
representation of the inner Decl value (not the surrounding Located<_>),
so spans do not contribute to the hash.
Fields§
§name: StringDeclaration name (empty string for anonymous or unnamed decls).
kind: DeclKindCoarse kind of the declaration.
body_hash: u64FNV-1a hash of format!("{:?}", located_decl.value).
Because we hash .value (not the Located wrapper), the span is not
included in the hash.
Implementations§
Source§impl DeclFingerprint
impl DeclFingerprint
Sourcepub fn of(decl: &Located<Decl>) -> Self
pub fn of(decl: &Located<Decl>) -> Self
Compute the fingerprint of a located declaration.
The body hash is derived from the pretty-printed representation of the
inner Decl value via print_decl. This is truly span-independent
because print_decl takes &Decl (not &Located<Decl>) and does not
print any source positions.
Using format!("{:?}", decl.value) would be incorrect here because
Decl contains Located<SurfaceExpr> sub-expressions whose Debug
output includes span information, making the hash span-dependent.
Sourcepub fn is_modified_version_of(&self, other: &DeclFingerprint) -> bool
pub fn is_modified_version_of(&self, other: &DeclFingerprint) -> bool
Returns true if self and other have the same name and kind but
a different body hash — i.e. the body was modified.
Trait Implementations§
Source§impl Clone for DeclFingerprint
impl Clone for DeclFingerprint
Source§fn clone(&self) -> DeclFingerprint
fn clone(&self) -> DeclFingerprint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more