Skip to content

Commit 8da094f

Browse files
committed
1 parent 0f4a3fe commit 8da094f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

Diff for: clippy_lints/src/non_copy_const.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::ptr;
66

77
use rustc::ty::adjustment::Adjust;
8-
use rustc::ty::{Ty, TypeFlags};
8+
use rustc::ty::{Ty, TypeFoldable};
99
use rustc_hir::def::{DefKind, Res};
1010
use rustc_hir::{Expr, ExprKind, ImplItem, ImplItemKind, Item, ItemKind, Node, TraitItem, TraitItemKind, UnOp};
1111
use rustc_lint::{LateContext, LateLintPass, Lint};
@@ -128,7 +128,7 @@ fn verify_ty_bound<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>, source: S
128128
db.span_label(const_kw_span, "make this a static item (maybe with lazy_static)");
129129
},
130130
Source::Assoc { ty: ty_span, .. } => {
131-
if ty.flags.contains(TypeFlags::HAS_FREE_LOCAL_NAMES) {
131+
if !ty.has_infer_types_or_consts() {
132132
db.span_label(ty_span, &format!("consider requiring `{}` to be `Copy`", ty));
133133
}
134134
},

Diff for: tests/ui/declare_interior_mutable_const.stderr

+6-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ error: a `const` item should never be interior mutable
3939
--> $DIR/declare_interior_mutable_const.rs:40:5
4040
|
4141
LL | const ATOMIC: AtomicUsize; //~ ERROR interior mutable
42-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
42+
| ^^^^^^^^^^^^^^-----------^
43+
| |
44+
| consider requiring `std::sync::atomic::AtomicUsize` to be `Copy`
4345

4446
error: a `const` item should never be interior mutable
4547
--> $DIR/declare_interior_mutable_const.rs:44:5
@@ -88,7 +90,9 @@ error: a `const` item should never be interior mutable
8890
--> $DIR/declare_interior_mutable_const.rs:81:5
8991
|
9092
LL | const ASSOC_3: AtomicUsize = AtomicUsize::new(14); //~ ERROR interior mutable
91-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
| ^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^^^^^^^^^^^
94+
| |
95+
| consider requiring `std::sync::atomic::AtomicUsize` to be `Copy`
9296

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

0 commit comments

Comments
 (0)