Skip to content

Commit 7c21f91

Browse files
committed
Auto merge of rust-lang#8788 - flip1995:rustup, r=xFrednet,flip1995
Rustup r? `@ghost` changelog: move trait_duplication_in_bounds and type_repetition_in_bounds to nursery temporarily. This could already be reverted before the release. Check the Clippy in the Rust repo beta branch when writing this changelog.
2 parents c7a705a + 0062829 commit 7c21f91

Some content is hidden

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

62 files changed

+316
-276
lines changed

clippy_dev/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ indoc = "1.0"
1010
itertools = "0.10.1"
1111
opener = "0.5"
1212
shell-escape = "0.1"
13-
tempfile = "3.3"
13+
tempfile = "3.2"
1414
walkdir = "2.3"
1515

1616
[features]

clippy_lints/src/attrs.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use clippy_utils::msrvs;
66
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
77
use clippy_utils::{extract_msrv_attr, meets_msrv};
88
use if_chain::if_chain;
9-
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem};
9+
use rustc_ast::{AttrKind, AttrStyle, Attribute, Lit, LitKind, MacArgs, MacArgsEq, MetaItemKind, NestedMetaItem};
1010
use rustc_errors::Applicability;
1111
use rustc_hir::{
1212
Block, Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, StmtKind, TraitFn, TraitItem, TraitItemKind,
@@ -593,6 +593,10 @@ fn check_empty_line_after_outer_attr(cx: &EarlyContext<'_>, item: &rustc_ast::It
593593
};
594594

595595
if attr.style == AttrStyle::Outer {
596+
if let MacArgs::Eq(_, MacArgsEq::Ast(expr)) = &attr_item.args
597+
&& !matches!(expr.kind, rustc_ast::ExprKind::Lit(..)) {
598+
return;
599+
}
596600
if attr_item.args.inner_tokens().is_empty() || !is_present_in_source(cx, attr.span) {
597601
return;
598602
}

clippy_lints/src/case_sensitive_file_extension_comparisons.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use if_chain::if_chain;
33
use rustc_ast::ast::LitKind;
4-
use rustc_data_structures::intern::Interned;
54
use rustc_hir::{Expr, ExprKind, PathSegment};
65
use rustc_lint::{LateContext, LateLintPass};
76
use rustc_middle::ty;
@@ -56,8 +55,8 @@ fn check_case_sensitive_file_extension_comparison(ctx: &LateContext<'_>, expr: &
5655
ty::Str => {
5756
return Some(span);
5857
},
59-
ty::Adt(ty::AdtDef(Interned(&ty::AdtDefData { did, .. }, _)), _) => {
60-
if ctx.tcx.is_diagnostic_item(sym::String, did) {
58+
ty::Adt(def, _) => {
59+
if ctx.tcx.is_diagnostic_item(sym::String, def.did()) {
6160
return Some(span);
6261
}
6362
},

clippy_lints/src/cognitive_complexity.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl CognitiveComplexity {
8282

8383
if rust_cc > self.limit.limit() {
8484
let fn_span = match kind {
85-
FnKind::ItemFn(ident, _, _, _) | FnKind::Method(ident, _, _) => ident.span,
85+
FnKind::ItemFn(ident, _, _) | FnKind::Method(ident, _) => ident.span,
8686
FnKind::Closure => {
8787
let header_span = body_span.with_hi(decl.output.span().lo());
8888
let pos = snippet_opt(cx, header_span).and_then(|snip| {

clippy_lints/src/doc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
240240
lint_for_missing_headers(cx, item.def_id, item.span, sig, headers, Some(body_id), fpu.panic_span);
241241
}
242242
},
243-
hir::ItemKind::Impl(ref impl_) => {
243+
hir::ItemKind::Impl(impl_) => {
244244
self.in_trait_impl = impl_.of_trait.is_some();
245245
},
246246
hir::ItemKind::Trait(_, unsafety, ..) => {
@@ -622,7 +622,7 @@ fn check_code(cx: &LateContext<'_>, text: &str, edition: Edition, span: Span) {
622622

623623
let sm = Lrc::new(SourceMap::new(FilePathMapping::empty()));
624624
let fallback_bundle =
625-
rustc_errors::fallback_fluent_bundle(false).expect("failed to load fallback fluent bundle");
625+
rustc_errors::fallback_fluent_bundle(rustc_errors::DEFAULT_LOCALE_RESOURCES, false);
626626
let emitter = EmitterWriter::new(
627627
Box::new(io::sink()),
628628
None,

clippy_lints/src/enum_variants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ impl LateLintPass<'_> for EnumVariantNames {
260260
}
261261
// The `module_name_repetitions` lint should only trigger if the item has the module in its
262262
// name. Having the same name is accepted.
263-
if item.vis.node.is_pub() && item_camel.len() > mod_camel.len() {
263+
if cx.tcx.visibility(item.def_id).is_public() && item_camel.len() > mod_camel.len() {
264264
let matching = count_match_start(mod_camel, &item_camel);
265265
let rmatching = count_match_end(mod_camel, &item_camel);
266266
let nchars = mod_camel.chars().count();

clippy_lints/src/exhaustive_items.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ impl LateLintPass<'_> for ExhaustiveItems {
7878
if !attrs.iter().any(|a| a.has_name(sym::non_exhaustive));
7979
then {
8080
let (lint, msg) = if let ItemKind::Struct(ref v, ..) = item.kind {
81-
if v.fields().iter().any(|f| !f.vis.node.is_pub()) {
81+
if v.fields().iter().any(|f| {
82+
let def_id = cx.tcx.hir().local_def_id(f.hir_id);
83+
!cx.tcx.visibility(def_id).is_public()
84+
}) {
8285
// skip structs with private fields
8386
return;
8487
}

clippy_lints/src/functions/must_use.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::{DOUBLE_MUST_USE, MUST_USE_CANDIDATE, MUST_USE_UNIT};
2020
pub(super) fn check_item<'tcx>(cx: &LateContext<'tcx>, item: &'tcx hir::Item<'_>) {
2121
let attrs = cx.tcx.hir().attrs(item.hir_id());
2222
let attr = must_use_attr(attrs);
23-
if let hir::ItemKind::Fn(ref sig, ref _generics, ref body_id) = item.kind {
23+
if let hir::ItemKind::Fn(ref sig, _generics, ref body_id) = item.kind {
2424
let is_public = cx.access_levels.is_exported(item.def_id);
2525
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
2626
if let Some(attr) = attr {
@@ -105,12 +105,7 @@ fn check_needless_must_use(
105105
fn_header_span,
106106
"this unit-returning function has a `#[must_use]` attribute",
107107
|diag| {
108-
diag.span_suggestion(
109-
attr.span,
110-
"remove the attribute",
111-
"".into(),
112-
Applicability::MachineApplicable,
113-
);
108+
diag.span_suggestion(attr.span, "remove the attribute", "", Applicability::MachineApplicable);
114109
},
115110
);
116111
} else if attr.value_str().is_none() && is_must_use_ty(cx, return_ty(cx, item_id)) {

clippy_lints/src/functions/not_unsafe_ptr_arg_deref.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ pub(super) fn check_fn<'tcx>(
1717
hir_id: hir::HirId,
1818
) {
1919
let unsafety = match kind {
20-
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }, _) => unsafety,
21-
intravisit::FnKind::Method(_, sig, _) => sig.header.unsafety,
20+
intravisit::FnKind::ItemFn(_, _, hir::FnHeader { unsafety, .. }) => unsafety,
21+
intravisit::FnKind::Method(_, sig) => sig.header.unsafety,
2222
intravisit::FnKind::Closure => return,
2323
};
2424

clippy_lints/src/functions/result_unit_err.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use clippy_utils::ty::is_type_diagnostic_item;
1414
use super::RESULT_UNIT_ERR;
1515

1616
pub(super) fn check_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
17-
if let hir::ItemKind::Fn(ref sig, ref _generics, _) = item.kind {
17+
if let hir::ItemKind::Fn(ref sig, _generics, _) = item.kind {
1818
let is_public = cx.access_levels.is_exported(item.def_id);
1919
let fn_header_span = item.span.with_hi(sig.decl.output.span().hi());
2020
if is_public {

0 commit comments

Comments
 (0)