diff --git a/src/librustc/hir/check_attr.rs b/src/librustc/hir/check_attr.rs index a3ab5f949e7d3..8ba52cdb64f5f 100644 --- a/src/librustc/hir/check_attr.rs +++ b/src/librustc/hir/check_attr.rs @@ -42,7 +42,9 @@ struct CheckAttrVisitor<'a> { impl<'a> CheckAttrVisitor<'a> { fn check_inline(&self, attr: &ast::Attribute, target: Target) { if target != Target::Fn { - span_err!(self.sess, attr.span, E0518, "attribute should be applied to function"); + struct_span_err!(self.sess, attr.span, E0518, "attribute should be applied to function") + .span_label(attr.span, &format!("requires a function")) + .emit(); } } diff --git a/src/test/compile-fail/E0518.rs b/src/test/compile-fail/E0518.rs index 8518bb4a6be3f..f9494e0bcb531 100644 --- a/src/test/compile-fail/E0518.rs +++ b/src/test/compile-fail/E0518.rs @@ -9,9 +9,11 @@ // except according to those terms. #[inline(always)] //~ ERROR E0518 + //~| requires a function struct Foo; #[inline(never)] //~ ERROR E0518 + //~| requires a function impl Foo { }