@@ -13,7 +13,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy};
1313use syntax:: attr:: IntType ;
1414use syntax:: codemap:: Span ;
1515use 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} ;
1919use utils:: paths;
@@ -608,6 +608,8 @@ fn should_strip_parens(op: &Expr, snip: &str) -> bool {
608608}
609609
610610fn 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