Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTitor committed Mar 2, 2020
1 parent 0f4a3fe commit 8da094f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions clippy_lints/src/non_copy_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use std::ptr;

use rustc::ty::adjustment::Adjust;
use rustc::ty::{Ty, TypeFlags};
use rustc::ty::{Ty, TypeFoldable};
use rustc_hir::def::{DefKind, Res};
use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind, UnOp};
use rustc_lint::{LateContext, LateLintPass, Lint};
Expand Down Expand Up @@ -128,7 +128,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: S
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) {
if !ty.has_infer_types_or_consts() {
db.span_label(ty_span, &format!("consider requiring `{}` to be `Copy`", ty));
}
},
Expand Down
8 changes: 6 additions & 2 deletions tests/ui/declare_interior_mutable_const.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ error: a `const` item should never be interior mutable
--> $DIR/declare_interior_mutable_const.rs:40:5
|
LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^-----------^
| |
| consider requiring `std::sync::atomic::AtomicUsize` to be `Copy`

error: a `const` item should never be interior mutable
--> $DIR/declare_interior_mutable_const.rs:44:5
Expand Down Expand Up @@ -88,7 +90,9 @@ error: a `const` item should never be interior mutable
--> $DIR/declare_interior_mutable_const.rs:81:5
|
LL | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| ^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^^^^^^^^^^^
| |
| consider requiring `std::sync::atomic::AtomicUsize` to be `Copy`

error: a `const` item should never be interior mutable
--> $DIR/declare_interior_mutable_const.rs:84:5
Expand Down

0 comments on commit 8da094f

Please sign in to comment.