From 1090509564b129886db8629bcab4cb46e46f9041 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Wed, 25 Sep 2019 05:39:56 -0700 Subject: [PATCH] non_copy_const: remove incorrect suggestion --- clippy_lints/src/non_copy_const.rs | 10 +---- tests/ui/non_copy_const.stderr | 66 ++++++++++-------------------- 2 files changed, 23 insertions(+), 53 deletions(-) diff --git a/clippy_lints/src/non_copy_const.rs b/clippy_lints/src/non_copy_const.rs index 992baa05e78..90a31f710f4 100644 --- a/clippy_lints/src/non_copy_const.rs +++ b/clippy_lints/src/non_copy_const.rs @@ -10,7 +10,6 @@ use rustc::lint::{LateContext, LateLintPass, Lint, LintArray, LintPass}; use rustc::ty::adjustment::Adjust; use rustc::ty::{Ty, TypeFlags}; use rustc::{declare_lint_pass, declare_tool_lint}; -use rustc_errors::Applicability; use rustc_typeck::hir_ty_to_ty; use syntax_pos::{InnerSpan, Span, DUMMY_SP}; @@ -125,16 +124,11 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: S match source { Source::Item { .. } => { let const_kw_span = span.from_inner(InnerSpan::new(0, 5)); - db.span_suggestion( - const_kw_span, - "make this a static item", - "static".to_string(), - Applicability::MachineApplicable, - ); + db.span_label(const_kw_span, "make this a static item (maybe with lazy_static)"); }, Source::Assoc { ty: ty_span, .. } => { if ty.flags.contains(TypeFlags::HAS_FREE_LOCAL_NAMES) { - db.span_help(ty_span, &format!("consider requiring `{}` to be `Copy`", ty)); + db.span_label(ty_span, &format!("consider requiring `{}` to be `Copy`", ty)); } }, Source::Expr { .. } => { diff --git a/tests/ui/non_copy_const.stderr b/tests/ui/non_copy_const.stderr index 2f325f9e3df..0568386f889 100644 --- a/tests/ui/non_copy_const.stderr +++ b/tests/ui/non_copy_const.stderr @@ -4,7 +4,7 @@ error: a const item should never be interior mutable LL | const ATOMIC: AtomicUsize = AtomicUsize::new(5); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | help: make this a static item: `static` + | make this a static item (maybe with lazy_static) | = note: `#[deny(clippy::declare_interior_mutable_const)]` on by default @@ -14,7 +14,7 @@ error: a const item should never be interior mutable LL | const CELL: Cell = Cell::new(6); //~ ERROR interior mutable | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | help: make this a static item: `static` + | make this a static item (maybe with lazy_static) error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:11:1 @@ -22,7 +22,7 @@ error: a const item should never be interior mutable LL | const ATOMIC_TUPLE: ([AtomicUsize; 1], Vec, u8) = ([ATOMIC], Vec::new(), 7); | -----^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | - | help: make this a static item: `static` + | make this a static item (maybe with lazy_static) error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:16:9 @@ -43,37 +43,25 @@ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:44:5 | LL | const INPUT: T; - | ^^^^^^^^^^^^^^^ - | -help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:44:18 - | -LL | const INPUT: T; - | ^ + | ^^^^^^^^^^^^^-^ + | | + | consider requiring `T` to be `Copy` error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:47:5 | LL | const ASSOC: Self::NonCopyType; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:47:18 - | -LL | const ASSOC: Self::NonCopyType; - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^-----------------^ + | | + | consider requiring `>::NonCopyType` to be `Copy` error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:51:5 | LL | const AN_INPUT: T = Self::INPUT; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider requiring `T` to be `Copy` - --> $DIR/non_copy_const.rs:51:21 - | -LL | const AN_INPUT: T = Self::INPUT; - | ^ + | ^^^^^^^^^^^^^^^^-^^^^^^^^^^^^^^^ + | | + | consider requiring `T` to be `Copy` error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:16:9 @@ -88,13 +76,9 @@ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:60:5 | LL | const SELF_2: Self; - | ^^^^^^^^^^^^^^^^^^^ - | -help: consider requiring `Self` to be `Copy` - --> $DIR/non_copy_const.rs:60:19 - | -LL | const SELF_2: Self; - | ^^^^ + | ^^^^^^^^^^^^^^----^ + | | + | consider requiring `Self` to be `Copy` error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:81:5 @@ -106,25 +90,17 @@ error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:84:5 | LL | const U_SELF: U = U::SELF_2; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider requiring `U` to be `Copy` - --> $DIR/non_copy_const.rs:84:19 - | -LL | const U_SELF: U = U::SELF_2; - | ^ + | ^^^^^^^^^^^^^^-^^^^^^^^^^^^^ + | | + | consider requiring `U` to be `Copy` error: a const item should never be interior mutable --> $DIR/non_copy_const.rs:87:5 | LL | const T_ASSOC: T::NonCopyType = T::ASSOC; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: consider requiring `>::NonCopyType` to be `Copy` - --> $DIR/non_copy_const.rs:87:20 - | -LL | const T_ASSOC: T::NonCopyType = T::ASSOC; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^--------------^^^^^^^^^^^^ + | | + | consider requiring `>::NonCopyType` to be `Copy` error: a const item with interior mutability should not be borrowed --> $DIR/non_copy_const.rs:94:5