From ab0607b4959f43eb8feec9b462f7e54d263656ba Mon Sep 17 00:00:00 2001 From: Mason Reed Date: Mon, 13 Jan 2025 15:12:03 -0500 Subject: [PATCH] Fix misc typos and add typos to rust CI --- .github/workflows/rust.yml | 11 +++++++++++ plugins/pdb-ng/src/symbol_parser.rs | 2 +- rust/src/binaryview.rs | 6 +++--- rust/src/confidence.rs | 10 +++++----- rust/src/custombinaryview.rs | 4 ++-- rust/src/function.rs | 6 +++--- rust/src/interaction.rs | 2 +- rust/src/project.rs | 2 +- rust/src/symbol.rs | 2 +- rust/src/typeprinter.rs | 2 +- rust/src/types.rs | 24 ++++++++++++------------ 11 files changed, 41 insertions(+), 30 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index e82ebb5e1..b1e69106b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -41,3 +41,14 @@ jobs: uses: actions-rust-lang/rustfmt@v1 with: manifest-path: ./rust/Cargo.toml + + # Check spelling with typos + spelling: + name: typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Typo Check + uses: crate-ci/typos@v1.29.4 + with: + files: ./rust \ No newline at end of file diff --git a/plugins/pdb-ng/src/symbol_parser.rs b/plugins/pdb-ng/src/symbol_parser.rs index 5bf636f80..51e18d1c0 100644 --- a/plugins/pdb-ng/src/symbol_parser.rs +++ b/plugins/pdb-ng/src/symbol_parser.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use binaryninja::confidence::ConfMergable; +use binaryninja::confidence::ConfMergeable; use std::collections::{BTreeMap, HashMap, HashSet}; use std::mem; use std::sync::OnceLock; diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs index 6a9246fb7..c28c2c594 100644 --- a/rust/src/binaryview.rs +++ b/rust/src/binaryview.rs @@ -844,13 +844,13 @@ pub trait BinaryViewExt: BinaryViewBase { // TODO: Replace with BulkModify guard. /// Start adding segments in bulk. Useful for adding large numbers of segments. /// - /// After calling this any call to [BinaryViewExt::add_segment] will be uncommited until a call to + /// After calling this any call to [BinaryViewExt::add_segment] will be uncommitted until a call to /// [BinaryViewExt::end_bulk_add_segments] /// - /// If you wish to discard the uncommited segments you can call [BinaryViewExt::cancel_bulk_add_segments]. + /// If you wish to discard the uncommitted segments you can call [BinaryViewExt::cancel_bulk_add_segments]. /// /// NOTE: This **must** be paired with a later call to [BinaryViewExt::end_bulk_add_segments] or - /// [BinaryViewExt::cancel_bulk_add_segments], otherwise segments added after this call will stay uncommited. + /// [BinaryViewExt::cancel_bulk_add_segments], otherwise segments added after this call will stay uncommitted. fn begin_bulk_add_segments(&self) { unsafe { BNBeginBulkAddSegments(self.as_ref().handle) } } diff --git a/rust/src/confidence.rs b/rust/src/confidence.rs index 792e46be0..4d9152c5f 100644 --- a/rust/src/confidence.rs +++ b/rust/src/confidence.rs @@ -24,7 +24,7 @@ pub struct Conf { pub confidence: u8, } -pub trait ConfMergable { +pub trait ConfMergeable { type Result; /// Merge two confidence types' values depending on whichever has higher confidence /// In the event of a tie, the LHS (caller's) value is used. @@ -57,7 +57,7 @@ impl Conf { /// Returns best value or LHS on tie /// /// `Conf` + `Conf` → `Conf` -impl ConfMergable> for Conf { +impl ConfMergeable> for Conf { type Result = Conf; fn merge(self, other: Conf) -> Conf { if other.confidence > self.confidence { @@ -71,7 +71,7 @@ impl ConfMergable> for Conf { /// Returns LHS if RHS is None /// /// `Conf` + `Option>` → `Conf` -impl ConfMergable>> for Conf { +impl ConfMergeable>> for Conf { type Result = Conf; fn merge(self, other: Option>) -> Conf { match other { @@ -84,7 +84,7 @@ impl ConfMergable>> for Conf { /// Returns RHS if LHS is None /// /// `Option>` + `Conf` → `Conf` -impl ConfMergable> for Option> { +impl ConfMergeable> for Option> { type Result = Conf; fn merge(self, other: Conf) -> Conf { match self { @@ -97,7 +97,7 @@ impl ConfMergable> for Option> { /// Returns best non-None value or None /// /// `Option>` + `Option>` → `Option>` -impl ConfMergable>> for Option> { +impl ConfMergeable>> for Option> { type Result = Option>; fn merge(self, other: Option>) -> Option> { match (self, other) { diff --git a/rust/src/custombinaryview.rs b/rust/src/custombinaryview.rs index cfef7886b..b8a11df9f 100644 --- a/rust/src/custombinaryview.rs +++ b/rust/src/custombinaryview.rs @@ -430,7 +430,7 @@ impl<'a, T: CustomBinaryViewType> CustomViewBuilder<'a, T> { /// /// The `BinaryView` argument passed to the constructor function is the object that is expected /// to be returned by the `AsRef` implementation required by the `BinaryViewBase` trait. - /// TODO FIXME welp this is broke going to need 2 init callbacks + /// TODO FIXME whelp this is broke going to need 2 init callbacks pub fn create(self, parent: &BinaryView, view_args: V::Args) -> Result> where V: CustomBinaryView, @@ -545,7 +545,7 @@ impl<'a, T: CustomBinaryViewType> CustomViewBuilder<'a, T> { // prohibited, so an API contract was violated in order to get here. // // if we're here, it's too late to do anything about it, though we can at least not - // run the destructor on the custom view since that memory is unitialized. + // run the destructor on the custom view since that memory is uninitialized. log::error!( "BinaryViewBase::freeObject called on partially initialized object! crash imminent!" ); diff --git a/rust/src/function.rs b/rust/src/function.rs index c8b695bcd..7e480896a 100644 --- a/rust/src/function.rs +++ b/rust/src/function.rs @@ -2014,7 +2014,7 @@ impl Function { unsafe { Array::new(vars, count, ()) } } - /// Merge one or more varibles in `sources` into the `target` variable. All + /// Merge one or more variables in `sources` into the `target` variable. All /// variable accesses to the variables in `sources` will be rewritten to use `target`. /// /// * `target` - target variable @@ -2058,7 +2058,7 @@ impl Function { } } - /// Splits a varible at the definition site. The given `var` must be the + /// Splits a variable at the definition site. The given `var` must be the /// variable unique to the definition and should be obtained by using /// [crate::mlil::MediumLevelILInstruction::get_split_var_for_definition] at the definition site. /// @@ -2081,7 +2081,7 @@ impl Function { unsafe { BNSplitVariable(self.handle, &raw_var) } } - /// Undoes varible splitting performed with [Function::split_variable]. The given `var` + /// Undoes variable splitting performed with [Function::split_variable]. The given `var` /// must be the variable unique to the definition and should be obtained by using /// [crate::mlil::MediumLevelILInstruction::get_split_var_for_definition] at the definition site. /// diff --git a/rust/src/interaction.rs b/rust/src/interaction.rs index 6c8715fc9..15a47daec 100644 --- a/rust/src/interaction.rs +++ b/rust/src/interaction.rs @@ -218,7 +218,7 @@ impl FormInputBuilder { } /// Form Field: Vertical spacing - pub fn seperator_field(mut self) -> Self { + pub fn separator_field(mut self) -> Self { let mut result = unsafe { std::mem::zeroed::() }; result.type_ = BNFormInputFieldType::SeparatorFormField; result.hasDefault = false; diff --git a/rust/src/project.rs b/rust/src/project.rs index edea8b234..9ea8ba3cd 100644 --- a/rust/src/project.rs +++ b/rust/src/project.rs @@ -745,7 +745,7 @@ impl Project { /// } /// } /// ``` - // NOTE mut is used here, so only one lock can be aquired at once + // NOTE mut is used here, so only one lock can be acquired at once pub fn bulk_operation(&mut self) -> Result { Ok(ProjectBulkOperationLock::lock(self)) } diff --git a/rust/src/symbol.rs b/rust/src/symbol.rs index 337e034bd..21df31a7e 100644 --- a/rust/src/symbol.rs +++ b/rust/src/symbol.rs @@ -270,7 +270,7 @@ impl Symbol { unsafe { BNIsSymbolAutoDefined(self.handle) } } - /// Wether this symbol has external linkage + /// Whether this symbol has external linkage pub fn external(&self) -> bool { self.binding() == Binding::Weak || self.binding() == Binding::Global } diff --git a/rust/src/typeprinter.rs b/rust/src/typeprinter.rs index e9c36f967..a5c75bf06 100644 --- a/rust/src/typeprinter.rs +++ b/rust/src/typeprinter.rs @@ -426,7 +426,7 @@ pub trait TypePrinter { ) -> Option>; /// In a single-line text representation of a type, generate the tokens - /// that should be printed after the type's name. Returns a ist of text + /// that should be printed after the type's name. Returns a list of text /// tokens representing the type /// /// * `type_` - Type to print diff --git a/rust/src/types.rs b/rust/src/types.rs index ff5f67b97..73d79c3b2 100644 --- a/rust/src/types.rs +++ b/rust/src/types.rs @@ -1944,7 +1944,7 @@ impl Debug for NamedTypeReference { #[derive(Default, Debug, Clone, Hash, PartialEq, Eq, Ord, PartialOrd)] pub struct QualifiedName { // TODO: Make this Option where default is "::". - pub seperator: String, + pub separator: String, pub items: Vec, } @@ -1956,8 +1956,8 @@ impl QualifiedName { .iter() .filter_map(|&raw_name| raw_to_string(raw_name as *const _)) .collect(); - let seperator = raw_to_string(value.join).unwrap(); - Self { items, seperator } + let separator = raw_to_string(value.join).unwrap(); + Self { items, separator } } pub(crate) fn from_owned_raw(value: BNQualifiedName) -> Self { @@ -1967,7 +1967,7 @@ impl QualifiedName { } pub fn into_raw(value: Self) -> BNQualifiedName { - let bn_join = BnString::new(&value.seperator); + let bn_join = BnString::new(&value.separator); BNQualifiedName { // NOTE: Leaking string list must be freed by core or us! name: strings_to_string_list(&value.items), @@ -1983,17 +1983,17 @@ impl QualifiedName { } pub fn new(items: Vec) -> Self { - Self::new_with_seperator(items, "::".to_string()) + Self::new_with_separator(items, "::".to_string()) } - pub fn new_with_seperator(items: Vec, seperator: String) -> Self { - Self { items, seperator } + pub fn new_with_separator(items: Vec, separator: String) -> Self { + Self { items, separator } } pub fn with_item(&self, item: impl Into) -> Self { let mut items = self.items.clone(); items.push(item.into()); - Self::new_with_seperator(items, self.seperator.clone()) + Self::new_with_separator(items, self.separator.clone()) } pub fn push(&mut self, item: String) { @@ -2014,7 +2014,7 @@ impl QualifiedName { self.items.split_last().map(|(a, b)| { ( a.to_owned(), - QualifiedName::new_with_seperator(b.to_vec(), self.seperator.clone()), + QualifiedName::new_with_separator(b.to_vec(), self.separator.clone()), ) }) } @@ -2042,7 +2042,7 @@ impl QualifiedName { .iter() .map(|item| item.replace(from, to)) .collect(), - seperator: self.seperator.clone(), + separator: self.separator.clone(), } } @@ -2074,7 +2074,7 @@ impl From for QualifiedName { Self { items: vec![value], // TODO: See comment in struct def. - seperator: String::from("::"), + separator: String::from("::"), } } } @@ -2135,7 +2135,7 @@ impl IndexMut for QualifiedName { impl Display for QualifiedName { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.items.join(&self.seperator)) + write!(f, "{}", self.items.join(&self.separator)) } }