Emit warnings for misplaced attributes used by some crates
This commit is contained in:
parent
4efe97a3d9
commit
f745b34960
13 changed files with 700 additions and 539 deletions
|
@ -66,22 +66,24 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
} else if self.tcx.sess.check_name(attr, sym::marker) {
|
} else if self.tcx.sess.check_name(attr, sym::marker) {
|
||||||
self.check_marker(attr, span, target)
|
self.check_marker(attr, span, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::target_feature) {
|
} else if self.tcx.sess.check_name(attr, sym::target_feature) {
|
||||||
self.check_target_feature(attr, span, target)
|
self.check_target_feature(hir_id, attr, span, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::track_caller) {
|
} else if self.tcx.sess.check_name(attr, sym::track_caller) {
|
||||||
self.check_track_caller(&attr.span, attrs, span, target)
|
self.check_track_caller(&attr.span, attrs, span, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::doc) {
|
} else if self.tcx.sess.check_name(attr, sym::doc) {
|
||||||
self.check_doc_alias(attr, hir_id, target)
|
self.check_doc_alias(attr, hir_id, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::cold) {
|
|
||||||
self.check_cold(&attr, span, target)
|
|
||||||
} else if self.tcx.sess.check_name(attr, sym::link_name) {
|
|
||||||
self.check_link_name(&attr, span, target)
|
|
||||||
} else if self.tcx.sess.check_name(attr, sym::no_link) {
|
} else if self.tcx.sess.check_name(attr, sym::no_link) {
|
||||||
self.check_no_link(&attr, span, target)
|
self.check_no_link(&attr, span, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::export_name) {
|
} else if self.tcx.sess.check_name(attr, sym::export_name) {
|
||||||
self.check_export_name(&attr, span, target)
|
self.check_export_name(&attr, span, target)
|
||||||
} else if self.tcx.sess.check_name(attr, sym::link_section) {
|
|
||||||
self.check_link_section(&attr, span, target)
|
|
||||||
} else {
|
} else {
|
||||||
|
// lint-only checks
|
||||||
|
if self.tcx.sess.check_name(attr, sym::cold) {
|
||||||
|
self.check_cold(hir_id, attr, span, target);
|
||||||
|
} else if self.tcx.sess.check_name(attr, sym::link_name) {
|
||||||
|
self.check_link_name(hir_id, attr, span, target);
|
||||||
|
} else if self.tcx.sess.check_name(attr, sym::link_section) {
|
||||||
|
self.check_link_section(hir_id, attr, span, target);
|
||||||
|
}
|
||||||
true
|
true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -212,10 +214,31 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid.
|
/// Checks if the `#[target_feature]` attribute on `item` is valid. Returns `true` if valid.
|
||||||
fn check_target_feature(&self, attr: &Attribute, span: &Span, target: Target) -> bool {
|
fn check_target_feature(
|
||||||
|
&self,
|
||||||
|
hir_id: HirId,
|
||||||
|
attr: &Attribute,
|
||||||
|
span: &Span,
|
||||||
|
target: Target,
|
||||||
|
) -> bool {
|
||||||
match target {
|
match target {
|
||||||
Target::Fn
|
Target::Fn
|
||||||
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
|
| Target::Method(MethodKind::Trait { body: true } | MethodKind::Inherent) => true,
|
||||||
|
// FIXME: #[target_feature] was previously erroneously allowed on statements and some
|
||||||
|
// crates used this, so only emit a warning.
|
||||||
|
Target::Statement => {
|
||||||
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
|
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!",
|
||||||
|
)
|
||||||
|
.span_label(*span, "not a function")
|
||||||
|
.emit();
|
||||||
|
});
|
||||||
|
true
|
||||||
|
}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
self.tcx
|
||||||
.sess
|
.sess
|
||||||
|
@ -288,45 +311,58 @@ 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, attr: &Attribute, span: &Span, target: Target) -> bool {
|
fn check_cold(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
|
||||||
match target {
|
match target {
|
||||||
Target::Fn | Target::Method(..) | Target::ForeignFn => true,
|
Target::Fn | Target::Method(..) | Target::ForeignFn => {}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
// FIXME: #[cold] was previously allowed on non-functions and some crates used
|
||||||
.sess
|
// this, so only emit a warning.
|
||||||
.struct_span_err(attr.span, "attribute should be applied to a function")
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
|
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!",
|
||||||
|
)
|
||||||
.span_label(*span, "not a function")
|
.span_label(*span, "not a function")
|
||||||
.emit();
|
.emit();
|
||||||
false
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if `#[link_name]` is applied to an item other than a foreign function or static. Returns `true` if valid.
|
/// Checks if `#[link_name]` is applied to an item other than a foreign function or static.
|
||||||
fn check_link_name(&self, attr: &Attribute, span: &Span, target: Target) -> bool {
|
fn check_link_name(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
|
||||||
if target == Target::ForeignFn || target == Target::ForeignStatic {
|
match target {
|
||||||
true
|
Target::ForeignFn | Target::ForeignStatic => {}
|
||||||
} else {
|
_ => {
|
||||||
let mut err = self.tcx.sess.struct_span_err(
|
// FIXME: #[cold] was previously allowed on non-functions/statics and some crates
|
||||||
attr.span,
|
// used this, so only emit a warning.
|
||||||
"attribute should be applied to a foreign function or static",
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
|
let mut diag =
|
||||||
|
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!",
|
||||||
);
|
);
|
||||||
err.span_label(*span, "not a foreign function or static");
|
|
||||||
|
|
||||||
// See issue #47725
|
// See issue #47725
|
||||||
if target == Target::ForeignMod {
|
if let Target::ForeignMod = target {
|
||||||
if let Some(value) = attr.value_str() {
|
if let Some(value) = attr.value_str() {
|
||||||
err.span_help(
|
diag.span_help(
|
||||||
attr.span,
|
attr.span,
|
||||||
&format!(r#"try `#[link(name = "{}")]` instead"#, value),
|
&format!(r#"try `#[link(name = "{}")]` instead"#, value),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
err.span_help(attr.span, r#"try `#[link(name = "...")]` instead"#);
|
diag.span_help(attr.span, r#"try `#[link(name = "...")]` instead"#);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
err.emit();
|
diag.span_label(*span, "not a foreign function or static");
|
||||||
false
|
diag.emit();
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -362,20 +398,23 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if `#[link_section]` is applied to a function or static. Returns `true` if valid.
|
/// Checks if `#[link_section]` is applied to a function or static.
|
||||||
fn check_link_section(&self, attr: &Attribute, span: &Span, target: Target) -> bool {
|
fn check_link_section(&self, hir_id: HirId, attr: &Attribute, span: &Span, target: Target) {
|
||||||
match target {
|
match target {
|
||||||
Target::Static | Target::Fn | Target::Method(..) => true,
|
Target::Static | Target::Fn | Target::Method(..) => {}
|
||||||
_ => {
|
_ => {
|
||||||
self.tcx
|
// FIXME: #[link_section] was previously allowed on non-functions/statics and some
|
||||||
.sess
|
// crates used this, so only emit a warning.
|
||||||
.struct_span_err(
|
self.tcx.struct_span_lint_hir(UNUSED_ATTRIBUTES, hir_id, attr.span, |lint| {
|
||||||
attr.span,
|
lint.build("attribute should be applied to a function or static")
|
||||||
"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!",
|
||||||
)
|
)
|
||||||
.span_label(*span, "not a function or static")
|
.span_label(*span, "not a function or static")
|
||||||
.emit();
|
.emit();
|
||||||
false
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -424,7 +463,11 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
}
|
}
|
||||||
sym::simd => {
|
sym::simd => {
|
||||||
is_simd = true;
|
is_simd = true;
|
||||||
if target != Target::Struct { ("a", "struct") } else { continue }
|
if target != Target::Struct {
|
||||||
|
("a", "struct")
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sym::transparent => {
|
sym::transparent => {
|
||||||
is_transparent = true;
|
is_transparent = true;
|
||||||
|
@ -461,7 +504,11 @@ impl CheckAttrVisitor<'tcx> {
|
||||||
| sym::isize
|
| sym::isize
|
||||||
| sym::usize => {
|
| sym::usize => {
|
||||||
int_reprs += 1;
|
int_reprs += 1;
|
||||||
if target != Target::Enum { ("an", "enum") } else { continue }
|
if target != Target::Enum {
|
||||||
|
("an", "enum")
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => continue,
|
_ => continue,
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,30 +64,6 @@ mod no_link {
|
||||||
//~| NOTE not an `extern crate` item
|
//~| NOTE not an `extern crate` item
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cold]
|
|
||||||
//~^ ERROR attribute should be applied to a function
|
|
||||||
mod cold {
|
|
||||||
//~^ NOTE not a function
|
|
||||||
|
|
||||||
mod inner { #![cold] }
|
|
||||||
//~^ ERROR attribute should be applied to a function
|
|
||||||
//~| NOTE not a function
|
|
||||||
|
|
||||||
#[cold] fn f() { }
|
|
||||||
|
|
||||||
#[cold] struct S;
|
|
||||||
//~^ ERROR attribute should be applied to a function
|
|
||||||
//~| NOTE not a function
|
|
||||||
|
|
||||||
#[cold] type T = S;
|
|
||||||
//~^ ERROR attribute should be applied to a function
|
|
||||||
//~| NOTE not a function
|
|
||||||
|
|
||||||
#[cold] impl S { }
|
|
||||||
//~^ ERROR attribute should be applied to a function
|
|
||||||
//~| NOTE not a function
|
|
||||||
}
|
|
||||||
|
|
||||||
#[export_name = "2200"]
|
#[export_name = "2200"]
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
//~^ ERROR attribute should be applied to a function or static
|
||||||
mod export_name {
|
mod export_name {
|
||||||
|
@ -112,60 +88,4 @@ mod export_name {
|
||||||
//~| NOTE not a function or static
|
//~| NOTE not a function or static
|
||||||
}
|
}
|
||||||
|
|
||||||
#[link_name = "1900"]
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
mod link_name {
|
|
||||||
//~^ NOTE not a foreign function or static
|
|
||||||
|
|
||||||
#[link_name = "1900"]
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| HELP try `#[link(name = "1900")]` instead
|
|
||||||
extern { }
|
|
||||||
//~^ NOTE not a foreign function or static
|
|
||||||
|
|
||||||
mod inner { #![link_name="1900"] }
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| NOTE not a foreign function or static
|
|
||||||
|
|
||||||
#[link_name = "1900"] fn f() { }
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| NOTE not a foreign function or static
|
|
||||||
|
|
||||||
#[link_name = "1900"] struct S;
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| NOTE not a foreign function or static
|
|
||||||
|
|
||||||
#[link_name = "1900"] type T = S;
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| NOTE not a foreign function or static
|
|
||||||
|
|
||||||
#[link_name = "1900"] impl S { }
|
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
|
||||||
//~| NOTE not a foreign function or static
|
|
||||||
}
|
|
||||||
|
|
||||||
#[link_section = "1800"]
|
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
|
||||||
mod link_section {
|
|
||||||
//~^ NOTE not a function or static
|
|
||||||
|
|
||||||
mod inner { #![link_section="1800"] }
|
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
|
||||||
//~| NOTE not a function or static
|
|
||||||
|
|
||||||
#[link_section = "1800"] fn f() { }
|
|
||||||
|
|
||||||
#[link_section = "1800"] struct S;
|
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
|
||||||
//~| NOTE not a function or static
|
|
||||||
|
|
||||||
#[link_section = "1800"] type T = S;
|
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
|
||||||
//~| NOTE not a function or static
|
|
||||||
|
|
||||||
#[link_section = "1800"] impl S { }
|
|
||||||
//~^ ERROR attribute should be applied to a function or static
|
|
||||||
//~| NOTE not a function or static
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
|
@ -38,23 +38,8 @@ LL | |
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_- not an `extern crate` item
|
| |_- not an `extern crate` item
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:1
|
|
||||||
|
|
|
||||||
LL | #[cold]
|
|
||||||
| ^^^^^^^
|
|
||||||
LL |
|
|
||||||
LL | / mod cold {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | mod inner { #![cold] }
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_- not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
error: attribute should be applied to a function or static
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:91:1
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:67:1
|
||||||
|
|
|
|
||||||
LL | #[export_name = "2200"]
|
LL | #[export_name = "2200"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -68,36 +53,6 @@ LL | |
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_- not a function or static
|
| |_- not a function or static
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:115:1
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
LL |
|
|
||||||
LL | / mod link_name {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | #[link_name = "1900"]
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:147:1
|
|
||||||
|
|
|
||||||
LL | #[link_section = "1800"]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
LL |
|
|
||||||
LL | / mod link_section {
|
|
||||||
LL | |
|
|
||||||
LL | |
|
|
||||||
LL | | mod inner { #![link_section="1800"] }
|
|
||||||
... |
|
|
||||||
LL | |
|
|
||||||
LL | | }
|
|
||||||
| |_- not a function or static
|
|
||||||
|
|
||||||
error[E0518]: attribute should be applied to function or closure
|
error[E0518]: attribute should be applied to function or closure
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:18:17
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:18:17
|
||||||
|
|
|
|
||||||
|
@ -152,123 +107,30 @@ error: attribute should be applied to an `extern crate` item
|
||||||
LL | #[no_link] impl S { }
|
LL | #[no_link] impl S { }
|
||||||
| ^^^^^^^^^^ ---------- not an `extern crate` item
|
| ^^^^^^^^^^ ---------- not an `extern crate` item
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:72:17
|
|
||||||
|
|
|
||||||
LL | mod inner { #![cold] }
|
|
||||||
| ------------^^^^^^^^-- not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5
|
|
||||||
|
|
|
||||||
LL | #[cold] struct S;
|
|
||||||
| ^^^^^^^ --------- not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5
|
|
||||||
|
|
|
||||||
LL | #[cold] type T = S;
|
|
||||||
| ^^^^^^^ ----------- not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
|
|
||||||
|
|
|
||||||
LL | #[cold] impl S { }
|
|
||||||
| ^^^^^^^ ---------- not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
error: attribute should be applied to a function or static
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:96:17
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:72:17
|
||||||
|
|
|
|
||||||
LL | mod inner { #![export_name="2200"] }
|
LL | mod inner { #![export_name="2200"] }
|
||||||
| ------------^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
|
| ------------^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
error: attribute should be applied to a function or static
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:102:5
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:78:5
|
||||||
|
|
|
|
||||||
LL | #[export_name = "2200"] struct S;
|
LL | #[export_name = "2200"] struct S;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
|
| ^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
error: attribute should be applied to a function or static
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:106:5
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:82:5
|
||||||
|
|
|
|
||||||
LL | #[export_name = "2200"] type T = S;
|
LL | #[export_name = "2200"] type T = S;
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
|
| ^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
error: attribute should be applied to a function or static
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:110:5
|
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:86:5
|
||||||
|
|
|
|
||||||
LL | #[export_name = "2200"] impl S { }
|
LL | #[export_name = "2200"] impl S { }
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
|
| ^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
error: aborting due to 17 previous errors
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:120:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
...
|
|
||||||
LL | extern { }
|
|
||||||
| ---------- not a foreign function or static
|
|
||||||
|
|
|
||||||
help: try `#[link(name = "1900")]` instead
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:120:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:126:17
|
|
||||||
|
|
|
||||||
LL | mod inner { #![link_name="1900"] }
|
|
||||||
| ------------^^^^^^^^^^^^^^^^^^^^-- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:130:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"] fn f() { }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:134:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"] struct S;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ --------- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:138:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"] type T = S;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ ----------- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:142:5
|
|
||||||
|
|
|
||||||
LL | #[link_name = "1900"] impl S { }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^ ---------- not a foreign function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:152:17
|
|
||||||
|
|
|
||||||
LL | mod inner { #![link_section="1800"] }
|
|
||||||
| ------------^^^^^^^^^^^^^^^^^^^^^^^-- not a function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:158:5
|
|
||||||
|
|
|
||||||
LL | #[link_section = "1800"] struct S;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ --------- not a function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:162:5
|
|
||||||
|
|
|
||||||
LL | #[link_section = "1800"] type T = S;
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ ----------- not a function or static
|
|
||||||
|
|
||||||
error: attribute should be applied to a function or static
|
|
||||||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:166:5
|
|
||||||
|
|
|
||||||
LL | #[link_section = "1800"] impl S { }
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^ ---------- not a function or static
|
|
||||||
|
|
||||||
error: aborting due to 34 previous errors
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0518`.
|
For more information about this error, try `rustc --explain E0518`.
|
||||||
|
|
|
@ -31,14 +31,19 @@
|
||||||
// occurrences in the source text.
|
// occurrences in the source text.
|
||||||
|
|
||||||
// check-pass
|
// check-pass
|
||||||
|
// ignore-tidy-linelength
|
||||||
|
|
||||||
#![feature(test, plugin_registrar)]
|
#![feature(test, plugin_registrar)]
|
||||||
#![warn(unused_attributes, unknown_lints)]
|
#![warn(unused_attributes, unknown_lints)]
|
||||||
|
//~^ NOTE the lint level is defined here
|
||||||
|
//~| NOTE the lint level is defined here
|
||||||
|
|
||||||
// Exception, a gated and deprecated attribute.
|
// Exception, a gated and deprecated attribute.
|
||||||
|
|
||||||
#![plugin_registrar] //~ WARN unused attribute
|
#![plugin_registrar]
|
||||||
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
|
|
||||||
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
|
// UNGATED WHITE-LISTED BUILT-IN ATTRIBUTES
|
||||||
|
|
||||||
|
@ -88,12 +93,18 @@
|
||||||
#![crate_name = "0900"]
|
#![crate_name = "0900"]
|
||||||
#![crate_type = "bin"] // cannot pass "0800" here
|
#![crate_type = "bin"] // cannot pass "0800" here
|
||||||
|
|
||||||
#![crate_id = "10"] //~ WARN use of deprecated attribute
|
#![crate_id = "10"]
|
||||||
|
//~^ WARN use of deprecated attribute
|
||||||
|
//~| HELP remove this attribute
|
||||||
|
|
||||||
// FIXME(#44232) we should warn that this isn't used.
|
// FIXME(#44232) we should warn that this isn't used.
|
||||||
#![feature(rust1)] //~ WARN no longer requires an attribute to enable
|
#![feature(rust1)]
|
||||||
|
//~^ WARN no longer requires an attribute to enable
|
||||||
|
//~| NOTE `#[warn(stable_features)]` on by default
|
||||||
|
|
||||||
#![no_start] //~ WARN use of deprecated attribute
|
#![no_start]
|
||||||
|
//~^ WARN use of deprecated attribute
|
||||||
|
//~| HELP remove this attribute
|
||||||
|
|
||||||
// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
|
// (cannot easily gating state of crate-level #[no_main]; but non crate-level is below at "0400")
|
||||||
#![no_builtins]
|
#![no_builtins]
|
||||||
|
@ -217,24 +228,30 @@ mod macro_export {
|
||||||
#[plugin_registrar]
|
#[plugin_registrar]
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
mod plugin_registrar {
|
mod plugin_registrar {
|
||||||
mod inner { #![plugin_registrar] }
|
mod inner { #![plugin_registrar] }
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
|
//~| NOTE `#[warn(deprecated)]` on by default
|
||||||
|
|
||||||
// for `fn f()` case, see gated-plugin_registrar.rs
|
// for `fn f()` case, see gated-plugin_registrar.rs
|
||||||
|
|
||||||
#[plugin_registrar] struct S;
|
#[plugin_registrar] struct S;
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
|
|
||||||
#[plugin_registrar] type T = S;
|
#[plugin_registrar] type T = S;
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
|
|
||||||
#[plugin_registrar] impl S { }
|
#[plugin_registrar] impl S { }
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
//~| WARN use of deprecated attribute
|
//~| WARN use of deprecated attribute
|
||||||
|
//~| HELP may be removed in a future compiler version
|
||||||
}
|
}
|
||||||
|
|
||||||
#[main]
|
#[main]
|
||||||
|
@ -449,6 +466,7 @@ mod reexport_test_harness_main {
|
||||||
mod macro_escape {
|
mod macro_escape {
|
||||||
mod inner { #![macro_escape] }
|
mod inner { #![macro_escape] }
|
||||||
//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
|
//~^ WARN `#[macro_escape]` is a deprecated synonym for `#[macro_use]`
|
||||||
|
//~| HELP try an outer attribute: `#[macro_use]`
|
||||||
|
|
||||||
#[macro_escape] fn f() { }
|
#[macro_escape] fn f() { }
|
||||||
//~^ WARN unused attribute
|
//~^ WARN unused attribute
|
||||||
|
@ -505,6 +523,104 @@ mod doc {
|
||||||
#[doc = "2400"] impl S { }
|
#[doc = "2400"] impl S { }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
//~^ WARN 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!
|
||||||
|
mod cold {
|
||||||
|
//~^ NOTE not a function
|
||||||
|
|
||||||
|
mod inner { #![cold] }
|
||||||
|
//~^ WARN 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!
|
||||||
|
//~| NOTE not a function
|
||||||
|
|
||||||
|
#[cold] fn f() { }
|
||||||
|
|
||||||
|
#[cold] struct S;
|
||||||
|
//~^ WARN 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!
|
||||||
|
//~| NOTE not a function
|
||||||
|
|
||||||
|
#[cold] type T = S;
|
||||||
|
//~^ WARN 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!
|
||||||
|
//~| NOTE not a function
|
||||||
|
|
||||||
|
#[cold] impl S { }
|
||||||
|
//~^ WARN 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!
|
||||||
|
//~| NOTE not a function
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link_name = "1900"]
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
mod link_name {
|
||||||
|
//~^ NOTE not a foreign function or static
|
||||||
|
|
||||||
|
#[link_name = "1900"]
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| HELP try `#[link(name = "1900")]` instead
|
||||||
|
extern { }
|
||||||
|
//~^ NOTE not a foreign function or static
|
||||||
|
|
||||||
|
mod inner { #![link_name="1900"] }
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a foreign function or static
|
||||||
|
|
||||||
|
#[link_name = "1900"] fn f() { }
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a foreign function or static
|
||||||
|
|
||||||
|
#[link_name = "1900"] struct S;
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a foreign function or static
|
||||||
|
|
||||||
|
#[link_name = "1900"] type T = S;
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a foreign function or static
|
||||||
|
|
||||||
|
#[link_name = "1900"] impl S { }
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a foreign function or static
|
||||||
|
}
|
||||||
|
|
||||||
|
#[link_section = "1800"]
|
||||||
|
//~^ WARN attribute should be applied to a function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
mod link_section {
|
||||||
|
//~^ NOTE not a function or static
|
||||||
|
|
||||||
|
mod inner { #![link_section="1800"] }
|
||||||
|
//~^ WARN attribute should be applied to a function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a function or static
|
||||||
|
|
||||||
|
#[link_section = "1800"] fn f() { }
|
||||||
|
|
||||||
|
#[link_section = "1800"] struct S;
|
||||||
|
//~^ WARN attribute should be applied to a function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a function or static
|
||||||
|
|
||||||
|
#[link_section = "1800"] type T = S;
|
||||||
|
//~^ WARN attribute should be applied to a function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a function or static
|
||||||
|
|
||||||
|
#[link_section = "1800"] impl S { }
|
||||||
|
//~^ WARN attribute should be applied to a function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
//~| NOTE not a function or static
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Note that this is a `check-pass` test, so it
|
// Note that this is a `check-pass` test, so it
|
||||||
// will never invoke the linker. These are here nonetheless to point
|
// will never invoke the linker. These are here nonetheless to point
|
||||||
// out that we allow them at non-crate-level (though I do not know
|
// out that we allow them at non-crate-level (though I do not know
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,14 @@
|
||||||
#[link_name = "foo"] //~ ERROR attribute should be applied to a foreign function or static
|
// ignore-tidy-linelength
|
||||||
|
#![warn(unused_attributes)] //~ NOTE lint level is defined here
|
||||||
|
|
||||||
|
#[link_name = "foo"]
|
||||||
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
struct Foo; //~ NOTE not a foreign function or static
|
struct Foo; //~ NOTE not a foreign function or static
|
||||||
|
|
||||||
#[link_name = "foobar"]
|
#[link_name = "foobar"]
|
||||||
//~^ ERROR attribute should be applied to a foreign function or static
|
//~^ WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
//~| HELP try `#[link(name = "foobar")]` instead
|
//~| HELP try `#[link(name = "foobar")]` instead
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn foo() -> u32;
|
fn foo() -> u32;
|
||||||
|
@ -12,7 +18,8 @@ extern "C" {
|
||||||
#[link_name]
|
#[link_name]
|
||||||
//~^ ERROR malformed `link_name` attribute input
|
//~^ ERROR malformed `link_name` attribute input
|
||||||
//~| HELP must be of the form
|
//~| HELP must be of the form
|
||||||
//~| ERROR attribute should be applied to a foreign function or static
|
//~| WARN attribute should be applied to a foreign function or static [unused_attributes]
|
||||||
|
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
//~| HELP try `#[link(name = "...")]` instead
|
//~| HELP try `#[link(name = "...")]` instead
|
||||||
extern "C" {
|
extern "C" {
|
||||||
fn bar() -> u32;
|
fn bar() -> u32;
|
||||||
|
|
|
@ -1,19 +1,27 @@
|
||||||
error: malformed `link_name` attribute input
|
error: malformed `link_name` attribute input
|
||||||
--> $DIR/issue-47725.rs:12:1
|
--> $DIR/issue-47725.rs:18:1
|
||||||
|
|
|
|
||||||
LL | #[link_name]
|
LL | #[link_name]
|
||||||
| ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`
|
| ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]`
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
warning: attribute should be applied to a foreign function or static
|
||||||
--> $DIR/issue-47725.rs:1:1
|
--> $DIR/issue-47725.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[link_name = "foo"]
|
LL | #[link_name = "foo"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
LL | struct Foo;
|
LL | struct Foo;
|
||||||
| ----------- not a foreign function or static
|
| ----------- not a foreign function or static
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-47725.rs:2:9
|
||||||
|
|
|
||||||
|
LL | #![warn(unused_attributes)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
warning: attribute should be applied to a foreign function or static
|
||||||
--> $DIR/issue-47725.rs:4:1
|
--> $DIR/issue-47725.rs:9:1
|
||||||
|
|
|
|
||||||
LL | #[link_name = "foobar"]
|
LL | #[link_name = "foobar"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -23,14 +31,15 @@ LL | | fn foo() -> u32;
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_- not a foreign function or static
|
| |_- not a foreign function or static
|
||||||
|
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
help: try `#[link(name = "foobar")]` instead
|
help: try `#[link(name = "foobar")]` instead
|
||||||
--> $DIR/issue-47725.rs:4:1
|
--> $DIR/issue-47725.rs:9:1
|
||||||
|
|
|
|
||||||
LL | #[link_name = "foobar"]
|
LL | #[link_name = "foobar"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: attribute should be applied to a foreign function or static
|
warning: attribute should be applied to a foreign function or static
|
||||||
--> $DIR/issue-47725.rs:12:1
|
--> $DIR/issue-47725.rs:18:1
|
||||||
|
|
|
|
||||||
LL | #[link_name]
|
LL | #[link_name]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
@ -40,11 +49,12 @@ LL | | fn bar() -> u32;
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_- not a foreign function or static
|
| |_- not a foreign function or static
|
||||||
|
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
help: try `#[link(name = "...")]` instead
|
help: try `#[link(name = "...")]` instead
|
||||||
--> $DIR/issue-47725.rs:12:1
|
--> $DIR/issue-47725.rs:18:1
|
||||||
|
|
|
|
||||||
LL | #[link_name]
|
LL | #[link_name]
|
||||||
| ^^^^^^^^^^^^
|
| ^^^^^^^^^^^^
|
||||||
|
|
||||||
error: aborting due to 4 previous errors
|
error: aborting due to previous error; 3 warnings emitted
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,14 @@
|
||||||
#[cold] //~ ERROR attribute should be applied to a function
|
// ignore-tidy-linelength
|
||||||
|
#![deny(unused_attributes)] //~ NOTE lint level is defined here
|
||||||
|
|
||||||
|
#[cold]
|
||||||
|
//~^ ERROR 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!
|
||||||
struct Foo; //~ NOTE not a function
|
struct Foo; //~ NOTE not a function
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#[cold] //~ ERROR attribute should be applied to a function
|
#[cold]
|
||||||
|
//~^ ERROR 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!
|
||||||
5; //~ NOTE not a function
|
5; //~ NOTE not a function
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/issue-54044.rs:1:1
|
--> $DIR/issue-54044.rs:4:1
|
||||||
|
|
|
|
||||||
LL | #[cold]
|
LL | #[cold]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
...
|
||||||
LL | struct Foo;
|
LL | struct Foo;
|
||||||
| ----------- not a function
|
| ----------- not a function
|
||||||
|
|
|
||||||
|
note: the lint level is defined here
|
||||||
|
--> $DIR/issue-54044.rs:2:9
|
||||||
|
|
|
||||||
|
LL | #![deny(unused_attributes)]
|
||||||
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/issue-54044.rs:5:5
|
--> $DIR/issue-54044.rs:10:5
|
||||||
|
|
|
|
||||||
LL | #[cold]
|
LL | #[cold]
|
||||||
| ^^^^^^^
|
| ^^^^^^^
|
||||||
|
...
|
||||||
LL | 5;
|
LL | 5;
|
||||||
| - not a function
|
| - not a function
|
||||||
|
|
|
||||||
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||||
|
|
||||||
error: aborting due to 2 previous errors
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,13 @@ fn main() {
|
||||||
#[target_feature(enable = "")]
|
#[target_feature(enable = "")]
|
||||||
//~^ ERROR: attribute should be applied to a function
|
//~^ ERROR: attribute should be applied to a function
|
||||||
//~| 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
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
//~^ ERROR: attribute should be applied to function [E0739]
|
//~^ 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
|
||||||
)
|
)
|
||||||
.next();
|
.next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ LL | |_| (),
|
||||||
| ------ not a function
|
| ------ not a function
|
||||||
|
|
||||||
error[E0739]: attribute should be applied to function
|
error[E0739]: attribute should be applied to function
|
||||||
--> $DIR/issue-68060.rs:7:13
|
--> $DIR/issue-68060.rs:8:13
|
||||||
|
|
|
|
||||||
LL | #[track_caller]
|
LL | #[track_caller]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
// ignore-sparc64
|
// ignore-sparc64
|
||||||
|
|
||||||
#![feature(target_feature)]
|
#![feature(target_feature)]
|
||||||
|
#![warn(unused_attributes)]
|
||||||
|
|
||||||
#[target_feature = "+sse2"]
|
#[target_feature = "+sse2"]
|
||||||
//~^ ERROR malformed `target_feature` attribute
|
//~^ ERROR malformed `target_feature` attribute
|
||||||
|
@ -48,17 +49,20 @@ struct Foo;
|
||||||
|
|
||||||
#[target_feature(enable = "sse2")]
|
#[target_feature(enable = "sse2")]
|
||||||
//~^ ERROR attribute should be applied to a function
|
//~^ ERROR attribute should be applied to a function
|
||||||
enum Bar { }
|
enum Bar {}
|
||||||
//~^ NOTE not a function
|
//~^ NOTE not a function
|
||||||
|
|
||||||
#[target_feature(enable = "sse2")]
|
#[target_feature(enable = "sse2")]
|
||||||
//~^ ERROR attribute should be applied to a function
|
//~^ ERROR attribute should be applied to a function
|
||||||
union Qux { f1: u16, f2: u16 }
|
union Qux {
|
||||||
//~^ NOTE not a function
|
//~^ NOTE not a function
|
||||||
|
f1: u16,
|
||||||
|
f2: u16,
|
||||||
|
}
|
||||||
|
|
||||||
#[target_feature(enable = "sse2")]
|
#[target_feature(enable = "sse2")]
|
||||||
//~^ ERROR attribute should be applied to a function
|
//~^ ERROR attribute should be applied to a function
|
||||||
trait Baz { }
|
trait Baz {}
|
||||||
//~^ NOTE not a function
|
//~^ NOTE not a function
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
|
|
@ -1,29 +1,29 @@
|
||||||
error: malformed `target_feature` attribute input
|
error: malformed `target_feature` attribute input
|
||||||
--> $DIR/invalid-attribute.rs:17:1
|
--> $DIR/invalid-attribute.rs:18:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature = "+sse2"]
|
LL | #[target_feature = "+sse2"]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]`
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]`
|
||||||
|
|
||||||
error: the feature named `foo` is not valid for this target
|
error: the feature named `foo` is not valid for this target
|
||||||
--> $DIR/invalid-attribute.rs:19:18
|
--> $DIR/invalid-attribute.rs:20:18
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "foo")]
|
LL | #[target_feature(enable = "foo")]
|
||||||
| ^^^^^^^^^^^^^^ `foo` is not valid for this target
|
| ^^^^^^^^^^^^^^ `foo` is not valid for this target
|
||||||
|
|
||||||
error: malformed `target_feature` attribute input
|
error: malformed `target_feature` attribute input
|
||||||
--> $DIR/invalid-attribute.rs:22:18
|
--> $DIR/invalid-attribute.rs:23:18
|
||||||
|
|
|
|
||||||
LL | #[target_feature(bar)]
|
LL | #[target_feature(bar)]
|
||||||
| ^^^ help: must be of the form: `enable = ".."`
|
| ^^^ help: must be of the form: `enable = ".."`
|
||||||
|
|
||||||
error: malformed `target_feature` attribute input
|
error: malformed `target_feature` attribute input
|
||||||
--> $DIR/invalid-attribute.rs:24:18
|
--> $DIR/invalid-attribute.rs:25:18
|
||||||
|
|
|
|
||||||
LL | #[target_feature(disable = "baz")]
|
LL | #[target_feature(disable = "baz")]
|
||||||
| ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."`
|
| ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."`
|
||||||
|
|
||||||
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
|
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
|
||||||
--> $DIR/invalid-attribute.rs:28:1
|
--> $DIR/invalid-attribute.rs:29:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -35,7 +35,7 @@ LL | fn bar() {}
|
||||||
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
|
= help: add `#![feature(target_feature_11)]` to the crate attributes to enable
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:34:1
|
--> $DIR/invalid-attribute.rs:35:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -44,7 +44,7 @@ LL | mod another {}
|
||||||
| -------------- not a function
|
| -------------- not a function
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:39:1
|
--> $DIR/invalid-attribute.rs:40:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -53,7 +53,7 @@ LL | const FOO: usize = 7;
|
||||||
| --------------------- not a function
|
| --------------------- not a function
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:44:1
|
--> $DIR/invalid-attribute.rs:45:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -62,40 +62,44 @@ LL | struct Foo;
|
||||||
| ----------- not a function
|
| ----------- not a function
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:49:1
|
--> $DIR/invalid-attribute.rs:50:1
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
LL |
|
LL |
|
||||||
LL | enum Bar { }
|
LL | enum Bar {}
|
||||||
|
| ----------- not a function
|
||||||
|
|
||||||
|
error: attribute should be applied to a function
|
||||||
|
--> $DIR/invalid-attribute.rs:55:1
|
||||||
|
|
|
||||||
|
LL | #[target_feature(enable = "sse2")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL |
|
||||||
|
LL | / union Qux {
|
||||||
|
LL | |
|
||||||
|
LL | | f1: u16,
|
||||||
|
LL | | f2: u16,
|
||||||
|
LL | | }
|
||||||
|
| |_- not a function
|
||||||
|
|
||||||
|
error: attribute should be applied to a function
|
||||||
|
--> $DIR/invalid-attribute.rs:63:1
|
||||||
|
|
|
||||||
|
LL | #[target_feature(enable = "sse2")]
|
||||||
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
LL |
|
||||||
|
LL | trait Baz {}
|
||||||
| ------------ not a function
|
| ------------ not a function
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/invalid-attribute.rs:54:1
|
|
||||||
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
LL |
|
|
||||||
LL | union Qux { f1: u16, f2: u16 }
|
|
||||||
| ------------------------------ not a function
|
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
|
||||||
--> $DIR/invalid-attribute.rs:59:1
|
|
||||||
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
LL |
|
|
||||||
LL | trait Baz { }
|
|
||||||
| ------------- not a function
|
|
||||||
|
|
||||||
error: cannot use `#[inline(always)]` with `#[target_feature]`
|
error: cannot use `#[inline(always)]` with `#[target_feature]`
|
||||||
--> $DIR/invalid-attribute.rs:64:1
|
--> $DIR/invalid-attribute.rs:68:1
|
||||||
|
|
|
|
||||||
LL | #[inline(always)]
|
LL | #[inline(always)]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:82:5
|
--> $DIR/invalid-attribute.rs:86:5
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -107,7 +111,7 @@ LL | | }
|
||||||
| |_____- not a function
|
| |_____- not a function
|
||||||
|
|
||||||
error: attribute should be applied to a function
|
error: attribute should be applied to a function
|
||||||
--> $DIR/invalid-attribute.rs:90:5
|
--> $DIR/invalid-attribute.rs:94:5
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -116,7 +120,7 @@ LL | || {};
|
||||||
| ----- not a function
|
| ----- not a function
|
||||||
|
|
||||||
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
|
error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions
|
||||||
--> $DIR/invalid-attribute.rs:74:5
|
--> $DIR/invalid-attribute.rs:78:5
|
||||||
|
|
|
|
||||||
LL | #[target_feature(enable = "sse2")]
|
LL | #[target_feature(enable = "sse2")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue