mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
needless_borrow
This commit is contained in:
parent
d351cb8dfb
commit
3839f9a9a2
9 changed files with 14 additions and 15 deletions
|
@ -175,7 +175,6 @@ field_reassign_with_default = "allow"
|
|||
forget_non_drop = "allow"
|
||||
format_collect = "allow"
|
||||
large_enum_variant = "allow"
|
||||
needless_borrow = "allow"
|
||||
needless_doctest_main = "allow"
|
||||
needless_lifetimes = "allow"
|
||||
needless_pass_by_value = "allow"
|
||||
|
|
|
@ -1844,8 +1844,8 @@ impl ExprCollector<'_> {
|
|||
flags as u128,
|
||||
Some(BuiltinUint::U32),
|
||||
)));
|
||||
let precision = self.make_count(&precision, argmap);
|
||||
let width = self.make_count(&width, argmap);
|
||||
let precision = self.make_count(precision, argmap);
|
||||
let width = self.make_count(width, argmap);
|
||||
|
||||
let format_placeholder_new = {
|
||||
let format_placeholder_new =
|
||||
|
|
|
@ -230,7 +230,7 @@ fn find_path_for_module(
|
|||
}
|
||||
|
||||
if let value @ Some(_) =
|
||||
find_in_prelude(ctx.db, &root_def_map, &def_map, ItemInNs::Types(module_id.into()), from)
|
||||
find_in_prelude(ctx.db, &root_def_map, def_map, ItemInNs::Types(module_id.into()), from)
|
||||
{
|
||||
return value.zip(Some(Stable));
|
||||
}
|
||||
|
|
|
@ -294,14 +294,14 @@ impl SearchMode {
|
|||
pub fn check(self, query: &str, case_sensitive: bool, candidate: &str) -> bool {
|
||||
match self {
|
||||
SearchMode::Exact if case_sensitive => candidate == query,
|
||||
SearchMode::Exact => candidate.eq_ignore_ascii_case(&query),
|
||||
SearchMode::Exact => candidate.eq_ignore_ascii_case(query),
|
||||
SearchMode::Prefix => {
|
||||
query.len() <= candidate.len() && {
|
||||
let prefix = &candidate[..query.len() as usize];
|
||||
if case_sensitive {
|
||||
prefix == query
|
||||
} else {
|
||||
prefix.eq_ignore_ascii_case(&query)
|
||||
prefix.eq_ignore_ascii_case(query)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ impl LangItems {
|
|||
|
||||
pub(crate) fn lang_attr(db: &dyn DefDatabase, item: AttrDefId) -> Option<LangItem> {
|
||||
let attrs = db.attrs(item);
|
||||
attrs.by_key("lang").string_value().and_then(|it| LangItem::from_str(&it))
|
||||
attrs.by_key("lang").string_value().and_then(|it| LangItem::from_str(it))
|
||||
}
|
||||
|
||||
pub(crate) fn notable_traits_in_deps(
|
||||
|
|
|
@ -1406,7 +1406,7 @@ impl DefCollector<'_> {
|
|||
}
|
||||
if let errors @ [_, ..] = &*value {
|
||||
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(macro_call_id);
|
||||
let diag = DefDiagnostic::macro_expansion_parse_error(module_id, loc.kind, &errors);
|
||||
let diag = DefDiagnostic::macro_expansion_parse_error(module_id, loc.kind, errors);
|
||||
self.def_map.diagnostics.push(diag);
|
||||
}
|
||||
|
||||
|
@ -2287,7 +2287,7 @@ impl ModCollector<'_, '_> {
|
|||
&MacroCall { ref path, ast_id, expand_to, call_site }: &MacroCall,
|
||||
container: ItemContainerId,
|
||||
) {
|
||||
let ast_id = AstIdWithPath::new(self.file_id(), ast_id, ModPath::clone(&path));
|
||||
let ast_id = AstIdWithPath::new(self.file_id(), ast_id, ModPath::clone(path));
|
||||
let db = self.def_collector.db;
|
||||
|
||||
// FIXME: Immediately expanding in "Case 1" is insufficient since "Case 2" may also define
|
||||
|
|
|
@ -154,7 +154,7 @@ impl Path {
|
|||
|
||||
pub fn mod_path(&self) -> Option<&ModPath> {
|
||||
match self {
|
||||
Path::Normal { mod_path, .. } => Some(&mod_path),
|
||||
Path::Normal { mod_path, .. } => Some(mod_path),
|
||||
Path::LangItem(..) => None,
|
||||
}
|
||||
}
|
||||
|
@ -219,13 +219,13 @@ impl<'a> PathSegments<'a> {
|
|||
}
|
||||
pub fn skip(&self, len: usize) -> PathSegments<'a> {
|
||||
PathSegments {
|
||||
segments: &self.segments.get(len..).unwrap_or(&[]),
|
||||
segments: self.segments.get(len..).unwrap_or(&[]),
|
||||
generic_args: self.generic_args.and_then(|it| it.get(len..)),
|
||||
}
|
||||
}
|
||||
pub fn take(&self, len: usize) -> PathSegments<'a> {
|
||||
PathSegments {
|
||||
segments: &self.segments.get(..len).unwrap_or(&self.segments),
|
||||
segments: self.segments.get(..len).unwrap_or(self.segments),
|
||||
generic_args: self.generic_args.map(|it| it.get(..len).unwrap_or(it)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1439,7 +1439,7 @@ impl Adt {
|
|||
resolver
|
||||
.generic_params()
|
||||
.and_then(|gp| {
|
||||
(&gp.lifetimes)
|
||||
gp.lifetimes
|
||||
.iter()
|
||||
// there should only be a single lifetime
|
||||
// but `Arena` requires to use an iterator
|
||||
|
@ -4286,7 +4286,7 @@ impl Type {
|
|||
) -> impl Iterator<Item = SmolStr> + 'a {
|
||||
// iterate the lifetime
|
||||
self.as_adt()
|
||||
.and_then(|a| a.lifetime(db).map(|lt| (<.name).to_smol_str()))
|
||||
.and_then(|a| a.lifetime(db).map(|lt| lt.name.to_smol_str()))
|
||||
.into_iter()
|
||||
// add the type and const parameters
|
||||
.chain(self.type_and_const_arguments(db))
|
||||
|
|
|
@ -764,7 +764,7 @@ impl Iterator for PatternIterator {
|
|||
type Item = SyntaxElement;
|
||||
|
||||
fn next(&mut self) -> Option<SyntaxElement> {
|
||||
(&mut self.iter).find(|element| !element.kind().is_trivia())
|
||||
self.iter.find(|element| !element.kind().is_trivia())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue