Skip to content

Commit f5db61f

Browse files
author
Daniel Smith
committed
Merge remote-tracking branch 'upstream/master' into refcell_ref_await
2 parents e170ebd + f96c47e commit f5db61f

File tree

12 files changed

+60
-50
lines changed

12 files changed

+60
-50
lines changed

clippy_lints/src/bit_mask.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ declare_clippy_lint! {
9090
/// if x & 0b1111 == 0 { }
9191
/// ```
9292
pub VERBOSE_BIT_MASK,
93-
style,
93+
pedantic,
9494
"expressions where a bit mask is less readable than the corresponding method call"
9595
}
9696

clippy_lints/src/enum_variants.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl EarlyLintPass for EnumVariantNames {
285285
);
286286
}
287287
}
288-
if item.vis.node.is_pub() {
288+
if item.vis.kind.is_pub() {
289289
let matching = partial_match(mod_camel, &item_camel);
290290
let rmatching = partial_rmatch(mod_camel, &item_camel);
291291
let nchars = mod_camel.chars().count();
@@ -316,7 +316,7 @@ impl EarlyLintPass for EnumVariantNames {
316316
}
317317
}
318318
if let ItemKind::Enum(ref def, _) = item.kind {
319-
let lint = match item.vis.node {
319+
let lint = match item.vis.kind {
320320
VisibilityKind::Public => PUB_ENUM_VARIANT_NAMES,
321321
_ => ENUM_VARIANT_NAMES,
322322
};

clippy_lints/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,6 +1161,7 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
11611161
LintId::of(&attrs::INLINE_ALWAYS),
11621162
LintId::of(&await_holding_lock::AWAIT_HOLDING_LOCK),
11631163
LintId::of(&await_holding_refcell_ref::AWAIT_HOLDING_REFCELL_REF),
1164+
LintId::of(&bit_mask::VERBOSE_BIT_MASK),
11641165
LintId::of(&checked_conversions::CHECKED_CONVERSIONS),
11651166
LintId::of(&copies::MATCH_SAME_ARMS),
11661167
LintId::of(&copies::SAME_FUNCTIONS_IN_IF_CONDITION),
@@ -1258,7 +1259,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
12581259
LintId::of(&attrs::USELESS_ATTRIBUTE),
12591260
LintId::of(&bit_mask::BAD_BIT_MASK),
12601261
LintId::of(&bit_mask::INEFFECTIVE_BIT_MASK),
1261-
LintId::of(&bit_mask::VERBOSE_BIT_MASK),
12621262
LintId::of(&blacklisted_name::BLACKLISTED_NAME),
12631263
LintId::of(&blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS),
12641264
LintId::of(&booleans::LOGIC_BUG),
@@ -1516,7 +1516,6 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf:
15161516
LintId::of(&assign_ops::ASSIGN_OP_PATTERN),
15171517
LintId::of(&attrs::BLANKET_CLIPPY_RESTRICTION_LINTS),
15181518
LintId::of(&attrs::UNKNOWN_CLIPPY_LINTS),
1519-
LintId::of(&bit_mask::VERBOSE_BIT_MASK),
15201519
LintId::of(&blacklisted_name::BLACKLISTED_NAME),
15211520
LintId::of(&blocks_in_if_conditions::BLOCKS_IN_IF_CONDITIONS),
15221521
LintId::of(&collapsible_if::COLLAPSIBLE_IF),

clippy_lints/src/manual_non_exhaustive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn check_manual_non_exhaustive_enum(cx: &EarlyContext<'_>, item: &Item, variants
122122

123123
fn check_manual_non_exhaustive_struct(cx: &EarlyContext<'_>, item: &Item, data: &VariantData) {
124124
fn is_private(field: &StructField) -> bool {
125-
matches!(field.vis.node, VisibilityKind::Inherited)
125+
matches!(field.vis.kind, VisibilityKind::Inherited)
126126
}
127127

128128
fn is_non_exhaustive_marker(field: &StructField) -> bool {
@@ -141,7 +141,7 @@ fn check_manual_non_exhaustive_struct(cx: &EarlyContext<'_>, item: &Item, data:
141141

142142
let fields = data.fields();
143143
let private_fields = fields.iter().filter(|f| is_private(f)).count();
144-
let public_fields = fields.iter().filter(|f| f.vis.node.is_pub()).count();
144+
let public_fields = fields.iter().filter(|f| f.vis.kind.is_pub()).count();
145145

146146
if_chain! {
147147
if private_fields == 1 && public_fields >= 1 && public_fields == fields.len() - 1;

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3374,7 +3374,7 @@ fn lint_into_iter(cx: &LateContext<'_>, expr: &hir::Expr<'_>, self_ref_ty: Ty<'_
33743374
INTO_ITER_ON_REF,
33753375
method_span,
33763376
&format!(
3377-
"this `.into_iter()` call is equivalent to `.{}()` and will not move the `{}`",
3377+
"this `.into_iter()` call is equivalent to `.{}()` and will not consume the `{}`",
33783378
method_name, kind,
33793379
),
33803380
"call directly",

clippy_lints/src/single_component_path_imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl EarlyLintPass for SingleComponentPathImports {
4141
if_chain! {
4242
if !in_macro(item.span);
4343
if cx.sess.opts.edition == Edition::Edition2018;
44-
if !item.vis.node.is_pub();
44+
if !item.vis.kind.is_pub();
4545
if let ItemKind::Use(use_tree) = &item.kind;
4646
if let segments = &use_tree.prefix.segments;
4747
if segments.len() == 1;

clippy_lints/src/types.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -321,14 +321,15 @@ impl Types {
321321
if let Some(def_id) = res.opt_def_id() {
322322
if Some(def_id) == cx.tcx.lang_items().owned_box() {
323323
if let Some(span) = match_borrows_parameter(cx, qpath) {
324+
let mut applicability = Applicability::MachineApplicable;
324325
span_lint_and_sugg(
325326
cx,
326327
REDUNDANT_ALLOCATION,
327328
hir_ty.span,
328329
"usage of `Box<&T>`",
329330
"try",
330-
snippet(cx, span, "..").to_string(),
331-
Applicability::MachineApplicable,
331+
snippet_with_applicability(cx, span, "..", &mut applicability).to_string(),
332+
applicability,
332333
);
333334
return; // don't recurse into the type
334335
}
@@ -345,14 +346,15 @@ impl Types {
345346
}
346347
} else if cx.tcx.is_diagnostic_item(sym::Rc, def_id) {
347348
if let Some(span) = match_type_parameter(cx, qpath, &paths::RC) {
349+
let mut applicability = Applicability::MachineApplicable;
348350
span_lint_and_sugg(
349351
cx,
350352
REDUNDANT_ALLOCATION,
351353
hir_ty.span,
352354
"usage of `Rc<Rc<T>>`",
353355
"try",
354-
snippet(cx, span, "..").to_string(),
355-
Applicability::MachineApplicable,
356+
snippet_with_applicability(cx, span, "..", &mut applicability).to_string(),
357+
applicability,
356358
);
357359
return; // don't recurse into the type
358360
}
@@ -368,26 +370,31 @@ impl Types {
368370
GenericArg::Type(ty) => ty.span,
369371
_ => return,
370372
};
373+
let mut applicability = Applicability::MachineApplicable;
371374
span_lint_and_sugg(
372375
cx,
373376
REDUNDANT_ALLOCATION,
374377
hir_ty.span,
375378
"usage of `Rc<Box<T>>`",
376379
"try",
377-
format!("Rc<{}>", snippet(cx, inner_span, "..")),
378-
Applicability::MachineApplicable,
380+
format!(
381+
"Rc<{}>",
382+
snippet_with_applicability(cx, inner_span, "..", &mut applicability)
383+
),
384+
applicability,
379385
);
380386
return; // don't recurse into the type
381387
}
382388
if let Some(span) = match_borrows_parameter(cx, qpath) {
389+
let mut applicability = Applicability::MachineApplicable;
383390
span_lint_and_sugg(
384391
cx,
385392
REDUNDANT_ALLOCATION,
386393
hir_ty.span,
387394
"usage of `Rc<&T>`",
388395
"try",
389-
snippet(cx, span, "..").to_string(),
390-
Applicability::MachineApplicable,
396+
snippet_with_applicability(cx, span, "..", &mut applicability).to_string(),
397+
applicability,
391398
);
392399
return; // don't recurse into the type
393400
}
@@ -546,7 +553,6 @@ impl Types {
546553
// details.
547554
return;
548555
}
549-
let mut applicability = Applicability::MachineApplicable;
550556
span_lint_and_sugg(
551557
cx,
552558
BORROWED_BOX,
@@ -556,8 +562,12 @@ impl Types {
556562
format!(
557563
"&{}{}",
558564
ltopt,
559-
&snippet_with_applicability(cx, inner.span, "..", &mut applicability)
565+
&snippet(cx, inner.span, "..")
560566
),
567+
// To make this `MachineApplicable`, at least one needs to check if it isn't a trait item
568+
// because the trait impls of it will break otherwise;
569+
// and there may be other cases that result in invalid code.
570+
// For example, type coercion doesn't work nicely.
561571
Applicability::Unspecified,
562572
);
563573
return; // don't recurse into the type

clippy_lints/src/utils/ast_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ pub fn eq_defaultness(l: Defaultness, r: Defaultness) -> bool {
394394

395395
pub fn eq_vis(l: &Visibility, r: &Visibility) -> bool {
396396
use VisibilityKind::*;
397-
match (&l.node, &r.node) {
397+
match (&l.kind, &r.kind) {
398398
(Public, Public) | (Inherited, Inherited) | (Crate(_), Crate(_)) => true,
399399
(Restricted { path: l, .. }, Restricted { path: r, .. }) => eq_path(l, r),
400400
_ => false,

src/lintlist/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ pub static ref ALL_LINTS: Vec<Lint> = vec![
26442644
},
26452645
Lint {
26462646
name: "verbose_bit_mask",
2647-
group: "style",
2647+
group: "pedantic",
26482648
desc: "expressions where a bit mask is less readable than the corresponding method call",
26492649
deprecation: None,
26502650
module: "bit_mask",

0 commit comments

Comments
 (0)