Skip to content

Commit 2703e74

Browse files
committed
Disable cast_lossless on const items
1 parent f5f0273 commit 2703e74

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

clippy_lints/src/types.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy};
1313
use syntax::attr::IntType;
1414
use syntax::codemap::Span;
1515
use syntax::errors::DiagnosticBuilder;
16-
use utils::{comparisons, higher, in_external_macro, in_macro, last_path_segment, match_def_path, match_path,
16+
use utils::{comparisons, higher, in_constant, in_external_macro, in_macro, last_path_segment, match_def_path, match_path,
1717
multispan_sugg, opt_def_id, same_tys, snippet, snippet_opt, span_help_and_lint, span_lint,
1818
span_lint_and_sugg, span_lint_and_then, type_size};
1919
use utils::paths;
@@ -608,6 +608,8 @@ fn should_strip_parens(op: &Expr, snip: &str) -> bool {
608608
}
609609

610610
fn span_lossless_lint(cx: &LateContext, expr: &Expr, op: &Expr, cast_from: Ty, cast_to: Ty) {
611+
// Do not suggest using From in consts/statics until it is valid to do so (see #2267).
612+
if in_constant(cx, expr.id) { return }
611613
// The suggestion is to use a function call, so if the original expression
612614
// has parens on the outside, they are no longer needed.
613615
let opt = snippet_opt(cx, op.span);

0 commit comments

Comments
 (0)