assembler: apply clippy lints
This commit is contained in:
@@ -16,23 +16,28 @@ impl From<Symbol> for SymbolId {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for SymbolId {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SymbolId {
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
Self(Uuid::new_v4())
|
||||
}
|
||||
|
||||
/// Convenience method to get the [`Module`] from a [`ModuleId`].
|
||||
#[must_use]
|
||||
pub fn to_module<'s>(&self, registry: &'s SymbolTable) -> Option<&'s Symbol> {
|
||||
registry.get(self)
|
||||
}
|
||||
|
||||
/// Convenience method to get the [`Module`] name from a [`ModuleId`].
|
||||
pub fn to_module_name<'m>(self, registry: &'m SymbolTable) -> Option<&'m str> {
|
||||
if let Some(module) = self.to_module(®istry) {
|
||||
Some(module.name.as_str())
|
||||
} else {
|
||||
None
|
||||
}
|
||||
#[must_use]
|
||||
pub fn to_module_name(self, registry: &SymbolTable) -> Option<&str> {
|
||||
self.to_module(registry).map(|module| module.name.as_str())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,6 +87,7 @@ pub struct Symbol {
|
||||
}
|
||||
|
||||
impl Symbol {
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
name: String,
|
||||
module_id: ModuleId,
|
||||
@@ -123,6 +129,7 @@ impl Symbol {
|
||||
}
|
||||
|
||||
/// Returns whether a [`Symbol`] depends on `symbol_id`.
|
||||
#[must_use]
|
||||
pub fn depends_on(&self, symbol_id: &SymbolId) -> bool {
|
||||
self.dependencies.contains(symbol_id)
|
||||
}
|
||||
@@ -140,14 +147,14 @@ impl Symbol {
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
/// The visibility of the symbol in different object files.
|
||||
pub enum Visibility {
|
||||
/// STB_PUBLIC under the ELF spec. Visible in all other object files. Shall be used
|
||||
/// `STB_PUBLIC` under the ELF spec. Visible in all other object files. Shall be used
|
||||
/// for labels. Remember labels are namespaced in different files so they won't clash
|
||||
/// with one another.
|
||||
Public,
|
||||
/// Only visible within this object file. STB_LOCAL under ELF spec. Shall be used for
|
||||
/// data definitions unless they are marked public.
|
||||
/// Only visible within this object file. `STB_LOCAL` under ELF spec. Shall be used
|
||||
/// for data definitions unless they are marked public.
|
||||
Local,
|
||||
/// STB_WEAK under the ELF spec. Potentially unused.
|
||||
/// `STB_WEAK` under the ELF spec. Potentially unused.
|
||||
Weak,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user