Create new error code E0734 for stability attributes used outside of standard library

This commit is contained in:
Guillaume Gomez 2019-09-25 13:23:53 +02:00
parent c9edc02e83
commit 68d099a175
2 changed files with 7 additions and 2 deletions

View File

@ -2247,4 +2247,5 @@ trait Foo { }
E0726, // non-explicit (not `'_`) elided lifetime in unsupported position
E0727, // `async` generators are not yet supported
E0728, // `await` must be in an `async` function or block
E0734, // stability attributes may not be used outside of the standard library
}

View File

@ -199,8 +199,12 @@ fn annotate<F>(&mut self, hir_id: HirId, attrs: &[Attribute],
let name = attr.name_or_empty();
if [sym::unstable, sym::stable, sym::rustc_deprecated].contains(&name) {
attr::mark_used(attr);
self.tcx.sess.span_err(attr.span, "stability attributes may not be used \
outside of the standard library");
struct_span_err!(
self.tcx.sess,
attr.span,
E0734,
"stability attributes may not be used outside of the standard library",
).emit();
}
}