]> git.lizzy.rs Git - rust.git/commitdiff
Make E0094 underline better
authorJohannes Löthberg <johannes@kyriasis.com>
Wed, 24 Aug 2016 23:24:49 +0000 (01:24 +0200)
committerJohannes Löthberg <johannes@kyriasis.com>
Thu, 25 Aug 2016 08:48:11 +0000 (10:48 +0200)
Fixes #35966.

Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
src/librustc_typeck/check/intrinsic.rs

index 7f9e715b7fafc634798dc1090f7b238ef6c9e99c..616c99a6b9bc3690c75fa853da2d047286787724 100644 (file)
@@ -51,12 +51,17 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     }));
     let i_n_tps = i_ty.generics.types.len();
     if i_n_tps != n_tps {
-        struct_span_err!(tcx.sess, it.span, E0094,
-            "intrinsic has wrong number of type \
-             parameters: found {}, expected {}",
-             i_n_tps, n_tps)
-             .span_label(it.span, &format!("expected {} type parameter", n_tps))
-             .emit();
+        let span = match it.node {
+            hir::ForeignItemFn(_, ref generics) => generics.span().unwrap_or(it.span),
+            hir::ForeignItemStatic(_, _) => it.span
+        };
+
+        struct_span_err!(tcx.sess, span, E0094,
+                        "intrinsic has wrong number of type \
+                        parameters: found {}, expected {}",
+                        i_n_tps, n_tps)
+            .span_label(span, &format!("expected {} type parameter", n_tps))
+            .emit();
     } else {
         require_same_types(ccx,
                            TypeOrigin::IntrinsicType(it.span),