Skip to content

Commit 0eff589

Browse files
committed
Auto merge of #8196 - flip1995:rustup, r=flip1995
Rustup r? `@ghost` changelog: none
2 parents c1cd64b + b0f9894 commit 0eff589

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+168
-141
lines changed

Diff for: clippy_lints/src/approx_const.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl ApproxConstant {
8787
let s = s.as_str();
8888
if s.parse::<f64>().is_ok() {
8989
for &(constant, name, min_digits, msrv) in &KNOWN_CONSTS {
90-
if is_approx_const(constant, &s, min_digits)
90+
if is_approx_const(constant, s, min_digits)
9191
&& msrv.as_ref().map_or(true, |msrv| meets_msrv(self.msrv.as_ref(), msrv))
9292
{
9393
span_lint_and_help(

Diff for: clippy_lints/src/attrs.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_semver::RustcVersion;
1717
use rustc_session::{declare_lint_pass, declare_tool_lint, impl_lint_pass};
1818
use rustc_span::source_map::Span;
1919
use rustc_span::sym;
20-
use rustc_span::symbol::{Symbol, SymbolStr};
20+
use rustc_span::symbol::Symbol;
2121
use semver::Version;
2222

2323
static UNIX_SYSTEMS: &[&str] = &[
@@ -310,8 +310,10 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
310310
|| is_word(lint, sym::deprecated)
311311
|| is_word(lint, sym!(unreachable_pub))
312312
|| is_word(lint, sym!(unused))
313-
|| extract_clippy_lint(lint).map_or(false, |s| s == "wildcard_imports")
314-
|| extract_clippy_lint(lint).map_or(false, |s| s == "enum_glob_use")
313+
|| extract_clippy_lint(lint)
314+
.map_or(false, |s| s.as_str() == "wildcard_imports")
315+
|| extract_clippy_lint(lint)
316+
.map_or(false, |s| s.as_str() == "enum_glob_use")
315317
{
316318
return;
317319
}
@@ -370,15 +372,15 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
370372
}
371373

372374
/// Returns the lint name if it is clippy lint.
373-
fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<SymbolStr> {
375+
fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<Symbol> {
374376
if_chain! {
375377
if let Some(meta_item) = lint.meta_item();
376378
if meta_item.path.segments.len() > 1;
377379
if let tool_name = meta_item.path.segments[0].ident;
378380
if tool_name.name == sym::clippy;
379381
then {
380382
let lint_name = meta_item.path.segments.last().unwrap().ident.name;
381-
return Some(lint_name.as_str());
383+
return Some(lint_name);
382384
}
383385
}
384386
None
@@ -387,7 +389,7 @@ fn extract_clippy_lint(lint: &NestedMetaItem) -> Option<SymbolStr> {
387389
fn check_clippy_lint_names(cx: &LateContext<'_>, name: Symbol, items: &[NestedMetaItem]) {
388390
for lint in items {
389391
if let Some(lint_name) = extract_clippy_lint(lint) {
390-
if lint_name == "restriction" && name != sym::allow {
392+
if lint_name.as_str() == "restriction" && name != sym::allow {
391393
span_lint_and_help(
392394
cx,
393395
BLANKET_CLIPPY_RESTRICTION_LINTS,
@@ -486,7 +488,7 @@ fn check_attrs(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribut
486488

487489
fn check_semver(cx: &LateContext<'_>, span: Span, lit: &Lit) {
488490
if let LitKind::Str(is, _) = lit.kind {
489-
if Version::parse(&is.as_str()).is_ok() {
491+
if Version::parse(is.as_str()).is_ok() {
490492
return;
491493
}
492494
}
@@ -619,7 +621,7 @@ fn check_mismatched_target_os(cx: &EarlyContext<'_>, attr: &Attribute) {
619621
MetaItemKind::Word => {
620622
if_chain! {
621623
if let Some(ident) = meta.ident();
622-
if let Some(os) = find_os(&*ident.name.as_str());
624+
if let Some(os) = find_os(ident.name.as_str());
623625
then {
624626
mismatched.push((os, ident.span));
625627
}

Diff for: clippy_lints/src/booleans.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn simplify_not(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<String> {
272272
.copied()
273273
.flat_map(|(a, b)| vec![(a, b), (b, a)])
274274
.find(|&(a, _)| {
275-
let path: &str = &path.ident.name.as_str();
275+
let path: &str = path.ident.name.as_str();
276276
a == path
277277
})
278278
.and_then(|(_, neg_method)| Some(format!("{}.{}()", snippet_opt(cx, args[0].span)?, neg_method)))

Diff for: clippy_lints/src/checked_conversions.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ fn get_implementing_type<'a>(path: &QPath<'_>, candidates: &'a [&str], function:
321321
if let TyKind::Path(QPath::Resolved(None, tp)) = &ty.kind;
322322
if let [int] = &*tp.segments;
323323
then {
324-
let name = &int.ident.name.as_str();
325-
candidates.iter().find(|c| name == *c).copied()
324+
let name = int.ident.name.as_str();
325+
candidates.iter().find(|c| &name == *c).copied()
326326
} else {
327327
None
328328
}
@@ -335,8 +335,8 @@ fn int_ty_to_sym<'tcx>(path: &QPath<'_>) -> Option<&'tcx str> {
335335
if let QPath::Resolved(_, path) = *path;
336336
if let [ty] = &*path.segments;
337337
then {
338-
let name = &ty.ident.name.as_str();
339-
INTS.iter().find(|c| name == *c).copied()
338+
let name = ty.ident.name.as_str();
339+
INTS.iter().find(|c| &name == *c).copied()
340340
} else {
341341
None
342342
}

Diff for: clippy_lints/src/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ fn check_attrs<'a>(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs
437437

438438
for attr in attrs {
439439
if let AttrKind::DocComment(comment_kind, comment) = attr.kind {
440-
let (comment, current_spans) = strip_doc_comment_decoration(&comment.as_str(), comment_kind, attr.span);
440+
let (comment, current_spans) = strip_doc_comment_decoration(comment.as_str(), comment_kind, attr.span);
441441
spans.extend_from_slice(&current_spans);
442442
doc.push_str(&comment);
443443
} else if attr.has_name(sym::doc) {

Diff for: clippy_lints/src/duration_subsec.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl<'tcx> LateLintPass<'tcx> for DurationSubsec {
4949
if match_type(cx, cx.typeck_results().expr_ty(&args[0]).peel_refs(), &paths::DURATION);
5050
if let Some((Constant::Int(divisor), _)) = constant(cx, cx.typeck_results(), right);
5151
then {
52-
let suggested_fn = match (method_path.ident.as_str().as_ref(), divisor) {
52+
let suggested_fn = match (method_path.ident.as_str(), divisor) {
5353
("subsec_micros", 1_000) | ("subsec_nanos", 1_000_000) => "subsec_millis",
5454
("subsec_nanos", 1_000) => "subsec_micros",
5555
_ => return,

Diff for: clippy_lints/src/enum_variants.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn check_enum_start(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>
130130
let name = variant.ident.name.as_str();
131131
let item_name_chars = item_name.chars().count();
132132

133-
if count_match_start(item_name, &name).char_count == item_name_chars
133+
if count_match_start(item_name, name).char_count == item_name_chars
134134
&& name.chars().nth(item_name_chars).map_or(false, |c| !c.is_lowercase())
135135
&& name.chars().nth(item_name_chars + 1).map_or(false, |c| !c.is_numeric())
136136
{
@@ -147,7 +147,7 @@ fn check_enum_end(cx: &LateContext<'_>, item_name: &str, variant: &Variant<'_>)
147147
let name = variant.ident.name.as_str();
148148
let item_name_chars = item_name.chars().count();
149149

150-
if count_match_end(item_name, &name).char_count == item_name_chars {
150+
if count_match_end(item_name, name).char_count == item_name_chars {
151151
span_lint(
152152
cx,
153153
ENUM_VARIANT_NAMES,
@@ -171,7 +171,7 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
171171
check_enum_end(cx, item_name, var);
172172
let name = var.ident.name.as_str();
173173

174-
let variant_split = camel_case_split(&name);
174+
let variant_split = camel_case_split(name);
175175

176176
pre = pre
177177
.iter()
@@ -240,7 +240,7 @@ impl LateLintPass<'_> for EnumVariantNames {
240240
#[allow(clippy::similar_names)]
241241
fn check_item(&mut self, cx: &LateContext<'_>, item: &Item<'_>) {
242242
let item_name = item.ident.name.as_str();
243-
let item_camel = to_camel_case(&item_name);
243+
let item_camel = to_camel_case(item_name);
244244
if !item.span.from_expansion() && is_present_in_source(cx, item.span) {
245245
if let Some(&(ref mod_name, ref mod_camel)) = self.modules.last() {
246246
// constants don't have surrounding modules
@@ -289,7 +289,7 @@ impl LateLintPass<'_> for EnumVariantNames {
289289
}
290290
if let ItemKind::Enum(ref def, _) = item.kind {
291291
if !(self.avoid_breaking_exported_api && cx.access_levels.is_exported(item.def_id)) {
292-
check_variant(cx, self.threshold, def, &item_name, item.span);
292+
check_variant(cx, self.threshold, def, item_name, item.span);
293293
}
294294
}
295295
self.modules.push((item.ident.name, item_camel));

Diff for: clippy_lints/src/equatable_if_let.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,20 @@ fn is_structural_partial_eq(cx: &LateContext<'tcx>, ty: Ty<'tcx>, other: Ty<'tcx
6767
impl<'tcx> LateLintPass<'tcx> for PatternEquality {
6868
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
6969
if_chain! {
70-
if let ExprKind::Let(pat, exp, _) = expr.kind;
71-
if unary_pattern(pat);
72-
let exp_ty = cx.typeck_results().expr_ty(exp);
73-
let pat_ty = cx.typeck_results().pat_ty(pat);
70+
if let ExprKind::Let(let_expr) = expr.kind;
71+
if unary_pattern(let_expr.pat);
72+
let exp_ty = cx.typeck_results().expr_ty(let_expr.init);
73+
let pat_ty = cx.typeck_results().pat_ty(let_expr.pat);
7474
if is_structural_partial_eq(cx, exp_ty, pat_ty);
7575
then {
7676

7777
let mut applicability = Applicability::MachineApplicable;
78-
let pat_str = match pat.kind {
78+
let pat_str = match let_expr.pat.kind {
7979
PatKind::Struct(..) => format!(
8080
"({})",
81-
snippet_with_context(cx, pat.span, expr.span.ctxt(), "..", &mut applicability).0,
81+
snippet_with_context(cx, let_expr.pat.span, expr.span.ctxt(), "..", &mut applicability).0,
8282
),
83-
_ => snippet_with_context(cx, pat.span, expr.span.ctxt(), "..", &mut applicability).0.to_string(),
83+
_ => snippet_with_context(cx, let_expr.pat.span, expr.span.ctxt(), "..", &mut applicability).0.to_string(),
8484
};
8585
span_lint_and_sugg(
8686
cx,
@@ -90,7 +90,7 @@ impl<'tcx> LateLintPass<'tcx> for PatternEquality {
9090
"try",
9191
format!(
9292
"{} == {}",
93-
snippet_with_context(cx, exp.span, expr.span.ctxt(), "..", &mut applicability).0,
93+
snippet_with_context(cx, let_expr.init.span, expr.span.ctxt(), "..", &mut applicability).0,
9494
pat_str,
9595
),
9696
applicability,

Diff for: clippy_lints/src/float_literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ impl<'tcx> LateLintPass<'tcx> for FloatLiteral {
6868
if let LitKind::Float(sym, lit_float_ty) = lit.node;
6969
then {
7070
let sym_str = sym.as_str();
71-
let formatter = FloatFormat::new(&sym_str);
71+
let formatter = FloatFormat::new(sym_str);
7272
// Try to bail out if the float is for sure fine.
7373
// If its within the 2 decimal digits of being out of precision we
7474
// check if the parsed representation is the same as the string
7575
// since we'll need the truncated string anyway.
76-
let digits = count_digits(&sym_str);
76+
let digits = count_digits(sym_str);
7777
let max = max_digits(fty);
7878
let type_suffix = match lit_float_ty {
7979
LitFloatType::Suffixed(ast::FloatTy::F32) => Some("f32"),

Diff for: clippy_lints/src/floating_point_arithmetic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ fn are_same_base_logs(cx: &LateContext<'_>, expr_a: &Expr<'_>, expr_b: &Expr<'_>
595595
return method_name_a.as_str() == method_name_b.as_str() &&
596596
args_a.len() == args_b.len() &&
597597
(
598-
["ln", "log2", "log10"].contains(&&*method_name_a.as_str()) ||
598+
["ln", "log2", "log10"].contains(&method_name_a.as_str()) ||
599599
method_name_a.as_str() == "log" && args_a.len() == 2 && eq_expr_value(cx, &args_a[1], &args_b[1])
600600
);
601601
}
@@ -718,7 +718,7 @@ impl<'tcx> LateLintPass<'tcx> for FloatingPointArithmetic {
718718
let recv_ty = cx.typeck_results().expr_ty(&args[0]);
719719

720720
if recv_ty.is_floating_point() {
721-
match &*path.ident.name.as_str() {
721+
match path.ident.name.as_str() {
722722
"ln" => check_ln1p(cx, expr, args),
723723
"log" => check_log_base(cx, expr, args),
724724
"powf" => check_powf(cx, expr, args),

Diff for: clippy_lints/src/implicit_saturating_sub.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
9696
if let LitKind::Int(0, _) = cond_lit.node {
9797
if cx.typeck_results().expr_ty(cond_left).is_signed() {
9898
} else {
99-
print_lint_and_sugg(cx, &var_name, expr);
99+
print_lint_and_sugg(cx, var_name, expr);
100100
};
101101
}
102102
},
@@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
108108
let mut int_ids = INT_TYPES.iter().filter_map(|&ty| cx.tcx.lang_items().require(ty).ok());
109109
if int_ids.any(|int_id| int_id == impl_id);
110110
then {
111-
print_lint_and_sugg(cx, &var_name, expr)
111+
print_lint_and_sugg(cx, var_name, expr)
112112
}
113113
}
114114
},
@@ -121,7 +121,7 @@ impl<'tcx> LateLintPass<'tcx> for ImplicitSaturatingSub {
121121
let mut int_ids = INT_TYPES.iter().filter_map(|&ty| cx.tcx.lang_items().require(ty).ok());
122122
if int_ids.any(|int_id| int_id == impl_id);
123123
then {
124-
print_lint_and_sugg(cx, &var_name, expr)
124+
print_lint_and_sugg(cx, var_name, expr)
125125
}
126126
}
127127
},

Diff for: clippy_lints/src/iter_not_returning_iterator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare_lint_pass!(IterNotReturningIterator => [ITER_NOT_RETURNING_ITERATOR]);
4242

4343
impl LateLintPass<'_> for IterNotReturningIterator {
4444
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx ImplItem<'tcx>) {
45-
let name: &str = &impl_item.ident.name.as_str();
45+
let name = impl_item.ident.name.as_str();
4646
if_chain! {
4747
if let ImplItemKind::Fn(fn_sig, _) = &impl_item.kind;
4848
let ret_ty = return_ty(cx, impl_item.hir_id());

Diff for: clippy_lints/src/len_zero.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ fn is_empty_string(expr: &Expr<'_>) -> bool {
441441
if let ExprKind::Lit(ref lit) = expr.kind {
442442
if let LitKind::Str(lit, _) = lit.node {
443443
let lit = lit.as_str();
444-
return lit == "";
444+
return lit.is_empty();
445445
}
446446
}
447447
false

Diff for: clippy_lints/src/loops/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn check_for_loop_arg(cx: &LateContext<'_>, pat: &Pat<'_>, arg: &Expr<'_>) {
659659
let mut next_loop_linted = false; // whether or not ITER_NEXT_LOOP lint was used
660660

661661
if let ExprKind::MethodCall(method, _, [self_arg], _) = arg.kind {
662-
let method_name = &*method.ident.as_str();
662+
let method_name = method.ident.as_str();
663663
// check for looping over x.iter() or x.iter_mut(), could use &x or &mut x
664664
match method_name {
665665
"iter" | "iter_mut" => explicit_iter_loop::check(cx, self_arg, arg, method_name),

Diff for: clippy_lints/src/loops/needless_collect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn check_needless_collect_direct_usage<'tcx>(expr: &'tcx Expr<'_>, cx: &LateCont
3131
let ty = cx.typeck_results().expr_ty(&args[0]);
3232
let mut applicability = Applicability::MaybeIncorrect;
3333
let is_empty_sugg = "next().is_none()".to_string();
34-
let method_name = &*method.ident.name.as_str();
34+
let method_name = method.ident.name.as_str();
3535
let sugg = if is_type_diagnostic_item(cx, ty, sym::Vec) ||
3636
is_type_diagnostic_item(cx, ty, sym::VecDeque) ||
3737
is_type_diagnostic_item(cx, ty, sym::LinkedList) ||
@@ -210,7 +210,7 @@ impl<'tcx> Visitor<'tcx> for IterFunctionVisitor<'_, 'tcx> {
210210
if let Some(hir_id) = self.current_statement_hir_id {
211211
self.hir_id_uses_map.insert(hir_id, self.uses.len());
212212
}
213-
match &*method_name.ident.name.as_str() {
213+
match method_name.ident.name.as_str() {
214214
"into_iter" => self.uses.push(Some(IterFunction {
215215
func: IterFunctionKind::IntoIter,
216216
span: expr.span,

Diff for: clippy_lints/src/loops/never_loop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,12 @@ fn never_loop_expr(expr: &Expr<'_>, main_loop_id: HirId) -> NeverLoopResult {
115115
| ExprKind::Unary(_, e)
116116
| ExprKind::Cast(e, _)
117117
| ExprKind::Type(e, _)
118-
| ExprKind::Let(_, e, _)
119118
| ExprKind::Field(e, _)
120119
| ExprKind::AddrOf(_, _, e)
121120
| ExprKind::Struct(_, _, Some(e))
122121
| ExprKind::Repeat(e, _)
123122
| ExprKind::DropTemps(e) => never_loop_expr(e, main_loop_id),
123+
ExprKind::Let(let_expr) => never_loop_expr(let_expr.init, main_loop_id),
124124
ExprKind::Array(es) | ExprKind::MethodCall(_, _, es, _) | ExprKind::Tup(es) => {
125125
never_loop_expr_all(&mut es.iter(), main_loop_id)
126126
},

Diff for: clippy_lints/src/manual_assert.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ impl LateLintPass<'_> for ManualAssert {
5050
..
5151
} = &expr;
5252
if is_expn_of(stmt.span, "panic").is_some();
53-
if !matches!(cond.kind, ExprKind::Let(_, _, _));
53+
if !matches!(cond.kind, ExprKind::Let(_));
5454
if let StmtKind::Semi(semi) = stmt.kind;
5555
if !cx.tcx.sess.source_map().is_multiline(cond.span);
5656

0 commit comments

Comments
 (0)