fix(rust): correct various typos

This commit is contained in:
Will Lillis 2026-03-28 03:19:48 -04:00
parent 1a82df3cac
commit cf8719f132
16 changed files with 31 additions and 32 deletions

View file

@ -867,7 +867,7 @@ fn update_package_json(path: &Path) -> Result<()> {
fn update_grammar_js(path: &Path) -> Result<()> {
let mut contents = fs::read_to_string(path)?;
if contents.contains("module.exports") {
info!("Migrating grammars.js to ESM");
info!("Migrating grammar.js to ESM");
contents = contents.replace("module.exports =", "export default");
write_file(path, contents)?;
}

View file

@ -240,7 +240,7 @@ struct Parse {
/// Output the parse data in a pretty-printed CST format
#[arg(long = "cst", short = 'c')]
pub output_cst: bool,
/// Show parsing statistic
/// Show parsing statistics
#[arg(long, short, conflicts_with = "json", conflicts_with = "json_summary")]
pub stat: bool,
/// Interrupt the parsing process by timeout (µs)
@ -901,7 +901,7 @@ impl Init {
let new_config = format!("{}\n", serde_json::to_string_pretty(&json)?);
// Write the re-serialized config back, as newly added optional boolean fields
// will be included with explicit `false`s rather than implict `null`s
// will be included with explicit `false`s rather than implicit `null`s
if self.update && !old_config.trim().eq(new_config.trim()) {
info!("Updating tree-sitter.json");
fs::write(
@ -1147,7 +1147,7 @@ impl Parse {
};
if self.lib_path.is_none() && self.lang_name.is_some() {
warn!("--lang-name` specified without --lib-path. This argument will be ignored.");
warn!("--lang-name specified without --lib-path. This argument will be ignored.");
}
let lib_info = get_lib_info(self.lib_path.as_ref(), self.lang_name.as_ref(), current_dir);
@ -1319,7 +1319,7 @@ impl Test {
}
if self.lib_path.is_none() && self.lang_name.is_some() {
warn!("--lang-name` specified without --lib-path. This argument will be ignored.");
warn!("--lang-name specified without --lib-path. This argument will be ignored.");
}
let languages = loader.languages_at_path(current_dir)?;
let language = if let Some(ref lib_path) = self.lib_path {
@ -1498,7 +1498,7 @@ impl Fuzz {
loader.force_rebuild(self.rebuild || self.grammar_path.is_some());
if self.lib_path.is_none() && self.lang_name.is_some() {
warn!("--lang-name` specified without --lib-path. This argument will be ignored.");
warn!("--lang-name specified without --lib-path. This argument will be ignored.");
}
let languages = loader.languages_at_path(current_dir)?;
let (language, language_name) = if let Some(ref lib_path) = self.lib_path {

View file

@ -1013,10 +1013,9 @@ fn run_tests(
(format_sexp(&output, 0), format_sexp(&actual, 0))
};
// Only bail early before updating if the actual is not the output,
// sometimes users want to test cases that
// are intended to have errors, hence why this
// check isn't shown above
// Only bail early before updating if `actual` does not match `output`.
// Sometimes users want to test cases that are intended to have
// errors, hence why this check isn't shown above.
if actual.contains("ERROR") || actual.contains("MISSING") {
test_summary.has_parse_errors = true;

View file

@ -454,7 +454,7 @@ fn test_node_child_by_field_name_with_extra_hidden_children() {
// In the Python grammar, some fields are applied to `suite` nodes,
// which consist of an invisible `indent` token followed by a block.
// Check that when searching for a child with a field name, we don't
//
// return a hidden child node.
let tree = parser.parse("while a:\n pass", None).unwrap();
let while_node = tree.root_node().child(0).unwrap();
assert_eq!(while_node.kind(), "while_statement");

View file

@ -1108,8 +1108,8 @@ fn test_query_matches_with_immediate_siblings() {
// siblings before that child node.
// 2. After the last child node in a pattern, it means that there cannot be any named
// sibling after that child node.
// 2. Between two child nodes in a pattern, it specifies that there cannot be any named
// siblings between those two child snodes.
// 3. Between two child nodes in a pattern, it specifies that there cannot be any named
// siblings between those two child nodes.
let query = Query::new(
&language,
"
@ -1941,7 +1941,7 @@ fn test_query_matches_with_too_many_permutations_to_track() {
let matches = cursor.matches(&query, tree.root_node(), source.as_bytes());
// For this pathological query, some match permutations will be dropped.
// Just check that a subset of the results are returned, and crash or
// Just check that a subset of the results are returned, and no crash or
// leak occurs.
assert_eq!(
collect_matches(matches, &query, source.as_str())[0],

View file

@ -787,7 +787,7 @@ impl<'a> ParseTableBuilder<'a> {
entry.actions.pop();
conflicting_items.retain(|item| item.is_done());
}
// If the SHIFT and REDUCE actions have the same predence, consider
// If the SHIFT and REDUCE actions have the same precedence, consider
// the REDUCE actions' associativity.
else if !shift_is_less && !shift_is_more {
considered_associativity = true;

View file

@ -152,8 +152,8 @@ impl<'a> ParseItemSetBuilder<'a> {
// * `lookaheads` - the set of possible lookahead tokens that can always come after `item`
// in an expansion of symbol `i`.
//
// * `reserved_lookaheads` - the set of reserved lookahead lookahead tokens that can
// always come after `item` in the expansion of symbol `i`.
// * `reserved_lookaheads` - the set of reserved lookahead tokens that can always come
// after `item` in the expansion of symbol `i`.
//
// * `propagates_lookaheads` - a boolean indicating whether or not `item` can occur at the
// *end* of the expansion of symbol `i`, so that i's own current lookahead tokens can

View file

@ -460,7 +460,7 @@ impl Minimizer<'_> {
// Get a mapping of old state index -> new_state_index
let mut old_ids_by_new_id = (0..self.parse_table.states.len()).collect::<Vec<_>>();
old_ids_by_new_id.sort_unstable_by_key(|i| {
// Don't changes states 0 (the error state) or 1 (the start state).
// Don't change states 0 (the error state) or 1 (the start state).
if *i <= 1 {
return *i as i64 - 1_000_000;
}

View file

@ -28,7 +28,7 @@ pub struct TokenConflictMap<'a> {
impl<'a> TokenConflictMap<'a> {
/// Create a token conflict map based on a lexical grammar, which describes the structure
/// of each token, and a `following_token` map, which indicates which tokens may be appear
/// of each token, and a `following_token` map, which indicates which tokens may appear
/// immediately after each other token.
///
/// This analyzes the possible kinds of overlap between each pair of tokens and stores

View file

@ -91,7 +91,7 @@ pub(super) fn extract_default_aliases(
.map(|(i, status)| (Symbol::external(i), status)),
);
// For each symbol that always appears aliased, find the alias the occurs most often,
// For each symbol that always appears aliased, find the alias that occurs most often,
// and designate that alias as the symbol's "default alias". Store all of these
// default aliases in a map that will be returned.
let mut result = AliasMap::new();

View file

@ -482,7 +482,7 @@ mod test {
])
]))
),
// The pattern "e" was only used in once place: as the definition of `rule_1`,
// The pattern "e" was only used in one place: as the definition of `rule_1`,
// so that rule was moved to the lexical grammar. The pattern "b" appeared in
// two places, so it was not moved into the lexical grammar.
Variable::named("rule_2", Rule::terminal(1)),

View file

@ -937,7 +937,7 @@ impl Generator {
// For large character sets, find the best matching character set from
// a pre-selected list of large character sets, which are based on the
// state transitions for invidual tokens. This transition may not exactly
// state transitions for individual tokens. This transition may not exactly
// match one of the pre-selected character sets. In that case, determine
// the additional checks that need to be performed to match this transition.
let mut best_large_char_set: Option<(usize, CharacterSet, CharacterSet)> = None;
@ -1018,7 +1018,7 @@ impl Generator {
add!(self, " ||{line_break}");
}
// If the character set contains the max character, than it probably
// If the character set contains the max character, then it probably
// corresponds to a negated character class in a regex, so it will be more
// concise and readable to express it in terms of negated ranges.
let is_included = !asserted_chars.contains(char::MAX);

View file

@ -468,7 +468,7 @@ impl HighlightConfiguration {
/// and `function.builtin.constructor`, but will not match `function.method`.
///
/// When highlighting, results are returned as `Highlight` values, which contain the index
/// of the matched highlight this list of highlight names.
/// of the matched highlight in this list of highlight names.
pub fn configure(&mut self, recognized_names: &[impl AsRef<str>]) {
let mut capture_parts = Vec::new();
self.highlight_indices.clear();

View file

@ -1746,7 +1746,7 @@ impl Loader {
let language_path =
parser_path.join(grammar.path.unwrap_or_else(|| PathBuf::from(".")));
// Determine if a previous language configuration in this package.json file
// Determine if a previous language configuration in this tree-sitter.json file
// already uses the same language.
let mut language_id = None;
for (id, (path, _, _)) in

View file

@ -353,7 +353,7 @@ fn build_wasm(cmd: &mut Command, edit_tsd: bool) -> Result<()> {
///
/// If `TREE_SITTER_WASI_SDK_PATH` is set, it will use that path to look for the clang executable.
///
/// Note that this is just a minimially modified version of
/// Note that this is just a minimally modified version of
/// `tree_sitter_loader::ensure_wasi_sdk_exists`. In the loader, this functionality is implemented
/// as a private method of `Loader`. Rather than add this to the public API, we just
/// re-implement it. Any fixes and/or modifications made to the loader's copy should be reflected
@ -402,7 +402,7 @@ pub fn ensure_wasi_sdk_exists() -> Result<PathBuf> {
///
/// If `TREE_SITTER_BINARYEN_PATH` is set, it will use that path to look for the wasm-opt executable.
///
/// Note that this is just a minimially modified version of
/// Note that this is just a minimally modified version of
/// `tree_sitter_loader::ensure_binaryen_exists`. In the loader, this functionality is implemented
/// as a private method of `Loader`. Rather than add this to the public API, we just
/// re-implement it. Any fixes and/or modifications made to the loader's copy should be reflected

View file

@ -367,7 +367,7 @@ unsafe extern "C" {
pub fn ts_node_is_missing(self_: TSNode) -> bool;
}
unsafe extern "C" {
#[doc = " Check if the node is *extra*. Extra nodes represent things like comments,\n which are not required the grammar, but can appear anywhere."]
#[doc = " Check if the node is *extra*. Extra nodes represent things like comments,\n which are not required by the grammar, but can appear anywhere."]
pub fn ts_node_is_extra(self_: TSNode) -> bool;
}
unsafe extern "C" {
@ -640,7 +640,7 @@ unsafe extern "C" {
) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
#[doc = " Get the quantifier of the query's captures. Each capture is * associated\n with a numeric id based on the order that it appeared in the query's source."]
#[doc = " Get the quantifier of the query's captures. Each capture is associated\n with a numeric id based on the order that it appeared in the query's source."]
pub fn ts_query_capture_quantifier_for_id(
self_: *const TSQuery,
pattern_index: u32,
@ -667,7 +667,7 @@ unsafe extern "C" {
pub fn ts_query_disable_pattern(self_: *mut TSQuery, pattern_index: u32);
}
unsafe extern "C" {
#[doc = " Create a new cursor for executing a given query.\n\n The cursor stores the state that is needed to iteratively search\n for matches. To use the query cursor, first call [`ts_query_cursor_exec`]\n to start running a given query on a given syntax node. Then, there are\n two options for consuming the results of the query:\n 1. Repeatedly call [`ts_query_cursor_next_match`] to iterate over all of the\n *matches* in the order that they were found. Each match contains the\n index of the pattern that matched, and an array of captures. Because\n multiple patterns can match the same set of nodes, one match may contain\n captures that appear *before* some of the captures from a previous match.\n 2. Repeatedly call [`ts_query_cursor_next_capture`] to iterate over all of the\n individual *captures* in the order that they appear. This is useful if\n don't care about which pattern matched, and just want a single ordered\n sequence of captures.\n\n If you don't care about consuming all of the results, you can stop calling\n [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] at any point.\n You can then start executing another query on another node by calling\n [`ts_query_cursor_exec`] again."]
#[doc = " Create a new cursor for executing a given query.\n\n The cursor stores the state that is needed to iteratively search\n for matches. To use the query cursor, first call [`ts_query_cursor_exec`]\n to start running a given query on a given syntax node. Then, there are\n two options for consuming the results of the query:\n 1. Repeatedly call [`ts_query_cursor_next_match`] to iterate over all of the\n *matches* in the order that they were found. Each match contains the\n index of the pattern that matched, and an array of captures. Because\n multiple patterns can match the same set of nodes, one match may contain\n captures that appear *before* some of the captures from a previous match.\n 2. Repeatedly call [`ts_query_cursor_next_capture`] to iterate over all of the\n individual *captures* in the order that they appear. This is useful if\n you don't care about which pattern matched, and just want a single ordered\n sequence of captures.\n\n If you don't care about consuming all of the results, you can stop calling\n [`ts_query_cursor_next_match`] or [`ts_query_cursor_next_capture`] at any point.\n You can then start executing another query on another node by calling\n [`ts_query_cursor_exec`] again."]
pub fn ts_query_cursor_new() -> *mut TSQueryCursor;
}
unsafe extern "C" {
@ -746,7 +746,7 @@ unsafe extern "C" {
) -> bool;
}
unsafe extern "C" {
#[doc = " Set the maximum start depth for a query cursor.\n\n This prevents cursors from exploring children nodes at a certain depth.\n Note if a pattern includes many children, then they will still be checked.\n\n The zero max start depth value can be used as a special behavior and\n it helps to destructure a subtree by staying on a node and using captures\n for interested parts. Note that the zero max start depth only limit a search\n depth for a pattern's root node but other nodes that are parts of the pattern\n may be searched at any depth what defined by the pattern structure.\n\n Set to `UINT32_MAX` to remove the maximum start depth."]
#[doc = " Set the maximum start depth for a query cursor.\n\n This prevents cursors from exploring children nodes at a certain depth.\n Note if a pattern includes many children, then they will still be checked.\n\n The zero max start depth value can be used as a special behavior and\n it helps to destructure a subtree by staying on a node and using captures\n for interested parts. Note that the zero max start depth only limits a search\n depth for a pattern's root node but other nodes that are parts of the pattern\n may be searched at any depth as defined by the pattern structure.\n\n Set to `UINT32_MAX` to remove the maximum start depth."]
pub fn ts_query_cursor_set_max_start_depth(self_: *mut TSQueryCursor, max_start_depth: u32);
}
unsafe extern "C" {
@ -813,7 +813,7 @@ unsafe extern "C" {
) -> *const ::core::ffi::c_char;
}
unsafe extern "C" {
#[doc = " Check whether the given node type id belongs to named nodes, anonymous nodes,\n or a hidden nodes.\n\n See also [`ts_node_is_named`]. Hidden nodes are never returned from the API."]
#[doc = " Check whether the given node type id belongs to named nodes, anonymous nodes,\n or hidden nodes.\n\n See also [`ts_node_is_named`]. Hidden nodes are never returned from the API."]
pub fn ts_language_symbol_type(self_: *const TSLanguage, symbol: TSSymbol) -> TSSymbolType;
}
unsafe extern "C" {