|
1 |
| -// Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT |
2 |
| -// file at the top-level directory of this distribution. |
3 |
| -// |
4 |
| -// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or |
5 |
| -// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license |
6 |
| -// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your |
7 |
| -// option. This file may not be copied, modified, or distributed |
8 |
| -// except according to those terms. |
9 |
| - |
10 | 1 | //! checks for attributes
|
11 | 2 |
|
12 | 3 | use crate::reexport::*;
|
@@ -341,9 +332,12 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
|
341 | 332 | // https://github.com/rust-lang/rust/pull/56992
|
342 | 333 | CheckLintNameResult::NoLint(None) => (),
|
343 | 334 | _ => {
|
344 |
| - db.span_suggestion(lint.span, |
345 |
| - "lowercase the lint name", |
346 |
| - name_lower); |
| 335 | + db.span_suggestion_with_applicability( |
| 336 | + lint.span, |
| 337 | + "lowercase the lint name", |
| 338 | + name_lower, |
| 339 | + Applicability::MaybeIncorrect, |
| 340 | + ); |
347 | 341 | }
|
348 | 342 | }
|
349 | 343 | }
|
@@ -382,8 +376,9 @@ fn is_relevant_trait(tcx: TyCtxt<'_, '_, '_>, item: &TraitItem) -> bool {
|
382 | 376 | fn is_relevant_block(tcx: TyCtxt<'_, '_, '_>, tables: &ty::TypeckTables<'_>, block: &Block) -> bool {
|
383 | 377 | if let Some(stmt) = block.stmts.first() {
|
384 | 378 | match &stmt.node {
|
385 |
| - StmtKind::Decl(_, _) => true, |
386 |
| - StmtKind::Expr(expr, _) | StmtKind::Semi(expr, _) => is_relevant_expr(tcx, tables, expr), |
| 379 | + StmtKind::Local(_) => true, |
| 380 | + StmtKind::Expr(expr) | StmtKind::Semi(expr) => is_relevant_expr(tcx, tables, expr), |
| 381 | + _ => false, |
387 | 382 | }
|
388 | 383 | } else {
|
389 | 384 | block.expr.as_ref().map_or(false, |e| is_relevant_expr(tcx, tables, e))
|
@@ -520,18 +515,17 @@ impl EarlyLintPass for CfgAttrPass {
|
520 | 515 | // check for `rustfmt_skip` and `rustfmt::skip`
|
521 | 516 | if let Some(skip_item) = &items[1].meta_item();
|
522 | 517 | if skip_item.name() == "rustfmt_skip" || skip_item.name() == "skip";
|
| 518 | + // Only lint outer attributes, because custom inner attributes are unstable |
| 519 | + // Tracking issue: https://github.com/rust-lang/rust/issues/54726 |
| 520 | + if let AttrStyle::Outer = attr.style; |
523 | 521 | then {
|
524 |
| - let attr_style = match attr.style { |
525 |
| - AttrStyle::Outer => "#[", |
526 |
| - AttrStyle::Inner => "#![", |
527 |
| - }; |
528 | 522 | span_lint_and_sugg(
|
529 | 523 | cx,
|
530 | 524 | DEPRECATED_CFG_ATTR,
|
531 | 525 | attr.span,
|
532 | 526 | "`cfg_attr` is deprecated for rustfmt and got replaced by tool_attributes",
|
533 | 527 | "use",
|
534 |
| - format!("{}rustfmt::skip]", attr_style), |
| 528 | + "#[rustfmt::skip]".to_string(), |
535 | 529 | Applicability::MachineApplicable,
|
536 | 530 | );
|
537 | 531 | }
|
|
0 commit comments