style: prefer turbofish syntax where possible
This commit is contained in:
parent
fd91404ab0
commit
b40839cd72
12 changed files with 28 additions and 29 deletions
|
|
@ -503,8 +503,8 @@ impl Loader {
|
|||
let library = unsafe { Library::new(&library_path) }
|
||||
.with_context(|| format!("Error opening dynamic library {library_path:?}"))?;
|
||||
let language = unsafe {
|
||||
let language_fn: Symbol<unsafe extern "C" fn() -> Language> = library
|
||||
.get(language_fn_name.as_bytes())
|
||||
let language_fn = library
|
||||
.get::<Symbol<unsafe extern "C" fn() -> Language>>(language_fn_name.as_bytes())
|
||||
.with_context(|| format!("Failed to load symbol {language_fn_name}"))?;
|
||||
language_fn()
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub fn build_lex_table(
|
|||
LexTable::default()
|
||||
};
|
||||
|
||||
let mut parse_state_ids_by_token_set: Vec<(TokenSet, Vec<ParseStateId>)> = Vec::new();
|
||||
let mut parse_state_ids_by_token_set = Vec::<(TokenSet, Vec<ParseStateId>)>::new();
|
||||
for (i, state) in parse_table.states.iter().enumerate() {
|
||||
let tokens = state
|
||||
.terminal_entries
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ impl<'a> ParseTableBuilder<'a> {
|
|||
// REDUCE-REDUCE conflicts where all actions have the *same*
|
||||
// precedence, and there can still be SHIFT/REDUCE conflicts.
|
||||
let mut considered_associativity = false;
|
||||
let mut shift_precedence: Vec<(&Precedence, Symbol)> = Vec::new();
|
||||
let mut shift_precedence = Vec::<(&Precedence, Symbol)>::new();
|
||||
let mut conflicting_items = HashSet::new();
|
||||
for (item, lookaheads) in &item_set.entries {
|
||||
if let Some(step) = item.step() {
|
||||
|
|
|
|||
|
|
@ -464,7 +464,7 @@ impl<'a> NfaCursor<'a> {
|
|||
fn group_transitions<'b>(
|
||||
iter: impl Iterator<Item = (&'b CharacterSet, bool, i32, u32)>,
|
||||
) -> Vec<NfaTransition> {
|
||||
let mut result: Vec<NfaTransition> = Vec::new();
|
||||
let mut result = Vec::<NfaTransition>::new();
|
||||
for (chars, is_sep, prec, state) in iter {
|
||||
let mut chars = chars.clone();
|
||||
let mut i = 0;
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ pub(super) fn extract_tokens(
|
|||
.expected_conflicts
|
||||
.into_iter()
|
||||
.map(|conflict| {
|
||||
let mut result: Vec<_> = conflict
|
||||
let mut result = conflict
|
||||
.iter()
|
||||
.map(|symbol| symbol_replacer.replace_symbol(*symbol))
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
result.sort_unstable();
|
||||
result.dedup();
|
||||
result
|
||||
|
|
|
|||
|
|
@ -362,10 +362,10 @@ mod tests {
|
|||
|
||||
let inline_map = process_inlines(&grammar, &LexicalGrammar::default()).unwrap();
|
||||
|
||||
let productions: Vec<&Production> = inline_map
|
||||
let productions = inline_map
|
||||
.inlined_productions(&grammar.variables[0].productions[0], 1)
|
||||
.unwrap()
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
productions.iter().copied().cloned().collect::<Vec<_>>(),
|
||||
|
|
@ -461,10 +461,10 @@ mod tests {
|
|||
|
||||
let inline_map = process_inlines(&grammar, &LexicalGrammar::default()).unwrap();
|
||||
|
||||
let productions: Vec<_> = inline_map
|
||||
let productions = inline_map
|
||||
.inlined_productions(&grammar.variables[0].productions[0], 0)
|
||||
.unwrap()
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert_eq!(
|
||||
productions.iter().copied().cloned().collect::<Vec<_>>(),
|
||||
|
|
|
|||
|
|
@ -675,7 +675,7 @@ impl Generator {
|
|||
|
||||
// For each lex state, compute a summary of the code that needs to be
|
||||
// generated.
|
||||
let state_transition_summaries: Vec<Vec<TransitionSummary>> = lex_table
|
||||
let state_transition_summaries = lex_table
|
||||
.states
|
||||
.iter()
|
||||
.map(|state| {
|
||||
|
|
@ -732,7 +732,7 @@ impl Generator {
|
|||
})
|
||||
.collect()
|
||||
})
|
||||
.collect();
|
||||
.collect::<Vec<Vec<_>>>();
|
||||
|
||||
// Generate a helper function for each large character set.
|
||||
let mut sorted_large_char_sets = large_character_sets.iter().collect::<Vec<_>>();
|
||||
|
|
@ -1153,7 +1153,7 @@ impl Generator {
|
|||
|
||||
let mut index = 0;
|
||||
let mut small_state_indices = Vec::new();
|
||||
let mut symbols_by_value: HashMap<(usize, SymbolType), Vec<Symbol>> = HashMap::new();
|
||||
let mut symbols_by_value = HashMap::<(usize, SymbolType), Vec<Symbol>>::new();
|
||||
for state in self.parse_table.states.iter().skip(self.large_state_count) {
|
||||
small_state_indices.push(index);
|
||||
symbols_by_value.clear();
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ pub fn parse_file_at_path(parser: &mut Parser, opts: &ParseFileOptions) -> Resul
|
|||
let mut indent_level = 0;
|
||||
let mut did_visit_children = false;
|
||||
let mut had_named_children = false;
|
||||
let mut tags: Vec<&str> = Vec::new();
|
||||
let mut tags = Vec::<&str>::new();
|
||||
writeln!(&mut stdout, "<?xml version=\"1.0\"?>")?;
|
||||
loop {
|
||||
let node = cursor.node();
|
||||
|
|
|
|||
|
|
@ -158,10 +158,10 @@ fn test_parsing_with_custom_utf16_input() {
|
|||
let mut parser = Parser::new();
|
||||
parser.set_language(&get_language("rust")).unwrap();
|
||||
|
||||
let lines: Vec<Vec<u16>> = ["pub fn foo() {", " 1", "}"]
|
||||
let lines = ["pub fn foo() {", " 1", "}"]
|
||||
.iter()
|
||||
.map(|s| s.encode_utf16().collect())
|
||||
.collect();
|
||||
.map(|s| s.encode_utf16().collect::<Vec<_>>())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let tree = parser
|
||||
.parse_utf16_with(
|
||||
|
|
@ -1014,11 +1014,11 @@ fn test_parsing_error_in_invalid_included_ranges() {
|
|||
#[test]
|
||||
fn test_parsing_utf16_code_with_errors_at_the_end_of_an_included_range() {
|
||||
let source_code = "<script>a.</script>";
|
||||
let utf16_source_code: Vec<u16> = source_code
|
||||
let utf16_source_code = source_code
|
||||
.as_bytes()
|
||||
.iter()
|
||||
.map(|c| u16::from(*c))
|
||||
.collect();
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let start_byte = 2 * source_code.find("a.").unwrap();
|
||||
let end_byte = 2 * source_code.find("</script>").unwrap();
|
||||
|
|
|
|||
|
|
@ -397,14 +397,14 @@ fn test_tags_via_c_api() {
|
|||
})
|
||||
.unwrap();
|
||||
|
||||
let syntax_types: Vec<&str> = unsafe {
|
||||
let syntax_types = unsafe {
|
||||
let mut len: u32 = 0;
|
||||
let ptr =
|
||||
c::ts_tagger_syntax_kinds_for_scope_name(tagger, c_scope_name.as_ptr(), &mut len);
|
||||
slice::from_raw_parts(ptr, len as usize)
|
||||
.iter()
|
||||
.map(|i| CStr::from_ptr(*i).to_str().unwrap())
|
||||
.collect()
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn test_text_provider_for_string() {
|
|||
|
||||
#[test]
|
||||
fn test_text_provider_for_box_of_str_slice() {
|
||||
let text: Box<str> = "// comment".to_owned().into_boxed_str();
|
||||
let text = "// comment".to_owned().into_boxed_str();
|
||||
|
||||
check_parsing(text.as_bytes(), text.as_bytes());
|
||||
check_parsing(<_ as AsRef<str>>::as_ref(&text), text.as_bytes());
|
||||
|
|
@ -82,7 +82,7 @@ fn test_text_provider_for_box_of_str_slice() {
|
|||
|
||||
#[test]
|
||||
fn test_text_provider_for_box_of_bytes_slice() {
|
||||
let text: Box<[u8]> = "// comment".to_owned().into_boxed_str().into_boxed_bytes();
|
||||
let text = "// comment".to_owned().into_boxed_str().into_boxed_bytes();
|
||||
|
||||
check_parsing(text.as_ref(), text.as_ref());
|
||||
check_parsing(text.as_ref(), &*text);
|
||||
|
|
@ -91,15 +91,14 @@ fn test_text_provider_for_box_of_bytes_slice() {
|
|||
|
||||
#[test]
|
||||
fn test_text_provider_for_vec_of_bytes() {
|
||||
let text: Vec<u8> = "// comment".to_owned().into_bytes();
|
||||
let text = "// comment".to_owned().into_bytes();
|
||||
|
||||
check_parsing(&*text, &*text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_text_provider_for_arc_of_bytes_slice() {
|
||||
let text: Vec<u8> = "// comment".to_owned().into_bytes();
|
||||
let text: Arc<[u8]> = Arc::from(text);
|
||||
let text: Arc<[u8]> = Arc::from("// comment".to_owned().into_bytes());
|
||||
|
||||
check_parsing(&*text, &*text);
|
||||
check_parsing(text.as_ref(), text.as_ref());
|
||||
|
|
@ -149,7 +148,7 @@ fn test_text_provider_callback_with_owned_bytes_vec_slice() {
|
|||
.unwrap_or_default()
|
||||
},
|
||||
|_node: Node<'_>| {
|
||||
let slice: Vec<u8> = text.to_owned().into_bytes();
|
||||
let slice = text.to_owned().into_bytes();
|
||||
iter::once(slice)
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ pub fn compile_language_to_wasm(
|
|||
|
||||
// Exit with an error if the external scanner uses symbols from the
|
||||
// C or C++ standard libraries that aren't available to wasm parsers.
|
||||
let stdlib_symbols: Vec<_> = wasm_stdlib_symbols().collect();
|
||||
let stdlib_symbols = wasm_stdlib_symbols().collect::<Vec<_>>();
|
||||
let dylink_symbols = [
|
||||
"__indirect_function_table",
|
||||
"__memory_base",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue