Skip to content

Commit 19e5adc

Browse files
committed
Auto merge of rust-lang#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 ```
2 parents f1785f7 + e341e99 commit 19e5adc

File tree

20 files changed

+22
-22
lines changed

20 files changed

+22
-22
lines changed

crates/base-db/src/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ impl fmt::Display for CrateName {
128128
impl ops::Deref for CrateName {
129129
type Target = str;
130130
fn deref(&self) -> &str {
131-
&*self.0
131+
&self.0
132132
}
133133
}
134134

@@ -211,7 +211,7 @@ impl fmt::Display for CrateDisplayName {
211211
impl ops::Deref for CrateDisplayName {
212212
type Target = str;
213213
fn deref(&self) -> &str {
214-
&*self.crate_name
214+
&self.crate_name
215215
}
216216
}
217217

crates/base-db/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub trait SourceDatabase: FileLoader + std::fmt::Debug {
7777
fn parse_query(db: &dyn SourceDatabase, file_id: FileId) -> Parse<ast::SourceFile> {
7878
let _p = profile::span("parse_query").detail(|| format!("{:?}", file_id));
7979
let text = db.file_text(file_id);
80-
SourceFile::parse(&*text)
80+
SourceFile::parse(&text)
8181
}
8282

8383
/// We don't want to give HIR knowledge of source roots, hence we extract these

crates/hir-def/src/body.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl Body {
372372
/// Retrieves all ident patterns this pattern shares the ident with.
373373
pub fn ident_patterns_for<'slf>(&'slf self, pat: &'slf PatId) -> &'slf [PatId] {
374374
match self.or_pats.get(pat) {
375-
Some(pats) => &**pats,
375+
Some(pats) => pats,
376376
None => std::slice::from_ref(pat),
377377
}
378378
}

crates/hir-def/src/body/scope.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub struct ScopeData {
4747
impl ExprScopes {
4848
pub(crate) fn expr_scopes_query(db: &dyn DefDatabase, def: DefWithBodyId) -> Arc<ExprScopes> {
4949
let body = db.body(def);
50-
let mut scopes = ExprScopes::new(&*body);
50+
let mut scopes = ExprScopes::new(&body);
5151
scopes.shrink_to_fit();
5252
Arc::new(scopes)
5353
}

crates/hir/src/semantics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ impl<'db> SemanticsImpl<'db> {
12461246

12471247
fn with_ctx<F: FnOnce(&mut SourceToDefCtx<'_, '_>) -> T, T>(&self, f: F) -> T {
12481248
let mut cache = self.s2d_cache.borrow_mut();
1249-
let mut ctx = SourceToDefCtx { db: self.db, cache: &mut *cache };
1249+
let mut ctx = SourceToDefCtx { db: self.db, cache: &mut cache };
12501250
f(&mut ctx)
12511251
}
12521252

crates/ide-assists/src/handlers/inline_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ fn inline(
394394
// Inline parameter expressions or generate `let` statements depending on whether inlining works or not.
395395
for ((pat, param_ty, _), usages, expr) in izip!(params, param_use_nodes, arguments).rev() {
396396
// izip confuses RA due to our lack of hygiene info currently losing us type info causing incorrect errors
397-
let usages: &[ast::PathExpr] = &*usages;
397+
let usages: &[ast::PathExpr] = &usages;
398398
let expr: &ast::Expr = expr;
399399

400400
let insert_let_stmt = || {

crates/ide-db/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ pub trait LineIndexDatabase: base_db::SourceDatabase {
165165

166166
fn line_index(db: &dyn LineIndexDatabase, file_id: FileId) -> Arc<LineIndex> {
167167
let text = db.file_text(file_id);
168-
Arc::new(LineIndex::new(&*text))
168+
Arc::new(LineIndex::new(&text))
169169
}
170170

171171
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]

crates/ide-diagnostics/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub(crate) fn check_diagnostics_with_config(config: DiagnosticsConfig, ra_fixtur
102102
for file_id in files {
103103
let diagnostics = super::diagnostics(&db, &config, &AssistResolveStrategy::All, file_id);
104104

105-
let expected = extract_annotations(&*db.file_text(file_id));
105+
let expected = extract_annotations(&db.file_text(file_id));
106106
let mut actual = diagnostics
107107
.into_iter()
108108
.map(|d| {

crates/ide/src/inlay_hints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ mod tests {
459459
#[track_caller]
460460
pub(super) fn check_with_config(config: InlayHintsConfig, ra_fixture: &str) {
461461
let (analysis, file_id) = fixture::file(ra_fixture);
462-
let mut expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
462+
let mut expected = extract_annotations(&analysis.file_text(file_id).unwrap());
463463
let inlay_hints = analysis.inlay_hints(&config, file_id, None).unwrap();
464464
let actual = inlay_hints
465465
.into_iter()

crates/ide/src/inlay_hints/bind_pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ fn main() {
463463
}
464464
"#;
465465
let (analysis, file_id) = fixture::file(fixture);
466-
let expected = extract_annotations(&*analysis.file_text(file_id).unwrap());
466+
let expected = extract_annotations(&analysis.file_text(file_id).unwrap());
467467
let inlay_hints = analysis
468468
.inlay_hints(
469469
&InlayHintsConfig { type_hints: true, ..DISABLED_CONFIG },

crates/proc-macro-srv/src/abis/abi_1_58/proc_macro/bridge/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl BridgeState<'_> {
286286
BRIDGE_STATE.with(|state| {
287287
state.replace(BridgeState::InUse, |mut state| {
288288
// FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone
289-
f(&mut *state)
289+
f(&mut state)
290290
})
291291
})
292292
}

crates/proc-macro-srv/src/abis/abi_1_63/proc_macro/bridge/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ impl BridgeState<'_> {
301301
BRIDGE_STATE.with(|state| {
302302
state.replace(BridgeState::InUse, |mut state| {
303303
// FIXME(#52812) pass `f` directly to `replace` when `RefMutL` is gone
304-
f(&mut *state)
304+
f(&mut state)
305305
})
306306
})
307307
}

crates/profile/src/hprof.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static FILTER: Lazy<RwLock<Filter>> = Lazy::new(Default::default);
133133

134134
fn with_profile_stack<T>(f: impl FnOnce(&mut ProfileStack) -> T) -> T {
135135
thread_local!(static STACK: RefCell<ProfileStack> = RefCell::new(ProfileStack::new()));
136-
STACK.with(|it| f(&mut *it.borrow_mut()))
136+
STACK.with(|it| f(&mut it.borrow_mut()))
137137
}
138138

139139
#[derive(Default, Clone, Debug)]

crates/project-model/src/cargo_workspace.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ impl CargoWorkspace {
427427
}
428428

429429
pub fn package_flag(&self, package: &PackageData) -> String {
430-
if self.is_unique(&*package.name) {
430+
if self.is_unique(&package.name) {
431431
package.name.clone()
432432
} else {
433433
format!("{}:{}", package.name, package.version)

crates/project-model/src/manifest_path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl ops::Deref for ManifestPath {
4040
type Target = AbsPath;
4141

4242
fn deref(&self) -> &Self::Target {
43-
&*self.file
43+
&self.file
4444
}
4545
}
4646

crates/rust-analyzer/src/cli/lsif.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ impl LsifManager<'_> {
253253
};
254254
let result = folds
255255
.into_iter()
256-
.map(|it| to_proto::folding_range(&*text, &line_index, false, it))
256+
.map(|it| to_proto::folding_range(&text, &line_index, false, it))
257257
.collect();
258258
let folding_id = self.add_vertex(lsif::Vertex::FoldingRangeResult { result });
259259
self.add_edge(lsif::Edge::FoldingRange(lsif::EdgeData {

crates/rust-analyzer/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2178,7 +2178,7 @@ fn manual(fields: &[(&'static str, &'static str, &[&str], &str)]) -> String {
21782178
.iter()
21792179
.map(|(field, _ty, doc, default)| {
21802180
let name = format!("rust-analyzer.{}", field.replace('_', "."));
2181-
let doc = doc_comment_to_string(*doc);
2181+
let doc = doc_comment_to_string(doc);
21822182
if default.contains('\n') {
21832183
format!(
21842184
r#"[[{}]]{}::

crates/rust-analyzer/src/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ pub(crate) fn handle_folding_range(
899899
let line_folding_only = snap.config.line_folding_only();
900900
let res = folds
901901
.into_iter()
902-
.map(|it| to_proto::folding_range(&*text, &line_index, line_folding_only, it))
902+
.map(|it| to_proto::folding_range(&text, &line_index, line_folding_only, it))
903903
.collect();
904904
Ok(Some(res))
905905
}
@@ -979,7 +979,7 @@ pub(crate) fn handle_rename(
979979
let position = from_proto::file_position(&snap, params.text_document_position)?;
980980

981981
let mut change =
982-
snap.analysis.rename(position, &*params.new_name)?.map_err(to_proto::rename_error)?;
982+
snap.analysis.rename(position, &params.new_name)?.map_err(to_proto::rename_error)?;
983983

984984
// this is kind of a hack to prevent double edits from happening when moving files
985985
// When a module gets renamed by renaming the mod declaration this causes the file to move

crates/stdx/src/panic_context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ fn with_ctx(f: impl FnOnce(&mut Vec<String>)) {
4545
thread_local! {
4646
static CTX: RefCell<Vec<String>> = RefCell::new(Vec::new());
4747
}
48-
CTX.with(|ctx| f(&mut *ctx.borrow_mut()));
48+
CTX.with(|ctx| f(&mut ctx.borrow_mut()));
4949
}

crates/tt/src/buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<'a> Cursor<'a> {
190190
pub fn token_tree(self) -> Option<TokenTreeRef<'a>> {
191191
match self.entry() {
192192
Some(Entry::Leaf(tt)) => match tt {
193-
TokenTree::Leaf(leaf) => Some(TokenTreeRef::Leaf(leaf, *tt)),
193+
TokenTree::Leaf(leaf) => Some(TokenTreeRef::Leaf(leaf, tt)),
194194
TokenTree::Subtree(subtree) => Some(TokenTreeRef::Subtree(subtree, Some(tt))),
195195
},
196196
Some(Entry::Subtree(tt, subtree, _)) => Some(TokenTreeRef::Subtree(subtree, *tt)),

0 commit comments

Comments
 (0)