clippy::clone_on_copy

This commit is contained in:
Maan2003 2021-06-13 09:27:19 +05:30
parent 6cc6dee9e9
commit 705f7e6e26
No known key found for this signature in database
GPG Key ID: E9AF024BA63C70ED
7 changed files with 6 additions and 7 deletions

View File

@ -452,7 +452,7 @@ impl Module {
}
pub fn visibility_of(self, db: &dyn HirDatabase, def: &ModuleDef) -> Option<Visibility> {
self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of(def.clone().into())
self.id.def_map(db.upcast())[self.id.local_id].scope.visibility_of((*def).into())
}
pub fn diagnostics(

View File

@ -606,7 +606,7 @@ pub struct DocsRangeMap {
impl DocsRangeMap {
pub fn map(&self, range: TextRange) -> Option<InFile<TextRange>> {
let found = self.mapping.binary_search_by(|(probe, ..)| probe.ordering(range)).ok()?;
let (line_docs_range, idx, original_line_src_range) = self.mapping[found].clone();
let (line_docs_range, idx, original_line_src_range) = self.mapping[found];
if !line_docs_range.contains_range(range) {
return None;
}

View File

@ -59,7 +59,7 @@ pub struct ItemScope {
pub(crate) static BUILTIN_SCOPE: Lazy<FxHashMap<Name, PerNs>> = Lazy::new(|| {
BuiltinType::ALL
.iter()
.map(|(name, ty)| (name.clone(), PerNs::types(ty.clone().into(), Visibility::Public)))
.map(|(name, ty)| (name.clone(), PerNs::types((*ty).into(), Visibility::Public)))
.collect()
});

View File

@ -45,7 +45,6 @@ impl ProcMacroExpander {
let proc_macro = krate_graph[self.krate]
.proc_macro
.get(id.0 as usize)
.clone()
.ok_or_else(|| err!("No derive macro found."))?;
// Proc macros have access to the environment variables of the invoking crate.

View File

@ -43,7 +43,7 @@ pub(crate) fn goto_definition(
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
let (_, link, ns) =
extract_definitions_from_markdown(docs.as_str()).into_iter().find(|(range, ..)| {
doc_mapping.map(range.clone()).map_or(false, |InFile { file_id, value: range }| {
doc_mapping.map(*range).map_or(false, |InFile { file_id, value: range }| {
file_id == position.file_id.into() && range.contains(position.offset)
})
})?;

View File

@ -87,7 +87,7 @@ fn impls_for_trait_item(
.filter_map(|imp| {
let item = imp.items(sema.db).iter().find_map(|itm| {
let itm_name = itm.name(sema.db)?;
(itm_name == fun_name).then(|| itm.clone())
(itm_name == fun_name).then(|| *itm)
})?;
item.try_to_nav(sema.db)
})

View File

@ -131,7 +131,7 @@ pub(crate) fn hover(
let (docs, doc_mapping) = attributes.docs_with_rangemap(db)?;
let (idl_range, link, ns) =
extract_definitions_from_markdown(docs.as_str()).into_iter().find_map(|(range, link, ns)| {
let InFile { file_id, value: range } = doc_mapping.map(range.clone())?;
let InFile { file_id, value: range } = doc_mapping.map(range)?;
if file_id == position.file_id.into() && range.contains(position.offset) {
Some((range, link, ns))
} else {