}
cx.struct_span_lint(OVERFLOWING_LITERALS, e.span, |lint| {
- lint.build(&format!("literal out of range for `{}`", t.name_str()))
- .note(&format!(
- "the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
- cx.sess()
- .source_map()
- .span_to_snippet(lit.span)
- .expect("must get snippet from literal"),
- t.name_str(),
- min,
- max,
- ))
- .emit();
+ let mut err = lint.build(&format!("literal out of range for `{}`", t.name_str()));
+ err.note(&format!(
+ "the literal `{}` does not fit into the type `{}` whose range is `{}..={}`",
+ cx.sess()
+ .source_map()
+ .span_to_snippet(lit.span)
+ .expect("must get snippet from literal"),
+ t.name_str(),
+ min,
+ max,
+ ));
+ if let Some(sugg_ty) =
+ get_type_suggestion(&cx.typeck_results().node_type(e.hir_id), v, negative)
+ {
+ err.help(&format!("consider using `{}` instead", sugg_ty));
+ }
+ err.emit();
});
}
}
fn check_for_opaque_ty(&mut self, sp: Span, ty: Ty<'tcx>) -> bool {
struct ProhibitOpaqueTypes<'a, 'tcx> {
cx: &'a LateContext<'tcx>,
- };
+ }
impl<'a, 'tcx> ty::fold::TypeVisitor<'tcx> for ProhibitOpaqueTypes<'a, 'tcx> {
type BreakTy = Ty<'tcx>;