Skip to content

Commit 92f0998

Browse files
committed
Address review
1 parent 52cf489 commit 92f0998

28 files changed

+52
-52
lines changed

clippy_lints/src/blacklisted_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl LintPass for BlackListedName {
4141

4242
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlackListedName {
4343
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
44-
if let PatKind::Binding(_, _, ref ident, _) = pat.node {
44+
if let PatKind::Binding(_, _, ident, _) = pat.node {
4545
if self.blacklist.iter().any(|s| ident.name == *s) {
4646
span_lint(
4747
cx,

clippy_lints/src/booleans.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl<'a, 'tcx, 'v> SuggestContext<'a, 'tcx, 'v> {
203203
METHODS_WITH_NEGATION
204204
.iter().cloned()
205205
.flat_map(|(a, b)| vec![(a, b), (b, a)])
206-
.find(|&(a, _)| a == path.ident.name.as_str())
206+
.find(|&(a, _)| a == path.ident.as_str())
207207
.and_then(|(_, neg_method)| Some(format!("{}.{}()", self.snip(&args[0])?, neg_method)))
208208
},
209209
_ => None,

clippy_lints/src/copies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ fn bindings<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, pat: &Pat) -> HashMap<LocalInt
269269
PatKind::TupleStruct(_, ref pats, _) => for pat in pats {
270270
bindings_impl(cx, pat, map);
271271
},
272-
PatKind::Binding(_, _, ref ident, ref as_pat) => {
273-
if let Entry::Vacant(v) = map.entry(ident.name.as_str()) {
272+
PatKind::Binding(_, _, ident, ref as_pat) => {
273+
if let Entry::Vacant(v) = map.entry(ident.as_str()) {
274274
v.insert(cx.tables.pat_ty(pat));
275275
}
276276
if let Some(ref as_pat) = *as_pat {

clippy_lints/src/duration_subsec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for DurationSubsec {
4343
if match_type(cx, walk_ptrs_ty(cx.tables.expr_ty(&args[0])), &paths::DURATION);
4444
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.tables, right);
4545
then {
46-
let suggested_fn = match (method_path.ident.name.as_str().as_ref(), divisor) {
46+
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
4747
("subsec_micros", 1_000) => "subsec_millis",
4848
("subsec_nanos", 1_000) => "subsec_micros",
4949
("subsec_nanos", 1_000_000) => "subsec_millis",

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl LintPass for EnumVariantNames {
121121
}
122122

123123
fn var2str(var: &Variant) -> LocalInternedString {
124-
var.node.ident.name.as_str()
124+
var.node.ident.as_str()
125125
}
126126

127127
/// Returns the number of chars that match from the start
@@ -245,7 +245,7 @@ impl EarlyLintPass for EnumVariantNames {
245245
}
246246

247247
fn check_item(&mut self, cx: &EarlyContext, item: &Item) {
248-
let item_name = item.ident.name.as_str();
248+
let item_name = item.ident.as_str();
249249
let item_name_chars = item_name.chars().count();
250250
let item_camel = to_camel_case(&item_name);
251251
if !in_macro(item.span) {

clippy_lints/src/identity_conversion.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for IdentityConversion {
5656
},
5757

5858
ExprMethodCall(ref name, .., ref args) => {
59-
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.name.as_str() == "into" {
59+
if match_trait_method(cx, e, &paths::INTO[..]) && &*name.ident.as_str() == "into" {
6060
let a = cx.tables.expr_ty(e);
6161
let b = cx.tables.expr_ty(&args[0]);
6262
if same_tys(cx, a, b) {

clippy_lints/src/let_if_seq.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for LetIfSeq {
6767
if let Some(expr) = it.peek();
6868
if let hir::StmtDecl(ref decl, _) = stmt.node;
6969
if let hir::DeclLocal(ref decl) = decl.node;
70-
if let hir::PatKind::Binding(mode, canonical_id, ref ident, None) = decl.pat.node;
70+
if let hir::PatKind::Binding(mode, canonical_id, ident, None) = decl.pat.node;
7171
if let hir::StmtExpr(ref if_, _) = expr.node;
7272
if let hir::ExprIf(ref cond, ref then, ref else_) = if_.node;
7373
if !used_in_expr(cx, canonical_id, cond);

clippy_lints/src/loops.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ fn check_for_loop_range<'a, 'tcx>(
985985
}) = higher::range(cx, arg)
986986
{
987987
// the var must be a single name
988-
if let PatKind::Binding(_, canonical_id, ref ident, _) = pat.node {
988+
if let PatKind::Binding(_, canonical_id, ident, _) = pat.node {
989989
let mut visitor = VarVisitor {
990990
cx,
991991
var: canonical_id,
@@ -1206,7 +1206,7 @@ fn check_for_loop_arg(cx: &LateContext, pat: &Pat, arg: &Expr, expr: &Expr) {
12061206
if let ExprMethodCall(ref method, _, ref args) = arg.node {
12071207
// just the receiver, no arguments
12081208
if args.len() == 1 {
1209-
let method_name = &*method.ident.name.as_str();
1209+
let method_name = &*method.ident.as_str();
12101210
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
12111211
if method_name == "iter" || method_name == "iter_mut" {
12121212
if is_ref_iterable_type(cx, &args[0]) {
@@ -1520,7 +1520,7 @@ fn check_for_mutation(cx: &LateContext, body: &Expr, bound_ids: &[Option<NodeId>
15201520
fn pat_is_wild<'tcx>(pat: &'tcx PatKind, body: &'tcx Expr) -> bool {
15211521
match *pat {
15221522
PatKind::Wild => true,
1523-
PatKind::Binding(_, _, ident, None) if ident.name.as_str().starts_with('_') => {
1523+
PatKind::Binding(_, _, ident, None) if ident.as_str().starts_with('_') => {
15241524
let mut visitor = UsedVisitor {
15251525
var: ident.name,
15261526
used: false,
@@ -1933,7 +1933,7 @@ impl<'a, 'tcx> Visitor<'tcx> for InitializeVisitor<'a, 'tcx> {
19331933
// Look for declarations of the variable
19341934
if let DeclLocal(ref local) = decl.node {
19351935
if local.pat.id == self.var_id {
1936-
if let PatKind::Binding(_, _, ref ident, _) = local.pat.node {
1936+
if let PatKind::Binding(_, _, ident, _) = local.pat.node {
19371937
self.name = Some(ident.name);
19381938

19391939
self.state = if let Some(ref init) = local.init {

clippy_lints/src/matches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ fn check_single_match_opt_like(cx: &LateContext, ex: &Expr, arms: &[Arm], expr:
270270
}
271271
print::to_string(print::NO_ANN, |s| s.print_qpath(path, false))
272272
},
273-
PatKind::Binding(BindingAnnotation::Unannotated, _, ident, None) => ident.name.to_string(),
273+
PatKind::Binding(BindingAnnotation::Unannotated, _, ident, None) => ident.to_string(),
274274
PatKind::Path(ref path) => print::to_string(print::NO_ANN, |s| s.print_qpath(path, false)),
275275
_ => return,
276276
};
@@ -552,7 +552,7 @@ fn is_ref_some_arm(arm: &Arm) -> Option<BindingAnnotation> {
552552
if_chain! {
553553
if let PatKind::TupleStruct(ref path, ref pats, _) = arm.pats[0].node;
554554
if pats.len() == 1 && match_qpath(path, &paths::OPTION_SOME);
555-
if let PatKind::Binding(rb, _, ref ident, _) = pats[0].node;
555+
if let PatKind::Binding(rb, _, ident, _) = pats[0].node;
556556
if rb == BindingAnnotation::Ref || rb == BindingAnnotation::RefMut;
557557
if let ExprCall(ref e, ref args) = remove_blocks(&arm.body).node;
558558
if let ExprPath(ref some_path) = e.node;

clippy_lints/src/methods.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -771,8 +771,8 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
771771
lint_unnecessary_fold(cx, expr, arglists[0]);
772772
}
773773

774-
lint_or_fun_call(cx, expr, *method_span, &method_call.ident.name.as_str(), args);
775-
lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.name.as_str(), args);
774+
lint_or_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
775+
lint_expect_fun_call(cx, expr, *method_span, &method_call.ident.as_str(), args);
776776

777777
let self_ty = cx.tables.expr_ty_adjusted(&args[0]);
778778
if args.len() == 1 && method_call.ident.name == "clone" {
@@ -890,7 +890,7 @@ fn lint_or_fun_call(cx: &LateContext, expr: &hir::Expr, method_span: Span, name:
890890

891891
if name == "unwrap_or" {
892892
if let hir::ExprPath(ref qpath) = fun.node {
893-
let path = &*last_path_segment(qpath).ident.name.as_str();
893+
let path = &*last_path_segment(qpath).ident.as_str();
894894

895895
if ["default", "new"].contains(&path) {
896896
let arg_ty = cx.tables.expr_ty(arg);

0 commit comments

Comments
 (0)