Skip to content

Commit 6f93d3c

Browse files
committed
Make E0094 underline better
Fixes #35966. Signed-off-by: Johannes Löthberg <[email protected]>
1 parent 0ccd5c8 commit 6f93d3c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/librustc_typeck/check/intrinsic.rs

+11-6
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,17 @@ fn equate_intrinsic_type<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
5151
}));
5252
let i_n_tps = i_ty.generics.types.len();
5353
if i_n_tps != n_tps {
54-
struct_span_err!(tcx.sess, it.span, E0094,
55-
"intrinsic has wrong number of type \
56-
parameters: found {}, expected {}",
57-
i_n_tps, n_tps)
58-
.span_label(it.span, &format!("expected {} type parameter", n_tps))
59-
.emit();
54+
let span = match it.node {
55+
hir::ForeignItemFn(_, ref generics) => generics.span().unwrap_or(it.span),
56+
hir::ForeignItemStatic(_, _) => it.span
57+
};
58+
59+
struct_span_err!(tcx.sess, span, E0094,
60+
"intrinsic has wrong number of type \
61+
parameters: found {}, expected {}",
62+
i_n_tps, n_tps)
63+
.span_label(span, &format!("expected {} type parameter", n_tps))
64+
.emit();
6065
} else {
6166
require_same_types(ccx,
6267
TypeOrigin::IntrinsicType(it.span),

0 commit comments

Comments
 (0)