out_of_scope_traits,
lev_candidate,
mode,
- ..
}) => {
let tcx = self.tcx;
let span = tcx.hir.span(node_id);
let snippet = tcx.sess.codemap().span_to_snippet(span)
.unwrap();
- err.span_suggestion(span,
- &format!("you must specify a type for \
- this binding, like `{}`",
- concrete_type),
- format!("{}: {}",
- snippet,
- concrete_type));
+
+ let parent_node = self.tcx.hir.get(
+ self.tcx.hir.get_parent_node(node_id),
+ );
+ let msg = format!(
+ "you must specify a type for this binding, like `{}`",
+ concrete_type,
+ );
+ match parent_node {
+ hir_map::NodeLocal(hir::Local {
+ source: hir::LocalSource::Normal,
+ ..
+ }) => {
+ err.span_suggestion(
+ span,
+ &msg,
+ format!("{}: {}", snippet, concrete_type),
+ );
+ }
+ _ => {
+ err.span_label(span, msg);
+ }
+ }
}
}
}
LL | let y: f32 = 2.0;
| ^^^^^^
-error: aborting due to 2 previous errors
+error[E0689]: can't call method `pow` on ambiguous numeric type `{integer}`
+ --> $DIR/method-on-ambiguous-numeric-type.rs:19:26
+ |
+LL | for i in 0..100 {
+ | - you must specify a type for this binding, like `i32`
+LL | println!("{}", i.pow(2));
+ | ^^^
+
+error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0689`.