An invalid meta-item was used inside an attribute.
Erroneous code example:
#![allow(unused)]
#![feature(staged_api)]
#![allow(internal_features)]
#![stable(since = "1.0.0", feature = "test")]
fn main() {
#[deprecated(note)]
#[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {}
#[unstable(feature = "unstable_struct", issue)]
struct Unstable;
#[rustc_const_unstable(feature)]
const fn unstable_fn() {}
#[stable(feature = "stable_struct", since)]
struct Stable;
#[rustc_const_stable(feature)]
const fn stable_fn() {}
}
ⓘ
To fix the above example, you can write the following:
#![allow(unused)]
#![feature(staged_api)]
#![allow(internal_features)]
#![stable(since = "1.0.0", feature = "test")]
fn main() {
#[deprecated(since = "1.39.0", note = "reason")]
#[unstable(feature = "deprecated_fn", issue = "123")]
fn deprecated() {}
#[unstable(feature = "unstable_struct", issue = "123")]
struct Unstable;
#[rustc_const_unstable(feature = "unstable_fn", issue = "124")]
const fn unstable_fn() {}
#[stable(feature = "stable_struct", since = "1.39.0")]
struct Stable;
#[stable(feature = "stable_fn", since = "1.39.0")]
#[rustc_const_stable(feature = "stable_fn", since = "1.39.0")]
const fn stable_fn() {}
}
Several causes of this are,
an attribute may have expected you to give a list but you gave a
name = value
pair:
#![allow(unused)]
fn main() {
#[repr = "C"]
struct Foo {}
}
ⓘ
Or a name = value
pair, but you gave a list:
#![allow(unused)]
fn main() {
#[deprecated(since = "1.0.0", note("reason"))]
struct Foo {}
}
ⓘ
Or it expected some specific word but you gave an unexpected one:
#![allow(unused)]
fn main() {
#[inline(maybe_if_you_feel_like_it)]
fn foo() {}
}
ⓘ