1
Fork 0

Allow #[cold], #[track_caller] on closures. Fix whitespace in error messages.

This commit is contained in:
Caleb Zulawski 2020-08-12 12:43:14 -04:00
parent f745b34960
commit 0c62ef08bd
3 changed files with 16 additions and 28 deletions

View file

@ -121,12 +121,12 @@ impl CheckAttrVisitor<'tcx> {
lint.build("`#[inline]` is ignored on constants")
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
being phased out; it will become a hard error in \
a future release!",
)
.note(
"see issue #65833 <https://github.com/rust-lang/rust/issues/65833> \
for more information",
for more information",
)
.emit();
});
@ -165,7 +165,7 @@ impl CheckAttrVisitor<'tcx> {
.emit();
false
}
Target::Fn | Target::Method(..) | Target::ForeignFn => true,
Target::Fn | Target::Method(..) | Target::ForeignFn | Target::Closure => true,
_ => {
struct_span_err!(
self.tcx.sess,
@ -231,8 +231,8 @@ impl CheckAttrVisitor<'tcx> {
lint.build("attribute should be applied to a function")
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
being phased out; it will become a hard error in \
a future release!",
)
.span_label(*span, "not a function")
.emit();
@ -313,7 +313,7 @@ impl CheckAttrVisitor<'tcx> {
/// Checks if `#[cold]` is applied to a non-function. Returns `true` if valid.
fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
match target {
Target::Fn | Target::Method(..) | Target::ForeignFn => {}
Target::Fn | Target::Method(..) | Target::ForeignFn | Target::Closure => {}
_ => {
// FIXME: #[cold] was previously allowed on non-functions and some crates used
// this, so only emit a warning.
@ -321,8 +321,8 @@ impl CheckAttrVisitor<'tcx> {
lint.build("attribute should be applied to a function")
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
being phased out; it will become a hard error in \
a future release!",
)
.span_label(*span, "not a function")
.emit();
@ -343,8 +343,8 @@ impl CheckAttrVisitor<'tcx> {
lint.build("attribute should be applied to a foreign function or static");
diag.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
being phased out; it will become a hard error in \
a future release!",
);
// See issue #47725
@ -409,8 +409,8 @@ impl CheckAttrVisitor<'tcx> {
lint.build("attribute should be applied to a function or static")
.warn(
"this was previously accepted by the compiler but is \
being phased out; it will become a hard error in \
a future release!",
being phased out; it will become a hard error in \
a future release!",
)
.span_label(*span, "not a function or static")
.emit();