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);

clippy_lints/src/misc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
379379
}
380380
let binding = match expr.node {
381381
ExprPath(ref qpath) => {
382-
let binding = last_path_segment(qpath).ident.name.as_str();
382+
let binding = last_path_segment(qpath).ident.as_str();
383383
if binding.starts_with('_') &&
384384
!binding.starts_with("__") &&
385385
binding != "_result" && // FIXME: #944
@@ -417,7 +417,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
417417
}
418418

419419
fn check_pat(&mut self, cx: &LateContext<'a, 'tcx>, pat: &'tcx Pat) {
420-
if let PatKind::Binding(_, _, ref ident, Some(ref right)) = pat.node {
420+
if let PatKind::Binding(_, _, ident, Some(ref right)) = pat.node {
421421
if right.node == PatKind::Wild {
422422
span_lint(
423423
cx,

clippy_lints/src/misc_early.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl EarlyLintPass for MiscEarly {
190190
fn check_generics(&mut self, cx: &EarlyContext, gen: &Generics) {
191191
for param in &gen.params {
192192
if let GenericParamKind::Type { .. } = param.kind {
193-
let name = param.ident.name.as_str();
193+
let name = param.ident.as_str();
194194
if constants::BUILTIN_TYPES.contains(&&*name) {
195195
span_lint(
196196
cx,
@@ -268,7 +268,7 @@ impl EarlyLintPass for MiscEarly {
268268

269269
for arg in &decl.inputs {
270270
if let PatKind::Ident(_, ident, None) = arg.pat.node {
271-
let arg_name = ident.name.to_string();
271+
let arg_name = ident.to_string();
272272

273273
if arg_name.starts_with('_') {
274274
if let Some(correspondence) = registered_names.get(&arg_name[1..]) {

clippy_lints/src/mut_reference.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnnecessaryMutPassed {
4848
let def_id = cx.tables.type_dependent_defs()[e.hir_id].def_id();
4949
let substs = cx.tables.node_substs(e.hir_id);
5050
let method_type = cx.tcx.type_of(def_id).subst(cx.tcx, substs);
51-
check_arguments(cx, arguments, method_type, &path.ident.name.as_str())
51+
check_arguments(cx, arguments, method_type, &path.ident.as_str())
5252
},
5353
_ => (),
5454
}

clippy_lints/src/needless_pass_by_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NeedlessPassByValue {
153153
// Ignore `self`s.
154154
if idx == 0 {
155155
if let PatKind::Binding(_, _, ident, ..) = arg.pat.node {
156-
if ident.name.as_str() == "self" {
156+
if ident.as_str() == "self" {
157157
continue;
158158
}
159159
}

clippy_lints/src/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn get_open_options(cx: &LateContext, argument: &Expr, options: &mut Vec<(OpenOp
8787
_ => Argument::Unknown,
8888
};
8989

90-
match &*path.ident.name.as_str() {
90+
match &*path.ident.as_str() {
9191
"create" => {
9292
options.push((OpenOption::Create, argument_option));
9393
},

clippy_lints/src/ranges.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl LintPass for Pass {
8989
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass {
9090
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
9191
if let ExprMethodCall(ref path, _, ref args) = expr.node {
92-
let name = path.ident.name.as_str();
92+
let name = path.ident.as_str();
9393

9494
// Range with step_by(0).
9595
if name == "step_by" && args.len() == 2 && has_step_by(cx, &args[0]) {

clippy_lints/src/returns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl ReturnPass {
114114
if let Some(ref initexpr) = local.init;
115115
if let ast::PatKind::Ident(_, ident, _) = local.pat.node;
116116
if let ast::ExprKind::Path(_, ref path) = retexpr.node;
117-
if match_path_ast(path, &[&ident.name.as_str()]);
117+
if match_path_ast(path, &[&ident.as_str()]);
118118
if !in_external_macro(cx, initexpr.span);
119119
then {
120120
span_note_and_lint(cx,

clippy_lints/src/serde_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Serde {
3636
let mut seen_str = None;
3737
let mut seen_string = None;
3838
for item in items {
39-
match &*item.ident.name.as_str() {
39+
match &*item.ident.as_str() {
4040
"visit_str" => seen_str = Some(item.span),
4141
"visit_string" => seen_string = Some(item.span),
4242
_ => {},

clippy_lints/src/shadow.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ fn check_pat<'a, 'tcx>(
164164
) {
165165
// TODO: match more stuff / destructuring
166166
match pat.node {
167-
PatKind::Binding(_, _, ref ident, ref inner) => {
167+
PatKind::Binding(_, _, ident, ref inner) => {
168168
let name = ident.name;
169169
if is_binding(cx, pat.hir_id) {
170170
let mut new_binding = true;
@@ -378,5 +378,5 @@ fn is_self_shadow(name: Name, expr: &Expr) -> bool {
378378
}
379379

380380
fn path_eq_name(name: Name, path: &Path) -> bool {
381-
!path.is_global() && path.segments.len() == 1 && path.segments[0].ident.name.as_str() == name.as_str()
381+
!path.is_global() && path.segments.len() == 1 && path.segments[0].ident.as_str() == name.as_str()
382382
}

clippy_lints/src/swap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
6464
if let StmtDecl(ref tmp, _) = w[0].node;
6565
if let DeclLocal(ref tmp) = tmp.node;
6666
if let Some(ref tmp_init) = tmp.init;
67-
if let PatKind::Binding(_, _, ref ident, None) = tmp.pat.node;
67+
if let PatKind::Binding(_, _, ident, None) = tmp.pat.node;
6868

6969
// foo() = bar();
7070
if let StmtSemi(ref first, _) = w[1].node;
@@ -76,7 +76,7 @@ fn check_manual_swap(cx: &LateContext, block: &Block) {
7676
if let ExprPath(QPath::Resolved(None, ref rhs2)) = rhs2.node;
7777
if rhs2.segments.len() == 1;
7878

79-
if ident.name.as_str() == rhs2.segments[0].ident.name.as_str();
79+
if ident.as_str() == rhs2.segments[0].ident.as_str();
8080
if SpanlessEq::new(cx).ignore_fn().eq_expr(tmp_init, lhs1);
8181
if SpanlessEq::new(cx).ignore_fn().eq_expr(rhs1, lhs2);
8282
then {

clippy_lints/src/unused_io_amount.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
5757
}
5858
},
5959

60-
hir::ExprMethodCall(ref path, _, ref args) => match &*path.ident.name.as_str() {
60+
hir::ExprMethodCall(ref path, _, ref args) => match &*path.ident.as_str() {
6161
"expect" | "unwrap" | "unwrap_or" | "unwrap_or_else" => {
6262
check_method_call(cx, &args[0], expr);
6363
},
@@ -71,7 +71,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for UnusedIoAmount {
7171

7272
fn check_method_call(cx: &LateContext, call: &hir::Expr, expr: &hir::Expr) {
7373
if let hir::ExprMethodCall(ref path, _, _) = call.node {
74-
let symbol = &*path.ident.name.as_str();
74+
let symbol = &*path.ident.as_str();
7575
if match_trait_method(cx, call, &paths::IO_READ) && symbol == "read" {
7676
span_lint(
7777
cx,

clippy_lints/src/unused_label.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnusedLabelVisitor<'a, 'tcx> {
7070
fn visit_expr(&mut self, expr: &'tcx hir::Expr) {
7171
match expr.node {
7272
hir::ExprBreak(destination, _) | hir::ExprContinue(destination) => if let Some(label) = destination.label {
73-
self.labels.remove(&label.ident.name.as_str());
73+
self.labels.remove(&label.ident.as_str());
7474
},
7575
hir::ExprLoop(_, Some(label), _) | hir::ExprWhile(_, _, Some(label)) => {
76-
self.labels.insert(label.ident.name.as_str(), expr.span);
76+
self.labels.insert(label.ident.as_str(), expr.span);
7777
},
7878
_ => (),
7979
}

clippy_lints/src/unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn collect_unwrap_info<'a, 'tcx: 'a>(
9595
if let Expr_::ExprPath(QPath::Resolved(None, path)) = &args[0].node;
9696
let ty = cx.tables.expr_ty(&args[0]);
9797
if match_type(cx, ty, &paths::OPTION) || match_type(cx, ty, &paths::RESULT);
98-
let name = method_name.ident.name.as_str();
98+
let name = method_name.ident.as_str();
9999
if ["is_some", "is_none", "is_ok", "is_err"].contains(&&*name);
100100
then {
101101
assert!(args.len() == 1);
@@ -142,7 +142,7 @@ impl<'a, 'tcx: 'a> Visitor<'tcx> for UnwrappableVariablesVisitor<'a, 'tcx> {
142142
if_chain! {
143143
if let Expr_::ExprMethodCall(ref method_name, _, ref args) = expr.node;
144144
if let Expr_::ExprPath(QPath::Resolved(None, ref path)) = args[0].node;
145-
if ["unwrap", "unwrap_err"].contains(&&*method_name.ident.name.as_str());
145+
if ["unwrap", "unwrap_err"].contains(&&*method_name.ident.as_str());
146146
let call_to_unwrap = method_name.ident.name == "unwrap";
147147
if let Some(unwrappable) = self.unwrappables.iter()
148148
.find(|u| u.ident.def == path.def);

clippy_lints/src/utils/author.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
395395
let obj_pat = self.next("object");
396396
let field_name_pat = self.next("field_name");
397397
println!("Field(ref {}, ref {}) = {};", obj_pat, field_name_pat, current);
398-
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.name.as_str());
398+
println!(" if {}.node.as_str() == {:?}", field_name_pat, field_ident.as_str());
399399
self.current = obj_pat;
400400
self.visit_expr(object);
401401
},
@@ -503,7 +503,7 @@ impl<'tcx> Visitor<'tcx> for PrintVisitor {
503503
} else {
504504
println!("Binding({}, _, {}, None) = {};", anno_pat, name_pat, current);
505505
}
506-
println!(" if {}.node.as_str() == \"{}\";", name_pat, ident.name.as_str());
506+
println!(" if {}.node.as_str() == \"{}\";", name_pat, ident.as_str());
507507
}
508508
PatKind::Struct(ref path, ref fields, ignore) => {
509509
let path_pat = self.next("path");
@@ -671,7 +671,7 @@ fn print_path(path: &QPath, first: &mut bool) {
671671
} else {
672672
print!(", ");
673673
}
674-
print!("{:?}", segment.ident.name.as_str());
674+
print!("{:?}", segment.ident.as_str());
675675
},
676676
QPath::TypeRelative(ref ty, ref segment) => match ty.node {
677677
hir::Ty_::TyPath(ref inner_path) => {
@@ -681,7 +681,7 @@ fn print_path(path: &QPath, first: &mut bool) {
681681
} else {
682682
print!(", ");
683683
}
684-
print!("{:?}", segment.ident.name.as_str());
684+
print!("{:?}", segment.ident.as_str());
685685
},
686686
ref other => print!("/* unimplemented: {:?}*/", other),
687687
},

0 commit comments

Comments
 (0)