Fix clippy::explicit_deref_methods (pedantic)

https://rust-lang.github.io/rust-clippy/master/index.html#explicit_deref_methods

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2022-11-21 17:41:58 -08:00 committed by Charlie Marsh
parent 8d9d9b3204
commit 6b935121a7
3 changed files with 4 additions and 10 deletions

View file

@ -1,7 +1,6 @@
//! Lint rules based on AST traversal. //! Lint rules based on AST traversal.
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::ops::Deref;
use std::path::Path; use std::path::Path;
use itertools::Itertools; use itertools::Itertools;
@ -745,7 +744,7 @@ where
} }
if self.settings.enabled.contains(&CheckCode::F407) { if self.settings.enabled.contains(&CheckCode::F407) {
if !ALL_FEATURE_NAMES.contains(&alias.node.name.deref()) { if !ALL_FEATURE_NAMES.contains(&&*alias.node.name) {
self.add_check(Check::new( self.add_check(Check::new(
CheckKind::FutureFeatureNotDefined(alias.node.name.to_string()), CheckKind::FutureFeatureNotDefined(alias.node.name.to_string()),
Range::from_located(stmt), Range::from_located(stmt),
@ -941,7 +940,7 @@ where
self, self,
stmt, stmt,
test, test,
msg.as_ref().map(|expr| expr.deref()), msg.as_ref().map(|expr| &**expr),
); );
} }
if self.settings.enabled.contains(&CheckCode::S101) { if self.settings.enabled.contains(&CheckCode::S101) {

View file

@ -1,5 +1,3 @@
use std::ops::Deref;
use rustpython_ast::{Arguments, Constant, Expr, ExprKind, Stmt, StmtKind}; use rustpython_ast::{Arguments, Constant, Expr, ExprKind, Stmt, StmtKind};
use crate::ast::types::Range; use crate::ast::types::Range;
@ -25,9 +23,7 @@ where
StmtKind::FunctionDef { .. } | StmtKind::AsyncFunctionDef { .. } => { StmtKind::FunctionDef { .. } | StmtKind::AsyncFunctionDef { .. } => {
// No recurse. // No recurse.
} }
StmtKind::Return { value } => { StmtKind::Return { value } => self.returns.push(value.as_ref().map(|expr| &**expr)),
self.returns.push(value.as_ref().map(|expr| expr.deref()))
}
_ => visitor::walk_stmt(self, stmt), _ => visitor::walk_stmt(self, stmt),
} }
} }

View file

@ -1,7 +1,6 @@
use std::borrow::Cow; use std::borrow::Cow;
use std::fs::File; use std::fs::File;
use std::io::{BufReader, Read}; use std::io::{BufReader, Read};
use std::ops::Deref;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
@ -155,7 +154,7 @@ pub(crate) fn normalize_path_to(path: &Path, project_root: &Path) -> PathBuf {
/// Convert an absolute path to be relative to the current working directory. /// Convert an absolute path to be relative to the current working directory.
pub(crate) fn relativize_path(path: &Path) -> Cow<str> { pub(crate) fn relativize_path(path: &Path) -> Cow<str> {
if let Ok(path) = path.strip_prefix(path_dedot::CWD.deref()) { if let Ok(path) = path.strip_prefix(&*path_dedot::CWD) {
return path.to_string_lossy(); return path.to_string_lossy();
} }
path.to_string_lossy() path.to_string_lossy()