Skip to content

Commit

Permalink
Cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
WINSDK committed May 5, 2024
1 parent 9fa8887 commit 0f15d2e
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 64 deletions.
21 changes: 1 addition & 20 deletions commands/src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,6 @@ const MAX_DEPTH: usize = 256;

type Span = std::ops::RangeInclusive<usize>;

/// Trait for indicating that any error has to be propagated up.
trait Failing: Sized {
fn failing(self, ctx: &mut Context) -> Self;
}

impl<T, E> Failing for Result<T, E> {
fn failing(self, ctx: &mut Context) -> Self {
ctx.is_failing = self.is_err();
self
}
}

impl<T> Failing for Option<T> {
fn failing(self, ctx: &mut Context) -> Self {
ctx.is_failing = self.is_none();
self
}
}

/// Index into expression arena.
#[derive(Debug, PartialEq, Clone, Copy)]
struct ExprRef(usize);
Expand All @@ -60,7 +41,7 @@ struct Context<'src> {
/// Recursion depth.
depth: usize,

/// Indicator used by the [`Failing`] trait.
/// Indicator that error is unrecoverable.
is_failing: bool,

/// Arena of expressions.
Expand Down
35 changes: 0 additions & 35 deletions debugvault/src/itanium/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ trait ArgScope<'me, 'ctx>: fmt::Debug {
/// Get the current scope's `index`th template argument.
fn get_template_arg(&'me self, index: usize)
-> Result<(&'ctx TemplateArg, &'ctx TemplateArgs)>;

/// Get the current scope's `index`th function argument's type.
fn get_function_arg(&'me self, index: usize) -> Result<&'ctx Type>;
}

/// An `ArgScopeStack` represents the current function and template demangling
Expand Down Expand Up @@ -282,18 +279,6 @@ impl<'prev, 'subs> ArgScope<'prev, 'subs> for Option<ArgScopeStack<'prev, 'subs>

Err(error::Error::BadTemplateArgReference)
}

fn get_function_arg(&'prev self, idx: usize) -> Result<&'subs Type> {
let mut scope = self.as_ref();
while let Some(s) = scope {
if let Ok(arg) = s.item.get_function_arg(idx) {
return Ok(arg);
}
scope = s.prev;
}

Err(error::Error::BadFunctionArgReference)
}
}

/// Common state that is required when demangling a mangled symbol's parsed AST.
Expand Down Expand Up @@ -2166,10 +2151,6 @@ impl<'subs> ArgScope<'subs, 'subs> for SourceName {
) -> Result<(&'subs TemplateArg, &'subs TemplateArgs)> {
Err(error::Error::BadTemplateArgReference)
}

fn get_function_arg(&'subs self, _: usize) -> Result<&'subs Type> {
Err(error::Error::BadFunctionArgReference)
}
}

impl SourceName {
Expand Down Expand Up @@ -4062,10 +4043,6 @@ impl<'subs> ArgScope<'subs, 'subs> for UnnamedTypeName {
) -> Result<(&'subs TemplateArg, &'subs TemplateArgs)> {
Err(error::Error::BadTemplateArgReference)
}

fn get_function_arg(&'subs self, _: usize) -> Result<&'subs Type> {
Err(error::Error::BadFunctionArgReference)
}
}

/// The `<array-type>` production.
Expand Down Expand Up @@ -4596,10 +4573,6 @@ impl<'subs> ArgScope<'subs, 'subs> for TemplateArgs {
) -> Result<(&'subs TemplateArg, &'subs TemplateArgs)> {
self.0.get(idx).ok_or(error::Error::BadTemplateArgReference).map(|v| (v, self))
}

fn get_function_arg(&'subs self, _: usize) -> Result<&'subs Type> {
Err(error::Error::BadFunctionArgReference)
}
}

/// A <template-arg> production.
Expand Down Expand Up @@ -6367,10 +6340,6 @@ impl<'subs> ArgScope<'subs, 'subs> for ClosureTypeName {
) -> Result<(&'subs TemplateArg, &'subs TemplateArgs)> {
Err(error::Error::BadTemplateArgReference)
}

fn get_function_arg(&'subs self, _: usize) -> Result<&'subs Type> {
Err(error::Error::BadFunctionArgReference)
}
}

impl<'a> GetLeafName<'a> for ClosureTypeName {
Expand Down Expand Up @@ -6576,10 +6545,6 @@ impl<'a> ArgScope<'a, 'a> for WellKnownComponent {
fn get_template_arg(&'a self, _: usize) -> Result<(&'a TemplateArg, &'a TemplateArgs)> {
Err(error::Error::BadTemplateArgReference)
}

fn get_function_arg(&'a self, _: usize) -> Result<&'a Type> {
Err(error::Error::BadFunctionArgReference)
}
}

impl<'subs> DemangleAsLeaf<'subs> for WellKnownComponent {
Expand Down
9 changes: 0 additions & 9 deletions debugvault/src/itanium/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ pub enum Error {
/// within an earlier arg).
ForwardTemplateArgReference,

/// Found a reference to a function arg that is either out-of-bounds, or in
/// a context without function args.
BadFunctionArgReference,

/// Found a reference to a leaf name in a context where there is no current
/// leaf name.
BadLeafNameReference,
Expand Down Expand Up @@ -70,11 +66,6 @@ impl fmt::Display for Error {
"reference to a template arg from itself or a later template arg"
)
}
Error::BadFunctionArgReference => write!(
f,
"reference to a function arg that is either out-of-bounds, or in a context \
without function args"
),
Error::BadLeafNameReference => write!(
f,
"reference to a leaf name in a context where there is no current leaf name"
Expand Down

0 comments on commit 0f15d2e

Please sign in to comment.