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

@ -17,7 +17,7 @@ pub struct ActiveParameter {
impl ActiveParameter {
/// Returns information about the call argument this token is part of.
pub fn at_token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Option<Self> {
pub fn at_token(sema: &Semantics<'_, RootDatabase>, token: SyntaxToken) -> Option<Self> {
let (signature, active_parameter) = callable_for_token(sema, token)?;
let idx = active_parameter?;
@ -40,7 +40,7 @@ impl ActiveParameter {
/// Returns a [`hir::Callable`] this token is a part of and its argument index of said callable.
pub fn callable_for_token(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: SyntaxToken,
) -> Option<(hir::Callable, Option<usize>)> {
// Find the calling expression and its NameRef
@ -54,7 +54,7 @@ pub fn callable_for_token(
}
pub fn callable_for_node(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
calling_node: &ast::CallableExpr,
token: &SyntaxToken,
) -> Option<(hir::Callable, Option<usize>)> {

View file

@ -130,7 +130,7 @@ pub enum IdentClass {
}
impl IdentClass {
pub fn classify_node(sema: &Semantics<RootDatabase>, node: &SyntaxNode) -> Option<IdentClass> {
pub fn classify_node(sema: &Semantics<'_, RootDatabase>, node: &SyntaxNode) -> Option<IdentClass> {
match_ast! {
match node {
ast::Name(name) => NameClass::classify(sema, &name).map(IdentClass::NameClass),
@ -146,7 +146,7 @@ impl IdentClass {
}
pub fn classify_token(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
token: &SyntaxToken,
) -> Option<IdentClass> {
let parent = token.parent()?;
@ -154,7 +154,7 @@ impl IdentClass {
}
pub fn classify_lifetime(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<IdentClass> {
NameRefClass::classify_lifetime(sema, lifetime)
@ -218,7 +218,7 @@ impl NameClass {
Some(res)
}
pub fn classify(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<NameClass> {
pub fn classify(sema: &Semantics<'_, RootDatabase>, name: &ast::Name) -> Option<NameClass> {
let _p = profile::span("classify_name");
let parent = name.syntax().parent()?;
@ -238,7 +238,7 @@ impl NameClass {
};
return Some(NameClass::Definition(definition));
fn classify_item(sema: &Semantics<RootDatabase>, item: ast::Item) -> Option<Definition> {
fn classify_item(sema: &Semantics<'_, RootDatabase>, item: ast::Item) -> Option<Definition> {
let definition = match item {
ast::Item::MacroRules(it) => {
Definition::Macro(sema.to_def(&ast::Macro::MacroRules(it))?)
@ -266,7 +266,7 @@ impl NameClass {
}
fn classify_ident_pat(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
ident_pat: ast::IdentPat,
) -> Option<NameClass> {
if let Some(def) = sema.resolve_bind_pat_to_const(&ident_pat) {
@ -289,7 +289,7 @@ impl NameClass {
}
fn classify_rename(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
rename: ast::Rename,
) -> Option<Definition> {
if let Some(use_tree) = rename.syntax().parent().and_then(ast::UseTree::cast) {
@ -305,7 +305,7 @@ impl NameClass {
}
pub fn classify_lifetime(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<NameClass> {
let _p = profile::span("classify_lifetime").detail(|| lifetime.to_string());
@ -338,7 +338,7 @@ impl NameRefClass {
// Note: we don't have unit-tests for this rather important function.
// It is primarily exercised via goto definition tests in `ide`.
pub fn classify(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
name_ref: &ast::NameRef,
) -> Option<NameRefClass> {
let _p = profile::span("classify_name_ref").detail(|| name_ref.to_string());
@ -418,7 +418,7 @@ impl NameRefClass {
}
pub fn classify_lifetime(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
lifetime: &ast::Lifetime,
) -> Option<NameRefClass> {
let _p = profile::span("classify_lifetime_ref").detail(|| lifetime.to_string());

View file

@ -56,7 +56,7 @@ pub fn mod_path_to_ast(path: &hir::ModPath) -> ast::Path {
/// Iterates all `ModuleDef`s and `Impl` blocks of the given file.
pub fn visit_file_defs(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
file_id: FileId,
cb: &mut dyn FnMut(Definition),
) {

View file

@ -99,7 +99,7 @@ pub struct ImportAssets {
impl ImportAssets {
pub fn for_method_call(
method_call: &ast::MethodCallExpr,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
let candidate_node = method_call.syntax().clone();
Some(Self {
@ -111,7 +111,7 @@ impl ImportAssets {
pub fn for_exact_path(
fully_qualified_path: &ast::Path,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
let candidate_node = fully_qualified_path.syntax().clone();
if let Some(use_tree) = candidate_node.ancestors().find_map(ast::UseTree::cast) {
@ -129,7 +129,7 @@ impl ImportAssets {
})
}
pub fn for_ident_pat(sema: &Semantics<RootDatabase>, pat: &ast::IdentPat) -> Option<Self> {
pub fn for_ident_pat(sema: &Semantics<'_, RootDatabase>, pat: &ast::IdentPat) -> Option<Self> {
if !pat.is_simple_ident() {
return None;
}
@ -146,7 +146,7 @@ impl ImportAssets {
module_with_candidate: Module,
qualifier: Option<ast::Path>,
fuzzy_name: String,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
candidate_node: SyntaxNode,
) -> Option<Self> {
Some(Self {
@ -210,7 +210,7 @@ impl ImportAssets {
pub fn search_for_imports(
&self,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
prefix_kind: PrefixKind,
) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for_imports");
@ -218,7 +218,7 @@ impl ImportAssets {
}
/// This may return non-absolute paths if a part of the returned path is already imported into scope.
pub fn search_for_relative_paths(&self, sema: &Semantics<RootDatabase>) -> Vec<LocatedImport> {
pub fn search_for_relative_paths(&self, sema: &Semantics<'_, RootDatabase>) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for_relative_paths");
self.search_for(sema, None)
}
@ -237,7 +237,7 @@ impl ImportAssets {
fn search_for(
&self,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
prefixed: Option<PrefixKind>,
) -> Vec<LocatedImport> {
let _p = profile::span("import_assets::search_for");
@ -276,7 +276,7 @@ impl ImportAssets {
.collect()
}
fn scope_definitions(&self, sema: &Semantics<RootDatabase>) -> FxHashSet<ScopeDef> {
fn scope_definitions(&self, sema: &Semantics<'_, RootDatabase>) -> FxHashSet<ScopeDef> {
let _p = profile::span("import_assets::scope_definitions");
let mut scope_definitions = FxHashSet::default();
if let Some(scope) = sema.scope(&self.candidate_node) {
@ -289,7 +289,7 @@ impl ImportAssets {
}
fn path_applicable_imports(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
current_crate: Crate,
path_candidate: &PathImportCandidate,
mod_path: impl Fn(ItemInNs) -> Option<ModPath> + Copy,
@ -456,9 +456,9 @@ fn module_with_segment_name(
}
fn trait_applicable_items(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
current_crate: Crate,
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
trait_candidate: &TraitImportCandidate,
trait_assoc_item: bool,
mod_path: impl Fn(ItemInNs) -> Option<ModPath>,
@ -571,7 +571,7 @@ fn get_mod_path(
impl ImportCandidate {
fn for_method_call(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
method_call: &ast::MethodCallExpr,
) -> Option<Self> {
match sema.resolve_method_call(method_call) {
@ -585,7 +585,7 @@ impl ImportCandidate {
}
}
fn for_regular_path(sema: &Semantics<RootDatabase>, path: &ast::Path) -> Option<Self> {
fn for_regular_path(sema: &Semantics<'_, RootDatabase>, path: &ast::Path) -> Option<Self> {
if sema.resolve_path(path).is_some() {
return None;
}
@ -596,7 +596,7 @@ impl ImportCandidate {
)
}
fn for_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Self> {
fn for_name(sema: &Semantics<'_, RootDatabase>, name: &ast::Name) -> Option<Self> {
if sema
.scope(name.syntax())?
.speculative_resolve(&ast::make::ext::ident_path(&name.text()))
@ -613,14 +613,14 @@ impl ImportCandidate {
fn for_fuzzy_path(
qualifier: Option<ast::Path>,
fuzzy_name: String,
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
) -> Option<Self> {
path_import_candidate(sema, qualifier, NameToImport::Fuzzy(fuzzy_name))
}
}
fn path_import_candidate(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
qualifier: Option<ast::Path>,
name: NameToImport,
) -> Option<ImportCandidate> {

View file

@ -115,7 +115,7 @@ impl FileLoader for RootDatabase {
fn file_text(&self, file_id: FileId) -> Arc<String> {
FileLoaderDelegate(self).file_text(file_id)
}
fn resolve_path(&self, path: AnchoredPath) -> Option<FileId> {
fn resolve_path(&self, path: AnchoredPath<'_>) -> Option<FileId> {
FileLoaderDelegate(self).resolve_path(path)
}
fn relevant_crates(&self, file_id: FileId) -> Arc<FxHashSet<CrateId>> {

View file

@ -255,7 +255,7 @@ fn get_type_args_from_arg_list(generic_arg_list: ast::GenericArgList) -> Option<
}
fn find_trait_for_assoc_item(
scope: &SemanticsScope,
scope: &SemanticsScope<'_>,
type_param: hir::TypeParam,
assoc_item: ast::NameRef,
) -> Option<hir::Trait> {

View file

@ -66,7 +66,7 @@ macro_rules! _bail {
pub use _bail as bail;
impl Definition {
pub fn rename(&self, sema: &Semantics<RootDatabase>, new_name: &str) -> Result<SourceChange> {
pub fn rename(&self, sema: &Semantics<'_, RootDatabase>, new_name: &str) -> Result<SourceChange> {
match *self {
Definition::Module(module) => rename_mod(sema, module, new_name),
Definition::BuiltinType(_) => {
@ -80,7 +80,7 @@ impl Definition {
/// Textual range of the identifier which will change when renaming this
/// `Definition`. Note that some definitions, like buitin types, can't be
/// renamed.
pub fn range_for_rename(self, sema: &Semantics<RootDatabase>) -> Option<FileRange> {
pub fn range_for_rename(self, sema: &Semantics<'_, RootDatabase>) -> Option<FileRange> {
let res = match self {
Definition::Macro(mac) => {
let src = mac.source(sema.db)?;
@ -155,7 +155,7 @@ impl Definition {
};
return res;
fn name_range<D>(def: D, sema: &Semantics<RootDatabase>) -> Option<FileRange>
fn name_range<D>(def: D, sema: &Semantics<'_, RootDatabase>) -> Option<FileRange>
where
D: HasSource,
D::Ast: ast::HasName,
@ -168,7 +168,7 @@ impl Definition {
}
fn rename_mod(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
module: hir::Module,
new_name: &str,
) -> Result<SourceChange> {
@ -248,7 +248,7 @@ fn rename_mod(
}
fn rename_reference(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
def: Definition,
new_name: &str,
) -> Result<SourceChange> {
@ -448,7 +448,7 @@ fn source_edit_from_name_ref(
}
fn source_edit_from_def(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
def: Definition,
new_name: &str,
) -> Result<(FileId, TextEdit)> {

View file

@ -305,7 +305,7 @@ impl Definition {
}
}
pub fn usages<'a>(self, sema: &'a Semantics<RootDatabase>) -> FindUsages<'a> {
pub fn usages<'a>(self, sema: &'a Semantics<'_, RootDatabase>) -> FindUsages<'a> {
FindUsages {
local_repr: match self {
Definition::Local(local) => Some(local.representative(sema.db)),
@ -424,7 +424,7 @@ impl<'a> FindUsages<'a> {
}
fn scope_files<'a>(
sema: &'a Semantics<RootDatabase>,
sema: &'a Semantics<'_, RootDatabase>,
scope: &'a SearchScope,
) -> impl Iterator<Item = (Arc<String>, FileId, TextRange)> + 'a {
scope.entries.iter().map(|(&file_id, &search_range)| {
@ -740,7 +740,7 @@ impl<'a> FindUsages<'a> {
}
}
fn def_to_ty(sema: &Semantics<RootDatabase>, def: &Definition) -> Option<hir::Type> {
fn def_to_ty(sema: &Semantics<'_, RootDatabase>, def: &Definition) -> Option<hir::Type> {
match def {
Definition::Adt(adt) => Some(adt.ty(sema.db)),
Definition::TypeAlias(it) => Some(it.ty(sema.db)),

View file

@ -224,7 +224,7 @@ pub struct SymbolIndex {
}
impl fmt::Debug for SymbolIndex {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("SymbolIndex").field("n_symbols", &self.symbols.len()).finish()
}
}

View file

@ -399,7 +399,7 @@ impl TreeWithDepthIterator {
}
}
impl<'a> Iterator for TreeWithDepthIterator {
impl Iterator for TreeWithDepthIterator {
type Item = (ast::Expr, u32);
fn next(&mut self) -> Option<Self::Item> {

View file

@ -264,7 +264,7 @@ fn push_lint_completion(buf: &mut String, label: &str, description: &str) {
);
}
fn push_lint_group<'a>(buf: &mut String, label: &str, description: &str, children: &[String]) {
fn push_lint_group(buf: &mut String, label: &str, description: &str, children: &[String]) {
buf.push_str(
r###" LintGroup {
lint:

View file

@ -7,7 +7,7 @@ use syntax::{ast, AstNode};
/// Given the `impl` block, attempts to find the trait this `impl` corresponds to.
pub fn resolve_target_trait(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
impl_def: &ast::Impl,
) -> Option<hir::Trait> {
let ast_path =
@ -22,7 +22,7 @@ pub fn resolve_target_trait(
/// Given the `impl` block, returns the list of associated items (e.g. functions or types) that are
/// missing in this `impl` block.
pub fn get_missing_assoc_items(
sema: &Semantics<RootDatabase>,
sema: &Semantics<'_, RootDatabase>,
impl_def: &ast::Impl,
) -> Vec<hir::AssocItem> {
let imp = match sema.to_def(impl_def) {

View file

@ -20,7 +20,7 @@ impl TryEnum {
const ALL: [TryEnum; 2] = [TryEnum::Option, TryEnum::Result];
/// Returns `Some(..)` if the provided type is an enum that implements `std::ops::Try`.
pub fn from_ty(sema: &Semantics<RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
pub fn from_ty(sema: &Semantics<'_, RootDatabase>, ty: &hir::Type) -> Option<TryEnum> {
let enum_ = match ty.as_adt() {
Some(hir::Adt::Enum(it)) => it,
_ => return None,