Run cargo fix --edition-idioms

This commit is contained in:
Amos Wenger
2022-07-20 15:02:08 +02:00
parent 23d25a3094
commit 816f7fe12a
230 changed files with 888 additions and 888 deletions

View File

@@ -75,7 +75,7 @@ pub(crate) fn rewrite_links(db: &RootDatabase, markdown: &str, definition: Defin
pub(crate) fn remove_links(markdown: &str) -> String {
let mut drop_link = false;
let mut cb = |_: BrokenLink| {
let mut cb = |_: BrokenLink<'_>| {
let empty = InlineStr::try_from("").unwrap();
Some((CowStr::Inlined(empty), CowStr::Inlined(empty)))
};
@@ -196,7 +196,7 @@ pub(crate) fn resolve_doc_path_for_def(
}
pub(crate) fn doc_attributes(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
) -> Option<(hir::AttrsWithOwner, Definition)> {
match_ast! {
@@ -241,7 +241,7 @@ pub(crate) fn token_as_doc_comment(doc_token: &SyntaxToken) -> Option<DocComment
impl DocCommentToken {
pub(crate) fn get_definition_with_descend_at<T>(
self,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
offset: TextSize,
// Definition, CommentOwner, range of intra doc link in original file
mut cb: impl FnMut(Definition, SyntaxNode, TextRange) -> Option<T>,
@@ -360,7 +360,7 @@ fn map_links<'e>(
) -> impl Iterator<Item = Event<'e>> {
let mut in_link = false;
// holds the origin link target on start event and the rewritten one on end event
let mut end_link_target: Option<CowStr> = None;
let mut end_link_target: Option<CowStr<'_>> = None;
// normally link's type is determined by the type of link tag in the end event,
// however in some cases we want to change the link type, for example,
// `Shortcut` type parsed from Start/End tags doesn't make sense for url links

View File

@@ -52,7 +52,7 @@ fn check_doc_links(ra_fixture: &str) {
}
fn def_under_cursor(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
position: &FilePosition,
) -> (Definition, hir::Documentation) {
let (docs, def) = sema
@@ -70,7 +70,7 @@ fn def_under_cursor(
}
fn node_to_def(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
) -> Option<Option<(Option<hir::Documentation>, Definition)>> {
Some(match_ast! {

View File

@@ -100,23 +100,23 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
}
fn expand_macro_recur(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
macro_call: &ast::MacroCall,
) -> Option<SyntaxNode> {
let expanded = sema.expand(macro_call)?.clone_for_update();
expand(sema, expanded, ast::MacroCall::cast, expand_macro_recur)
}
fn expand_attr_macro_recur(sema: &Semantics<RootDatabase>, item: &ast::Item) -> Option<SyntaxNode> {
fn expand_attr_macro_recur(sema: &Semantics<'_, RootDatabase>, item: &ast::Item) -> Option<SyntaxNode> {
let expanded = sema.expand_attr_macro(item)?.clone_for_update();
expand(sema, expanded, ast::Item::cast, expand_attr_macro_recur)
}
fn expand<T: AstNode>(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
expanded: SyntaxNode,
f: impl FnMut(SyntaxNode) -> Option<T>,
exp: impl Fn(&Semantics<RootDatabase>, &T) -> Option<SyntaxNode>,
exp: impl Fn(&Semantics<'_, RootDatabase>, &T) -> Option<SyntaxNode>,
) -> Option<SyntaxNode> {
let children = expanded.descendants().filter_map(f);
let mut replacements = Vec::new();

View File

@@ -33,7 +33,7 @@ pub(crate) fn extend_selection(db: &RootDatabase, frange: FileRange) -> TextRang
}
fn try_extend_selection(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
root: &SyntaxNode,
frange: FileRange,
) -> Option<TextRange> {
@@ -120,7 +120,7 @@ fn try_extend_selection(
}
fn extend_tokens_from_range(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
macro_call: ast::MacroCall,
original_range: TextRange,
) -> Option<TextRange> {

View File

@@ -79,7 +79,7 @@ pub(crate) fn goto_definition(
}
fn try_lookup_include_path(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
tt: ast::TokenTree,
token: SyntaxToken,
file_id: FileId,
@@ -112,7 +112,7 @@ fn try_lookup_include_path(
/// impl A for S { type a = i32; } // <-- on this associate type, will get the location of a in the trait
/// ```
fn try_filter_trait_item_definition(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
def: &Definition,
) -> Option<Vec<NavigationTarget>> {
let db = sema.db;

View File

@@ -86,11 +86,11 @@ pub(crate) fn goto_implementation(
Some(RangeInfo { range, info: navs })
}
fn impls_for_ty(sema: &Semantics<RootDatabase>, ty: hir::Type) -> Vec<NavigationTarget> {
fn impls_for_ty(sema: &Semantics<'_, RootDatabase>, ty: hir::Type) -> Vec<NavigationTarget> {
Impl::all_for_type(sema.db, ty).into_iter().filter_map(|imp| imp.try_to_nav(sema.db)).collect()
}
fn impls_for_trait(sema: &Semantics<RootDatabase>, trait_: hir::Trait) -> Vec<NavigationTarget> {
fn impls_for_trait(sema: &Semantics<'_, RootDatabase>, trait_: hir::Trait) -> Vec<NavigationTarget> {
Impl::all_for_trait(sema.db, trait_)
.into_iter()
.filter_map(|imp| imp.try_to_nav(sema.db))
@@ -98,7 +98,7 @@ fn impls_for_trait(sema: &Semantics<RootDatabase>, trait_: hir::Trait) -> Vec<Na
}
fn impls_for_trait_item(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
trait_: hir::Trait,
fun_name: hir::Name,
) -> Vec<NavigationTarget> {

View File

@@ -44,7 +44,7 @@ pub struct HighlightRelatedConfig {
//
// Note: `?` and `->` do not currently trigger this behavior in the VSCode editor.
pub(crate) fn highlight_related(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: HighlightRelatedConfig,
FilePosition { offset, file_id }: FilePosition,
) -> Option<Vec<HighlightedRange>> {
@@ -76,7 +76,7 @@ pub(crate) fn highlight_related(
}
fn highlight_references(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
node: &SyntaxNode,
token: SyntaxToken,
file_id: FileId,
@@ -136,11 +136,11 @@ fn highlight_references(
}
fn highlight_exit_points(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<Vec<HighlightedRange>> {
fn hl(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
body: Option<ast::Expr>,
) -> Option<Vec<HighlightedRange>> {
let mut highlights = Vec::new();
@@ -330,7 +330,7 @@ fn cover_range(r0: Option<TextRange>, r1: Option<TextRange>) -> Option<TextRange
}
}
fn find_defs(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> FxHashSet<Definition> {
fn find_defs(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> FxHashSet<Definition> {
sema.descend_into_macros(token)
.into_iter()
.filter_map(|token| IdentClass::classify_token(sema, &token).map(IdentClass::definitions))

View File

@@ -163,7 +163,7 @@ pub(crate) fn hover(
}
pub(crate) fn hover_for_definition(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
definition: Definition,
node: &SyntaxNode,
@@ -189,7 +189,7 @@ pub(crate) fn hover_for_definition(
fn hover_ranged(
file: &SyntaxNode,
range: syntax::TextRange,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
) -> Option<RangeInfo<HoverResult>> {
// FIXME: make this work in attributes
@@ -222,7 +222,7 @@ fn hover_ranged(
}
fn hover_type_fallback(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
token: &SyntaxToken,
original_token: &SyntaxToken,
@@ -281,7 +281,7 @@ fn show_fn_references_action(db: &RootDatabase, def: Definition) -> Option<Hover
}
fn runnable_action(
sema: &hir::Semantics<RootDatabase>,
sema: &hir::Semantics<'_, RootDatabase>,
def: Definition,
file_id: FileId,
) -> Option<HoverAction> {

View File

@@ -26,7 +26,7 @@ use crate::{
};
pub(super) fn type_info(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
expr_or_pat: &Either<ast::Expr, ast::Pat>,
) -> Option<HoverResult> {
@@ -71,7 +71,7 @@ pub(super) fn type_info(
}
pub(super) fn try_expr(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
try_expr: &ast::TryExpr,
) -> Option<HoverResult> {
@@ -162,7 +162,7 @@ pub(super) fn try_expr(
}
pub(super) fn deref_expr(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
deref_expr: &ast::PrefixExpr,
) -> Option<HoverResult> {
@@ -226,7 +226,7 @@ pub(super) fn deref_expr(
}
pub(super) fn keyword(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &HoverConfig,
token: &SyntaxToken,
) -> Option<HoverResult> {
@@ -335,7 +335,7 @@ pub(super) fn path(db: &RootDatabase, module: hir::Module, item_name: Option<Str
pub(super) fn definition(
db: &RootDatabase,
def: Definition,
famous_defs: Option<&FamousDefs>,
famous_defs: Option<&FamousDefs<'_, '_>>,
config: &HoverConfig,
) -> Option<Markup> {
let mod_path = definition_mod_path(db, &def);
@@ -460,7 +460,7 @@ fn markup(docs: Option<String>, desc: String, mod_path: Option<String>) -> Optio
Some(buf.into())
}
fn builtin(famous_defs: &FamousDefs, builtin: hir::BuiltinType) -> Option<Markup> {
fn builtin(famous_defs: &FamousDefs<'_, '_>, builtin: hir::BuiltinType) -> Option<Markup> {
// std exposes prim_{} modules with docstrings on the root to document the builtins
let primitive_mod = format!("prim_{}", builtin.name());
let doc_owner = find_std_module(famous_defs, &primitive_mod)?;
@@ -468,7 +468,7 @@ fn builtin(famous_defs: &FamousDefs, builtin: hir::BuiltinType) -> Option<Markup
markup(Some(docs.into()), builtin.name().to_string(), None)
}
fn find_std_module(famous_defs: &FamousDefs, name: &str) -> Option<hir::Module> {
fn find_std_module(famous_defs: &FamousDefs<'_, '_>, name: &str) -> Option<hir::Module> {
let db = famous_defs.0.db;
let std_crate = famous_defs.std()?;
let std_root_module = std_crate.root_module(db);
@@ -513,7 +513,7 @@ impl KeywordHint {
}
fn keyword_hints(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: &SyntaxToken,
parent: syntax::SyntaxNode,
) -> KeywordHint {

View File

@@ -138,7 +138,7 @@ pub(crate) fn inlay_hints(
fn hints(
hints: &mut Vec<InlayHint>,
famous_defs @ FamousDefs(sema, _): &FamousDefs,
famous_defs @ FamousDefs(sema, _): &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
node: SyntaxNode,
@@ -185,7 +185,7 @@ fn hints(
fn closing_brace_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
file_id: FileId,
node: SyntaxNode,
@@ -502,8 +502,8 @@ fn fn_lifetime_fn_hints(
fn closure_ret_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
famous_defs: &FamousDefs,
sema: &Semantics<'_, RootDatabase>,
famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
closure: ast::ClosureExpr,
@@ -543,7 +543,7 @@ fn closure_ret_hints(
fn reborrow_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
expr: &ast::Expr,
) -> Option<()> {
@@ -570,8 +570,8 @@ fn reborrow_hints(
fn chaining_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
famous_defs: &FamousDefs,
sema: &Semantics<'_, RootDatabase>,
famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
file_id: FileId,
expr: &ast::Expr,
@@ -632,7 +632,7 @@ fn chaining_hints(
fn param_name_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
expr: ast::Expr,
) -> Option<()> {
@@ -685,7 +685,7 @@ fn param_name_hints(
fn binding_mode_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
pat: &ast::Pat,
) -> Option<()> {
@@ -732,7 +732,7 @@ fn binding_mode_hints(
fn bind_pat_hints(
acc: &mut Vec<InlayHint>,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
file_id: FileId,
pat: &ast::IdentPat,
@@ -783,7 +783,7 @@ fn bind_pat_hints(
}
fn is_named_constructor(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
pat: &ast::IdentPat,
ty_name: &str,
) -> Option<()> {
@@ -837,8 +837,8 @@ fn is_named_constructor(
/// Checks if the type is an Iterator from std::iter and replaces its hint with an `impl Iterator<Item = Ty>`.
fn hint_iterator(
sema: &Semantics<RootDatabase>,
famous_defs: &FamousDefs,
sema: &Semantics<'_, RootDatabase>,
famous_defs: &FamousDefs<'_, '_>,
config: &InlayHintsConfig,
ty: &hir::Type,
) -> Option<String> {
@@ -899,7 +899,7 @@ fn pat_is_enum_variant(db: &RootDatabase, bind_pat: &ast::IdentPat, pat_ty: &hir
}
fn should_not_display_type_hint(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
config: &InlayHintsConfig,
bind_pat: &ast::IdentPat,
pat_ty: &hir::Type,
@@ -959,7 +959,7 @@ fn closure_has_block_body(closure: &ast::ClosureExpr) -> bool {
}
fn should_hide_param_name_hint(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
callable: &hir::Callable,
param_name: &str,
argument: &ast::Expr,
@@ -1048,7 +1048,7 @@ fn is_param_name_suffix_of_fn_name(
}
fn is_adt_constructor_similar_to_param_name(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
argument: &ast::Expr,
param_name: &str,
) -> bool {
@@ -1116,7 +1116,7 @@ fn is_obvious_param(param_name: &str) -> bool {
}
fn get_callable(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
expr: &ast::Expr,
) -> Option<(hir::Callable, ast::ArgList)> {
match expr {

View File

@@ -50,7 +50,7 @@ pub struct Declaration {
//
// image::https://user-images.githubusercontent.com/48062697/113020670-b7c34f00-917a-11eb-8003-370ac5f2b3cb.gif[]
pub(crate) fn find_all_refs(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
position: FilePosition,
search_scope: Option<SearchScope>,
) -> Option<Vec<ReferenceSearchResult>> {
@@ -112,7 +112,7 @@ pub(crate) fn find_all_refs(
}
pub(crate) fn find_defs<'a>(
sema: &'a Semantics<RootDatabase>,
sema: &'a Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
offset: TextSize,
) -> Option<impl Iterator<Item = Definition> + 'a> {
@@ -178,7 +178,7 @@ pub(crate) fn decl_mutability(def: &Definition, syntax: &SyntaxNode, range: Text
fn retain_adt_literal_usages(
usages: &mut UsageSearchResult,
def: Definition,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
) {
let refs = usages.references.values_mut();
match def {
@@ -242,7 +242,7 @@ fn name_for_constructor_search(syntax: &SyntaxNode, position: FilePosition) -> O
}
fn is_enum_lit_name_ref(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
enum_: hir::Enum,
name_ref: &ast::NameRef,
) -> bool {

View File

@@ -120,7 +120,7 @@ pub(crate) fn will_rename_file(
}
fn find_definitions(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
position: FilePosition,
) -> RenameResult<impl Iterator<Item = (ast::NameLike, Definition)>> {
@@ -201,7 +201,7 @@ fn find_definitions(
}
}
fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> {
fn rename_to_self(sema: &Semantics<'_, RootDatabase>, local: hir::Local) -> RenameResult<SourceChange> {
if never!(local.is_self(sema.db)) {
bail!("rename_to_self invoked on self");
}
@@ -269,7 +269,7 @@ fn rename_to_self(sema: &Semantics<RootDatabase>, local: hir::Local) -> RenameRe
}
fn rename_self_to_param(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
local: hir::Local,
self_param: hir::SelfParam,
new_name: &str,

View File

@@ -35,7 +35,7 @@ pub enum TestId {
}
impl fmt::Display for TestId {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
TestId::Name(name) => name.fmt(f),
TestId::Path(path) => path.fmt(f),
@@ -219,7 +219,7 @@ pub(crate) fn related_tests(
}
fn find_related_tests(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
position: FilePosition,
search_scope: Option<SearchScope>,
@@ -259,7 +259,7 @@ fn find_related_tests(
}
fn find_related_tests_in_module(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
syntax: &SyntaxNode,
fn_def: &ast::Fn,
parent_module: &hir::Module,
@@ -282,7 +282,7 @@ fn find_related_tests_in_module(
find_related_tests(sema, syntax, fn_pos, Some(mod_scope), tests)
}
fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> {
fn as_test_runnable(sema: &Semantics<'_, RootDatabase>, fn_def: &ast::Fn) -> Option<Runnable> {
if test_related_attribute(fn_def).is_some() {
let function = sema.to_def(fn_def)?;
runnable_fn(sema, function)
@@ -291,7 +291,7 @@ fn as_test_runnable(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<
}
}
fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Option<hir::Module> {
fn parent_test_module(sema: &Semantics<'_, RootDatabase>, fn_def: &ast::Fn) -> Option<hir::Module> {
fn_def.syntax().ancestors().find_map(|node| {
let module = ast::Module::cast(node)?;
let module = sema.to_def(&module)?;
@@ -304,7 +304,7 @@ fn parent_test_module(sema: &Semantics<RootDatabase>, fn_def: &ast::Fn) -> Optio
})
}
pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) -> Option<Runnable> {
pub(crate) fn runnable_fn(sema: &Semantics<'_, RootDatabase>, def: hir::Function) -> Option<Runnable> {
let func = def.source(sema.db)?;
let name = def.name(sema.db).to_smol_str();
@@ -340,7 +340,7 @@ pub(crate) fn runnable_fn(sema: &Semantics<RootDatabase>, def: hir::Function) ->
Some(Runnable { use_name_in_title: false, nav, kind, cfg })
}
pub(crate) fn runnable_mod(sema: &Semantics<RootDatabase>, def: hir::Module) -> Option<Runnable> {
pub(crate) fn runnable_mod(sema: &Semantics<'_, RootDatabase>, def: hir::Module) -> Option<Runnable> {
if !has_test_function_or_multiple_test_submodules(sema, &def) {
return None;
}
@@ -353,7 +353,7 @@ pub(crate) fn runnable_mod(sema: &Semantics<RootDatabase>, def: hir::Module) ->
Some(Runnable { use_name_in_title: false, nav, kind: RunnableKind::TestMod { path }, cfg })
}
pub(crate) fn runnable_impl(sema: &Semantics<RootDatabase>, def: &hir::Impl) -> Option<Runnable> {
pub(crate) fn runnable_impl(sema: &Semantics<'_, RootDatabase>, def: &hir::Impl) -> Option<Runnable> {
let attrs = def.attrs(sema.db);
if !has_runnable_doc_test(&attrs) {
return None;
@@ -375,7 +375,7 @@ pub(crate) fn runnable_impl(sema: &Semantics<RootDatabase>, def: &hir::Impl) ->
/// Creates a test mod runnable for outline modules at the top of their definition.
fn runnable_mod_outline_definition(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
def: hir::Module,
) -> Option<Runnable> {
if !has_test_function_or_multiple_test_submodules(sema, &def) {
@@ -509,7 +509,7 @@ fn has_runnable_doc_test(attrs: &hir::Attrs) -> bool {
// We could create runnables for modules with number_of_test_submodules > 0,
// but that bloats the runnables for no real benefit, since all tests can be run by the submodule already
fn has_test_function_or_multiple_test_submodules(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
module: &hir::Module,
) -> bool {
let mut number_of_test_submodules = 0;

View File

@@ -94,7 +94,7 @@ pub(crate) fn signature_help(db: &RootDatabase, position: FilePosition) -> Optio
}
fn signature_help_for_call(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<SignatureHelp> {
// Find the calling expression and its NameRef
@@ -198,7 +198,7 @@ fn signature_help_for_call(
}
fn signature_help_for_generics(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<SignatureHelp> {
let parent = token.parent()?;

View File

@@ -173,7 +173,7 @@ impl StaticIndex<'_> {
self.files.push(result);
}
pub fn compute(analysis: &Analysis) -> StaticIndex {
pub fn compute(analysis: &Analysis) -> StaticIndex<'_> {
let db = &*analysis.db;
let work = all_modules(db).into_iter().filter(|module| {
let file_id = module.definition_source(db).file_id.original_file(db);
@@ -202,7 +202,7 @@ impl StaticIndex<'_> {
}
}
fn get_definition(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Definition> {
fn get_definition(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Definition> {
for token in sema.descend_into_macros(token) {
let def = IdentClass::classify_token(sema, &token).map(IdentClass::definitions);
if let Some(&[x]) = def.as_deref() {

View File

@@ -75,7 +75,7 @@ struct FilesStats {
}
impl fmt::Display for FilesStats {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} of files", self.size)
}
}
@@ -101,7 +101,7 @@ pub(crate) struct SyntaxTreeStats {
}
impl fmt::Display for SyntaxTreeStats {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} trees, {} preserved", self.total, self.retained)
}
}
@@ -143,7 +143,7 @@ struct LibrarySymbolsStats {
}
impl fmt::Display for LibrarySymbolsStats {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{} of index symbols ({})", self.size, self.total)
}
}

View File

@@ -196,7 +196,7 @@ pub(crate) fn highlight(
fn traverse(
hl: &mut Highlights,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
root: &SyntaxNode,
krate: hir::Crate,

View File

@@ -16,7 +16,7 @@ use crate::{
Highlight, HlMod, HlTag,
};
pub(super) fn token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Highlight> {
pub(super) fn token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Highlight> {
if let Some(comment) = ast::Comment::cast(token.clone()) {
let h = HlTag::Comment;
return Some(match comment.kind().doc {
@@ -46,7 +46,7 @@ pub(super) fn token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Optio
}
pub(super) fn name_like(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
syntactic_name_ref_highlighting: bool,
@@ -79,7 +79,7 @@ pub(super) fn name_like(
Some((highlight, binding_hash))
}
fn punctuation(sema: &Semantics<RootDatabase>, token: SyntaxToken, kind: SyntaxKind) -> Highlight {
fn punctuation(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken, kind: SyntaxKind) -> Highlight {
let parent = token.parent();
let parent_kind = parent.as_ref().map_or(EOF, SyntaxNode::kind);
match (kind, parent_kind) {
@@ -151,7 +151,7 @@ fn punctuation(sema: &Semantics<RootDatabase>, token: SyntaxToken, kind: SyntaxK
}
fn keyword(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
kind: SyntaxKind,
) -> Option<Highlight> {
@@ -190,7 +190,7 @@ fn keyword(
}
fn highlight_name_ref(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
binding_hash: &mut Option<u64>,
@@ -274,7 +274,7 @@ fn highlight_name_ref(
}
fn highlight_name(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
bindings_shadow_count: &mut FxHashMap<hir::Name, u32>,
binding_hash: &mut Option<u64>,
krate: hir::Crate,
@@ -321,7 +321,7 @@ fn calc_binding_hash(name: &hir::Name, shadow_count: u32) -> u64 {
hash((name, shadow_count))
}
fn highlight_def(sema: &Semantics<RootDatabase>, krate: hir::Crate, def: Definition) -> Highlight {
fn highlight_def(sema: &Semantics<'_, RootDatabase>, krate: hir::Crate, def: Definition) -> Highlight {
let db = sema.db;
let mut h = match def {
Definition::Macro(m) => Highlight::new(HlTag::Symbol(m.kind(sema.db).into())),
@@ -486,7 +486,7 @@ fn highlight_def(sema: &Semantics<RootDatabase>, krate: hir::Crate, def: Definit
}
fn highlight_method_call_by_name_ref(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
name_ref: &ast::NameRef,
) -> Option<Highlight> {
@@ -495,7 +495,7 @@ fn highlight_method_call_by_name_ref(
}
fn highlight_method_call(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
method_call: &ast::MethodCallExpr,
) -> Option<Highlight> {
@@ -584,7 +584,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight {
fn highlight_name_ref_by_syntax(
name: ast::NameRef,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
krate: hir::Crate,
) -> Highlight {
let default = HlTag::UnresolvedReference;

View File

@@ -20,7 +20,7 @@ use crate::{
pub(super) fn ra_fixture(
hl: &mut Highlights,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
literal: &ast::String,
expanded: &ast::String,
) -> Option<()> {
@@ -84,7 +84,7 @@ const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
/// Injection of syntax highlighting of doctests.
pub(super) fn doc_comment(
hl: &mut Highlights,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
InFile { file_id: src_file_id, value: node }: InFile<&SyntaxNode>,
) {
let (attributes, def) = match doc_attributes(sema, node) {