hax_rust_engine/ast/
identifiers.rs

1//! Identifier types used throughout the AST.
2//!
3//! This module provides two kinds of identifiers:
4//! - `GlobalId`: fully-qualified paths like `std::mem::drop`
5//! - `LocalId`: local identifiers
6
7use crate::symbol::Symbol;
8use hax_rust_engine_macros::*;
9use std::fmt;
10
11pub mod global_id;
12/// Local identifier
13#[derive_group_for_ast]
14pub struct LocalId(pub Symbol);
15
16impl fmt::Display for LocalId {
17    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
18        write!(f, "{}", self.0)
19    }
20}
21impl From<&hax_frontend_exporter::LocalIdent> for LocalId {
22    fn from(value: &hax_frontend_exporter::LocalIdent) -> Self {
23        Self(Symbol::new(&value.name))
24    }
25}
26impl From<&str> for LocalId {
27    fn from(name: &str) -> Self {
28        Self(Symbol::new(name))
29    }
30}
31
32pub use global_id::GlobalId;