about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-12-23 08:04:38 +0000
committerbors <bors@rust-lang.org>2022-12-23 08:04:38 +0000
commit19e5adc38b930ee24b5a0ea59d03364f467d161b (patch)
tree3d2565cef4f79358f9b6f7da24314c92ee3a218d
parentf1785f7a21f25ecad44b6a545ff14570d4754607 (diff)
parente341e996f793587ce4ce088d5390c017c4da849d (diff)
downloadrust-19e5adc38b930ee24b5a0ea59d03364f467d161b.tar.gz
rust-19e5adc38b930ee24b5a0ea59d03364f467d161b.zip
Auto merge of #13829 - nyurik:explicit-auto-deref, r=lnicola
Clippy-fix explicit auto-deref

Seems like these can be safely fixed. With one, I was particularly surprised -- `Some(pats) => &**pats,` in body.rs?

```
cargo clippy --fix -- -A clippy::all -D clippy::explicit_auto_deref
```
-rw-r--r--crates/base-db/src/input.rs4
-rw-r--r--crates/base-db/src/lib.rs2
-rw-r--r--crates/hir-def/src/body.rs2
-rw-r--r--crates/hir-def/src/body/scope.rs2
-rw-r--r--crates/hir/src/semantics.rs2
-rw-r--r--crates/ide-assists/src/handlers/inline_call.rs2
-rw-r--r--crates/ide-db/src/lib.rs2
-rw-r--r--crates/ide-diagnostics/src/tests.rs2
-rw-r--r--crates/ide/src/inlay_hints.rs2
-rw-r--r--crates/ide/src/inlay_hints/bind_pat.rs2
-rw-r--r--crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs2
-rw-r--r--crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs2
-rw-r--r--crates/profile/src/hprof.rs2
-rw-r--r--crates/project-model/src/cargo_workspace.rs2
-rw-r--r--crates/project-model/src/manifest_path.rs2
-rw-r--r--crates/rust-analyzer/src/cli/lsif.rs2
-rw-r--r--crates/rust-analyzer/src/config.rs2
-rw-r--r--crates/rust-analyzer/src/handlers.rs4
-rw-r--r--crates/stdx/src/panic_context.rs2
-rw-r--r--crates/tt/src/buffer.rs2
20 files changed, 22 insertions, 22 deletions
diff --git a/crates/base-db/src/input.rs b/crates/base-db/src/input.rs
index 7aff9b1ae84..20bf8497cb5 100644
--- a/crates/base-db/src/input.rs
+++ b/crates/base-db/src/input.rs
@@ -128,7 +128,7 @@ impl fmt::Display for CrateName {
 impl ops::Deref for CrateName {
     type Target = str;
     fn deref(&self) -> &str {
-        &*self.0
+        &self.0
     }
 }
 
@@ -211,7 +211,7 @@ impl fmt::Display for CrateDisplayName {
 impl ops::Deref for CrateDisplayName {
     type Target = str;
     fn deref(&self) -> &str {
-        &*self.crate_name
+        &self.crate_name
     }
 }
 
diff --git a/crates/base-db/src/lib.rs b/crates/base-db/src/lib.rs
index da11e4ae7bb..f725064cda9 100644
--- a/crates/base-db/src/lib.rs
+++ b/crates/base-db/src/lib.rs
@@ -77,7 +77,7 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
 fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
     let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
     let text = db.file_text(file_id);
-    SourceFile::parse(&*text)
+    SourceFile::parse(&text)
 }
 
 /// We don't want to give HIR knowledge of source roots, hence we extract these
diff --git a/crates/hir-def/src/body.rs b/crates/hir-def/src/body.rs
index 759f3b8c04b..78fbaa9d7d3 100644
--- a/crates/hir-def/src/body.rs
+++ b/crates/hir-def/src/body.rs
@@ -372,7 +372,7 @@ impl Body {
     /// Retrieves all ident patterns this pattern shares the ident with.
     pub fn ident_patterns_for<'slf>(&'slf self, pat: &'slf PatId) -> &'slf [PatId] {
         match self.or_pats.get(pat) {
-            Some(pats) => &**pats,
+            Some(pats) => pats,
             None => std::slice::from_ref(pat),
         }
     }
diff --git a/crates/hir-def/src/body/scope.rs b/crates/hir-def/src/body/scope.rs
index 45f64ebb060..2617d4288a3 100644
--- a/crates/hir-def/src/body/scope.rs
+++ b/crates/hir-def/src/body/scope.rs
@@ -47,7 +47,7 @@ pub struct ScopeData {
 impl ExprScopes {
     pub(crate) fn expr_scopes_query(db: &dyn DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> {
         let body = db.body(def);
-        let mut scopes = ExprScopes::new(&*body);
+        let mut scopes = ExprScopes::new(&body);
         scopes.shrink_to_fit();
         Arc::new(scopes)
     }
diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs
index 76c1963e2ee..55950da9d54 100644
--- a/crates/hir/src/semantics.rs
+++ b/crates/hir/src/semantics.rs
@@ -1246,7 +1246,7 @@ impl<'db> SemanticsImpl<'db> {
 
     fn with_ctx<F: FnOnce(&mut SourceToDefCtx<'_, '_>) -> T, T>(&self, f: F) -> T {
         let mut cache = self.s2d_cache.borrow_mut();
-        let mut ctx = SourceToDefCtx { db: self.db, cache: &mut *cache };
+        let mut ctx = SourceToDefCtx { db: self.db, cache: &mut cache };
         f(&mut ctx)
     }
 
diff --git a/crates/ide-assists/src/handlers/inline_call.rs b/crates/ide-assists/src/handlers/inline_call.rs
index 0c546ce5d41..5ac18727c19 100644
--- a/crates/ide-assists/src/handlers/inline_call.rs
+++ b/crates/ide-assists/src/handlers/inline_call.rs
@@ -394,7 +394,7 @@ fn inline(
     // Inline parameter expressions or generate `let` statements depending on whether inlining works or not.
     for ((pat, param_ty, _), usages, expr) in izip!(params, param_use_nodes, arguments).rev() {
         // izip confuses RA due to our lack of hygiene info currently losing us type info causing incorrect errors
-        let usages: &[ast::PathExpr] = &*usages;
+        let usages: &[ast::PathExpr] = &usages;
         let expr: &ast::Expr = expr;
 
         let insert_let_stmt = || {
diff --git a/crates/ide-db/src/lib.rs b/crates/ide-db/src/lib.rs
index e0bc0f89f0a..156bbb634e4 100644
--- a/crates/ide-db/src/lib.rs
+++ b/crates/ide-db/src/lib.rs
@@ -165,7 +165,7 @@ pub trait LineIndexDatabase: base_db::SourceDatabase {
 
 fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
     let text = db.file_text(file_id);
-    Arc::new(LineIndex::new(&*text))
+    Arc::new(LineIndex::new(&text))
 }
 
 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
diff --git a/crates/ide-diagnostics/src/tests.rs b/crates/ide-diagnostics/src/tests.rs
index 729619cfde0..82967883176 100644
--- a/crates/ide-diagnostics/src/tests.rs
+++ b/crates/ide-diagnostics/src/tests.rs
@@ -102,7 +102,7 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
     for file_id in files {
         let diagnostics = super::diagnostics(&db, &config, &AssistResolveStrategy::All, file_id);
 
-        let expected = extract_annotations(&*db.file_text(file_id));
+        let expected = extract_annotations(&db.file_text(file_id));
         let mut actual = diagnostics
             .into_iter()
             .map(|d| {
diff --git a/crates/ide/src/inlay_hints.rs b/crates/ide/src/inlay_hints.rs
index 2b78dc51d94..6b3c15fba7f 100644
--- a/crates/ide/src/inlay_hints.rs
+++ b/crates/ide/src/inlay_hints.rs
@@ -459,7 +459,7 @@ mod tests {
     #[track_caller]
     pub(super) fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) {
         let (analysis, file_id) = fixture::file(ra_fixture);
-        let mut expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
+        let mut expected = extract_annotations(&analysis.file_text(file_id).unwrap());
         let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
         let actual = inlay_hints
             .into_iter()
diff --git a/crates/ide/src/inlay_hints/bind_pat.rs b/crates/ide/src/inlay_hints/bind_pat.rs
index 355ededb5a4..4e63740098b 100644
--- a/crates/ide/src/inlay_hints/bind_pat.rs
+++ b/crates/ide/src/inlay_hints/bind_pat.rs
@@ -463,7 +463,7 @@ fn main() {
         }
         "#;
         let (analysis, file_id) = fixture::file(fixture);
-        let expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
+        let expected = extract_annotations(&analysis.file_text(file_id).unwrap());
         let inlay_hints = analysis
             .inlay_hints(
                 &InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },
diff --git a/crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs b/crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs
index ed0e91da361..e78842f5c37 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs
@@ -286,7 +286,7 @@ impl BridgeState<'_> {
         BRIDGE_STATE.with(|state| {
             state.replace(BridgeState::InUse, |mut state| {
                 // FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone
-                f(&mut *state)
+                f(&mut state)
             })
         })
     }
diff --git a/crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs b/crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs
index 102027d14a9..b346c2c1896 100644
--- a/crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs
+++ b/crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs
@@ -301,7 +301,7 @@ impl BridgeState<'_> {
         BRIDGE_STATE.with(|state| {
             state.replace(BridgeState::InUse, |mut state| {
                 // FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone
-                f(&mut *state)
+                f(&mut state)
             })
         })
     }
diff --git a/crates/profile/src/hprof.rs b/crates/profile/src/hprof.rs
index b562c193e71..deea0b0dd8f 100644
--- a/crates/profile/src/hprof.rs
+++ b/crates/profile/src/hprof.rs
@@ -133,7 +133,7 @@ static FILTER: Lazy<RwLock<Filter>> = Lazy::new(Default::default);
 
 fn with_profile_stack<T>(f: impl FnOnce(&mut ProfileStack) -> T) -> T {
     thread_local!(static STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
-    STACK.with(|it| f(&mut *it.borrow_mut()))
+    STACK.with(|it| f(&mut it.borrow_mut()))
 }
 
 #[derive(Default, Clone, Debug)]
diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs
index 02ec7a4f6f9..93f44d1ef56 100644
--- a/crates/project-model/src/cargo_workspace.rs
+++ b/crates/project-model/src/cargo_workspace.rs
@@ -427,7 +427,7 @@ impl CargoWorkspace {
     }
 
     pub fn package_flag(&self, package: &PackageData) -> String {
-        if self.is_unique(&*package.name) {
+        if self.is_unique(&package.name) {
             package.name.clone()
         } else {
             format!("{}:{}", package.name, package.version)
diff --git a/crates/project-model/src/manifest_path.rs b/crates/project-model/src/manifest_path.rs
index 4910fd3d11c..980d92d3df9 100644
--- a/crates/project-model/src/manifest_path.rs
+++ b/crates/project-model/src/manifest_path.rs
@@ -40,7 +40,7 @@ impl ops::Deref for ManifestPath {
     type Target = AbsPath;
 
     fn deref(&self) -> &Self::Target {
-        &*self.file
+        &self.file
     }
 }
 
diff --git a/crates/rust-analyzer/src/cli/lsif.rs b/crates/rust-analyzer/src/cli/lsif.rs
index c74ddabb177..43161778413 100644
--- a/crates/rust-analyzer/src/cli/lsif.rs
+++ b/crates/rust-analyzer/src/cli/lsif.rs
@@ -253,7 +253,7 @@ impl LsifManager<'_> {
         };
         let result = folds
             .into_iter()
-            .map(|it| to_proto::folding_range(&*text, &line_index, false, it))
+            .map(|it| to_proto::folding_range(&text, &line_index, false, it))
             .collect();
         let folding_id = self.add_vertex(lsif::Vertex::FoldingRangeResult { result });
         self.add_edge(lsif::Edge::FoldingRange(lsif::EdgeData {
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index cba04b00c3d..76ff2d5859e 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -2178,7 +2178,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
         .iter()
         .map(|(field, _ty, doc, default)| {
             let name = format!("rust-analyzer.{}", field.replace('_', "."));
-            let doc = doc_comment_to_string(*doc);
+            let doc = doc_comment_to_string(doc);
             if default.contains('\n') {
                 format!(
                     r#"[[{}]]{}::
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs
index 2850bc2c3d9..7a4d372a285 100644
--- a/crates/rust-analyzer/src/handlers.rs
+++ b/crates/rust-analyzer/src/handlers.rs
@@ -899,7 +899,7 @@ pub(crate) fn handle_folding_range(
     let line_folding_only = snap.config.line_folding_only();
     let res = folds
         .into_iter()
-        .map(|it| to_proto::folding_range(&*text, &line_index, line_folding_only, it))
+        .map(|it| to_proto::folding_range(&text, &line_index, line_folding_only, it))
         .collect();
     Ok(Some(res))
 }
@@ -979,7 +979,7 @@ pub(crate) fn handle_rename(
     let position = from_proto::file_position(&snap, params.text_document_position)?;
 
     let mut change =
-        snap.analysis.rename(position, &*params.new_name)?.map_err(to_proto::rename_error)?;
+        snap.analysis.rename(position, &params.new_name)?.map_err(to_proto::rename_error)?;
 
     // this is kind of a hack to prevent double edits from happening when moving files
     // When a module gets renamed by renaming the mod declaration this causes the file to move
diff --git a/crates/stdx/src/panic_context.rs b/crates/stdx/src/panic_context.rs
index f8fafc5a677..a64f9a6f3fa 100644
--- a/crates/stdx/src/panic_context.rs
+++ b/crates/stdx/src/panic_context.rs
@@ -45,5 +45,5 @@ fn with_ctx(f: impl FnOnce(&mut Vec<String>)) {
     thread_local! {
         static CTX: RefCell<Vec<String>> = RefCell::new(Vec::new());
     }
-    CTX.with(|ctx| f(&mut *ctx.borrow_mut()));
+    CTX.with(|ctx| f(&mut ctx.borrow_mut()));
 }
diff --git a/crates/tt/src/buffer.rs b/crates/tt/src/buffer.rs
index 69226bd4c48..d27a7aa0d4d 100644
--- a/crates/tt/src/buffer.rs
+++ b/crates/tt/src/buffer.rs
@@ -190,7 +190,7 @@ impl<'a> Cursor<'a> {
     pub fn token_tree(self) -> Option<TokenTreeRef<'a>> {
         match self.entry() {
             Some(Entry::Leaf(tt)) => match tt {
-                TokenTree::Leaf(leaf) => Some(TokenTreeRef::Leaf(leaf, *tt)),
+                TokenTree::Leaf(leaf) => Some(TokenTreeRef::Leaf(leaf, tt)),
                 TokenTree::Subtree(subtree) => Some(TokenTreeRef::Subtree(subtree, Some(tt))),
             },
             Some(Entry::Subtree(tt, subtree, _)) => Some(TokenTreeRef::Subtree(subtree, *tt)),