Allow #[cold], #[track_caller] on closures. Fix whitespace in error messages.
This commit is contained in:
parent
f745b34960
commit
0c62ef08bd
@ -121,12 +121,12 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
lint.build("`#[inline]` is ignored on constants")
|
lint.build("`#[inline]` is ignored on constants")
|
||||||
.warn(
|
.warn(
|
||||||
"this was previously accepted by the compiler but is \
|
"this was previously accepted by the compiler but is \
|
||||||
being phased out; it will become a hard error in \
|
being phased out; it will become a hard error in \
|
||||||
a future release!",
|
a future release!",
|
||||||
)
|
)
|
||||||
.note(
|
.note(
|
||||||
"see issue #65833 <https://github.com/rust-lang/rust/issues/65833> \
|
"see issue #65833 <https://github.com/rust-lang/rust/issues/65833> \
|
||||||
for more information",
|
for more information",
|
||||||
)
|
)
|
||||||
.emit();
|
.emit();
|
||||||
});
|
});
|
||||||
@ -165,7 +165,7 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
.emit();
|
.emit();
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
Target::Fn | Target::Method(..) | Target::ForeignFn => true,
|
Target::Fn | Target::Method(..) | Target::ForeignFn | Target::Closure => true,
|
||||||
_ => {
|
_ => {
|
||||||
struct_span_err!(
|
struct_span_err!(
|
||||||
self.tcx.sess,
|
self.tcx.sess,
|
||||||
@ -231,8 +231,8 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
lint.build("attribute should be applied to a function")
|
lint.build("attribute should be applied to a function")
|
||||||
.warn(
|
.warn(
|
||||||
"this was previously accepted by the compiler but is \
|
"this was previously accepted by the compiler but is \
|
||||||
being phased out; it will become a hard error in \
|
being phased out; it will become a hard error in \
|
||||||
a future release!",
|
a future release!",
|
||||||
)
|
)
|
||||||
.span_label(*span, "not a function")
|
.span_label(*span, "not a function")
|
||||||
.emit();
|
.emit();
|
||||||
@ -313,7 +313,7 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
/// Checks if `#[cold]` is applied to a non-function. Returns `true` if valid.
|
/// 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) {
|
fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
|
||||||
match 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
|
// FIXME: #[cold] was previously allowed on non-functions and some crates used
|
||||||
// this, so only emit a warning.
|
// this, so only emit a warning.
|
||||||
@ -321,8 +321,8 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
lint.build("attribute should be applied to a function")
|
lint.build("attribute should be applied to a function")
|
||||||
.warn(
|
.warn(
|
||||||
"this was previously accepted by the compiler but is \
|
"this was previously accepted by the compiler but is \
|
||||||
being phased out; it will become a hard error in \
|
being phased out; it will become a hard error in \
|
||||||
a future release!",
|
a future release!",
|
||||||
)
|
)
|
||||||
.span_label(*span, "not a function")
|
.span_label(*span, "not a function")
|
||||||
.emit();
|
.emit();
|
||||||
@ -343,8 +343,8 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
lint.build("attribute should be applied to a foreign function or static");
|
lint.build("attribute should be applied to a foreign function or static");
|
||||||
diag.warn(
|
diag.warn(
|
||||||
"this was previously accepted by the compiler but is \
|
"this was previously accepted by the compiler but is \
|
||||||
being phased out; it will become a hard error in \
|
being phased out; it will become a hard error in \
|
||||||
a future release!",
|
a future release!",
|
||||||
);
|
);
|
||||||
|
|
||||||
// See issue #47725
|
// See issue #47725
|
||||||
@ -409,8 +409,8 @@ impl CheckAttrVisitor<'tcx> {
|
|||||||
lint.build("attribute should be applied to a function or static")
|
lint.build("attribute should be applied to a function or static")
|
||||||
.warn(
|
.warn(
|
||||||
"this was previously accepted by the compiler but is \
|
"this was previously accepted by the compiler but is \
|
||||||
being phased out; it will become a hard error in \
|
being phased out; it will become a hard error in \
|
||||||
a future release!",
|
a future release!",
|
||||||
)
|
)
|
||||||
.span_label(*span, "not a function or static")
|
.span_label(*span, "not a function or static")
|
||||||
.emit();
|
.emit();
|
||||||
|
@ -6,11 +6,9 @@ fn main() {
|
|||||||
//~| ERROR: the feature named `` is not valid for this target
|
//~| ERROR: the feature named `` is not valid for this target
|
||||||
//~| NOTE: `` is not valid for this target
|
//~| NOTE: `` is not valid for this target
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
//~^ ERROR: attribute should be applied to function [E0739]
|
//~^ ERROR: `#[track_caller]` requires Rust ABI [E0737]
|
||||||
//~| ERROR: `#[track_caller]` requires Rust ABI [E0737]
|
|
||||||
|_| (),
|
|_| (),
|
||||||
//~^ NOTE: not a function
|
//~^ NOTE: not a function
|
||||||
//~| NOTE: not a function
|
|
||||||
)
|
)
|
||||||
.next();
|
.next();
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,6 @@ LL | #[target_feature(enable = "")]
|
|||||||
LL | |_| (),
|
LL | |_| (),
|
||||||
| ------ not a function
|
| ------ not a function
|
||||||
|
|
||||||
error[E0739]: attribute should be applied to function
|
|
||||||
--> $DIR/issue-68060.rs:8:13
|
|
||||||
|
|
|
||||||
LL | #[track_caller]
|
|
||||||
| ^^^^^^^^^^^^^^^
|
|
||||||
...
|
|
||||||
LL | |_| (),
|
|
||||||
| ------ not a function
|
|
||||||
|
|
||||||
error: the feature named `` is not valid for this target
|
error: the feature named `` is not valid for this target
|
||||||
--> $DIR/issue-68060.rs:4:30
|
--> $DIR/issue-68060.rs:4:30
|
||||||
|
|
|
|
||||||
@ -28,7 +19,6 @@ error[E0737]: `#[track_caller]` requires Rust ABI
|
|||||||
LL | #[track_caller]
|
LL | #[track_caller]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
Some errors have detailed explanations: E0737, E0739.
|
For more information about this error, try `rustc --explain E0737`.
|
||||||
For more information about an error, try `rustc --explain E0737`.
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user