@@ -13,7 +13,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy};
13
13
use syntax:: attr:: IntType ;
14
14
use syntax:: codemap:: Span ;
15
15
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,
17
17
multispan_sugg, opt_def_id, same_tys, snippet, snippet_opt, span_help_and_lint, span_lint,
18
18
span_lint_and_sugg, span_lint_and_then, type_size} ;
19
19
use utils:: paths;
@@ -608,6 +608,8 @@ fn should_strip_parens(op: &Expr, snip: &str) -> bool {
608
608
}
609
609
610
610
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 }
611
613
// The suggestion is to use a function call, so if the original expression
612
614
// has parens on the outside, they are no longer needed.
613
615
let opt = snippet_opt ( cx, op. span ) ;
0 commit comments