Skip to content

Commit

Permalink
Make inspect::SymType enum non-exhaustive
Browse files Browse the repository at this point in the history
We want to leave open the options of adding additional variants to the
inspect::SymType enum down the line without breaking backwards
compatibility.
Mark the type as non-exhaustive to make sure that this is a possibility.

Signed-off-by: Daniel Müller <deso@posteo.net>
  • Loading branch information
d-e-s-o committed Jan 24, 2024
1 parent 10748f1 commit 7ded103
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Unreleased
by default)
- Added support for usage of perf map files as part of process symbolization
- Added `perf_map` attribute to `symbolize::Process` type
- Made `inspect::SymType` enum non-exhaustive


0.2.0-alpha.10
Expand Down
7 changes: 2 additions & 5 deletions capi/src/inspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl From<SymType> for blaze_sym_type {
SymType::Unknown => blaze_sym_type::BLAZE_SYM_UNKNOWN,
SymType::Function => blaze_sym_type::BLAZE_SYM_FUNC,
SymType::Variable => blaze_sym_type::BLAZE_SYM_VAR,
_ => unreachable!(),
}
}
}
Expand Down Expand Up @@ -196,11 +197,7 @@ fn convert_syms_list_to_c(syms_list: Vec<Vec<SymInfo>>) -> *const *const blaze_s
name: name_ptr,
addr,
size,
sym_type: match sym_type {
SymType::Function => blaze_sym_type::BLAZE_SYM_FUNC,
SymType::Variable => blaze_sym_type::BLAZE_SYM_VAR,
SymType::Unknown => blaze_sym_type::BLAZE_SYM_UNKNOWN,
},
sym_type: sym_type.into(),
file_offset: file_offset.unwrap_or(0),
obj_file_name,
}
Expand Down
1 change: 1 addition & 0 deletions src/inspect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use source::Source;

/// The type of a symbol.
#[derive(Clone, Copy, Debug, Default, Eq, Hash, PartialEq)]
#[non_exhaustive]
pub enum SymType {
/// The symbol type is unknown.
#[default]
Expand Down

0 comments on commit 7ded103

Please sign in to comment.