diff options
| author | Johannes Löthberg <johannes@kyriasis.com> | 2016-08-25 01:24:49 +0200 |
|---|---|---|
| committer | Johannes Löthberg <johannes@kyriasis.com> | 2016-08-25 10:48:11 +0200 |
| commit | 6f93d3ce46d157b97da1b9ddbbd72f4bd40fbc2b (patch) | |
| tree | 211bb38b1ff64bf4bf79618a8b0207b4666d0a71 /src | |
| parent | 0ccd5c802b94fc9206e4ce27a9fbd4bebc66a771 (diff) | |
| download | rust-6f93d3ce46d157b97da1b9ddbbd72f4bd40fbc2b.tar.gz rust-6f93d3ce46d157b97da1b9ddbbd72f4bd40fbc2b.zip | |
Make E0094 underline better
Fixes #35966. Signed-off-by: Johannes Löthberg <johannes@kyriasis.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_typeck/check/intrinsic.rs | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index 7f9e715b7fa..616c99a6b9b 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -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), |
