-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Rewrite inline
attribute parser to use new infrastructure and improve diagnostics for all parsed attributes
#138165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4f73cd0
0aade73
566f691
ee976bb
672452d
5ab5f8a
780b902
81f8b57
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,9 @@ use rustc_abi::ExternAbi; | |
use rustc_ast::expand::autodiff_attrs::{AutoDiffAttrs, DiffActivity, DiffMode}; | ||
use rustc_ast::{LitKind, MetaItem, MetaItemInner, attr}; | ||
use rustc_attr_data_structures::ReprAttr::ReprAlign; | ||
use rustc_attr_data_structures::{AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr}; | ||
use rustc_attr_data_structures::{ | ||
AttributeKind, InlineAttr, InstructionSetAttr, OptimizeAttr, find_attr, | ||
}; | ||
use rustc_data_structures::fx::FxHashMap; | ||
use rustc_hir::def::DefKind; | ||
use rustc_hir::def_id::{DefId, LOCAL_CRATE, LocalDefId}; | ||
|
@@ -21,7 +23,6 @@ use rustc_session::parse::feature_err; | |
use rustc_session::{Session, lint}; | ||
use rustc_span::{Ident, Span, sym}; | ||
use rustc_target::spec::SanitizerSet; | ||
use tracing::debug; | ||
|
||
use crate::errors; | ||
use crate::target_features::{check_target_feature_trait_unsafe, from_target_feature_attr}; | ||
|
@@ -83,7 +84,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { | |
|
||
let rust_target_features = tcx.rust_target_features(LOCAL_CRATE); | ||
|
||
let mut inline_span = None; | ||
let mut link_ordinal_span = None; | ||
let mut no_sanitize_span = None; | ||
let mut mixed_export_name_no_mangle_lint_state = MixedExportNameAndNoMangleState::default(); | ||
|
@@ -449,48 +449,14 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { | |
|
||
mixed_export_name_no_mangle_lint_state.lint_if_mixed(tcx); | ||
|
||
codegen_fn_attrs.inline = attrs.iter().fold(InlineAttr::None, |ia, attr| { | ||
if !attr.has_name(sym::inline) { | ||
return ia; | ||
} | ||
|
||
if attr.is_word() { | ||
return InlineAttr::Hint; | ||
} | ||
let Some(ref items) = attr.meta_item_list() else { | ||
return ia; | ||
}; | ||
inline_span = Some(attr.span()); | ||
|
||
let [item] = &items[..] else { | ||
tcx.dcx().emit_err(errors::ExpectedOneArgument { span: attr.span() }); | ||
return InlineAttr::None; | ||
}; | ||
|
||
if item.has_name(sym::always) { | ||
InlineAttr::Always | ||
} else if item.has_name(sym::never) { | ||
InlineAttr::Never | ||
} else { | ||
tcx.dcx().emit_err(errors::InvalidArgument { span: items[0].span() }); | ||
|
||
InlineAttr::None | ||
} | ||
}); | ||
codegen_fn_attrs.inline = attrs.iter().fold(codegen_fn_attrs.inline, |ia, attr| { | ||
if !attr.has_name(sym::rustc_force_inline) || !tcx.features().rustc_attrs() { | ||
return ia; | ||
} | ||
|
||
if attr.is_word() { | ||
InlineAttr::Force { attr_span: attr.span(), reason: None } | ||
} else if let Some(val) = attr.value_str() { | ||
InlineAttr::Force { attr_span: attr.span(), reason: Some(val) } | ||
} else { | ||
debug!("`rustc_force_inline` not checked by attribute validation"); | ||
ia | ||
} | ||
}); | ||
let inline_span; | ||
(codegen_fn_attrs.inline, inline_span) = if let Some((inline_attr, span)) = | ||
find_attr!(attrs, AttributeKind::Inline(i, span) => (*i, *span)) | ||
{ | ||
(inline_attr, Some(span)) | ||
} else { | ||
(InlineAttr::None, None) | ||
}; | ||
|
||
// naked function MUST NOT be inlined! This attribute is required for the rust compiler itself, | ||
// but not for the code generation backend because at that point the naked function will just be | ||
|
@@ -511,7 +477,6 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs { | |
return OptimizeAttr::Default; | ||
}; | ||
|
||
inline_span = Some(attr.span()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixes #137950 |
||
let [item] = &items[..] else { | ||
tcx.dcx().emit_err(errors::ExpectedOneArgumentOptimize { span: attr.span() }); | ||
return OptimizeAttr::Default; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
#### Note: this error code is no longer emitted by the compiler | ||
|
||
This is because it was too specific to the `inline` attribute. | ||
Similar diagnostics occur for other attributes too. | ||
The example here will now emit `E0805` | ||
|
||
The `inline` attribute was malformed. | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0534 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no longer emitted because it's specific to inline. I kind of want to avoid those in favor of generic attribute related error codes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
```compile_fail,E0805 | ||
#[inline()] // error: expected one argument | ||
pub fn something() {} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,7 @@ struct Stable; | |
const fn stable_fn() {} | ||
``` | ||
|
||
Meta items are the key-value pairs inside of an attribute. | ||
To fix these issues you need to give required key-value pairs. | ||
To fix the above example, you can write the following: | ||
|
||
``` | ||
#![feature(staged_api)] | ||
|
@@ -49,3 +48,29 @@ struct Stable; | |
#[rustc_const_stable(feature = "stable_fn", since = "1.39.0")] // ok! | ||
const fn stable_fn() {} | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error code upgraded to represent the more generic issue of the structure of an attribute not matching the expected structure |
||
|
||
Several causes of this are, | ||
an attribute may have expected you to give a list but you gave a | ||
`name = value` pair: | ||
|
||
```compile_fail,E0539 | ||
// wrong, should be `#[repr(C)]` | ||
#[repr = "C"] | ||
struct Foo {} | ||
``` | ||
|
||
Or a `name = value` pair, but you gave a list: | ||
|
||
```compile_fail,E0539 | ||
// wrong, should be `note = "reason"` | ||
#[deprecated(since = "1.0.0", note("reason"))] | ||
struct Foo {} | ||
``` | ||
|
||
Or it expected some specific word but you gave an unexpected one: | ||
|
||
```compile_fail,E0539 | ||
// should be `always` or `never` | ||
#[inline(maybe_if_you_feel_like_it)] | ||
fn foo() {} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
An attribute was given an invalid number of arguments | ||
|
||
Erroneous code example: | ||
|
||
```compile_fail,E0805 | ||
#[inline()] // error! should either have a single argument, or no parentheses | ||
fn foo() {} | ||
#[inline(always, never)] // error! should have only one argument, not two | ||
fn bar() {} | ||
``` | ||
|
||
To fix this, either give the right number of arguments the attribute needs. | ||
In the case of inline, this could be none at all: | ||
|
||
``` | ||
#[inline] | ||
fn foo() {} | ||
``` | ||
|
||
or only one: | ||
|
||
``` | ||
#[inline(always)] | ||
fn foo() {} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -547,6 +547,7 @@ E0801: 0801, | |
E0802: 0802, | ||
E0803: 0803, | ||
E0804: 0804, | ||
E0805: 0805, | ||
); | ||
) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,8 +37,8 @@ pub type FxHashMap<K, V> = HashMap<K, V>; // re-export for use in src/librustdoc | |
// will instead cause conflicts. See #94591 for more. (This paragraph and the "Latest feature" line | ||
// are deliberately not in a doc comment, because they need not be in public docs.) | ||
// | ||
// Latest feature: rustdoc JSON: Don't apply #[repr] privacy heuristics | ||
pub const FORMAT_VERSION: u32 = 46; | ||
// Latest feature: Pretty printing of inline attributes changed | ||
pub const FORMAT_VERSION: u32 = 48; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uh, we skipped 47. Oh well, not much to be done about it now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @GuillaumeGomez: when you add the (tidy?) check for updating the number and comment in tandem, could you also add a check that the number is being increased by one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I opened #142677 for that. But that's a good point. Added to my TODO list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #138165 (comment), earlier it was thaught that someone else was going to do 46->47, to this should do 47->48. I think the takeaways are: a) Don't try to be too clever and do a double bounce There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've published There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've published |
||
|
||
/// The root of the emitted JSON blob. | ||
/// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
use super::INLINE_ALWAYS; | ||
use super::utils::is_word; | ||
use clippy_utils::diagnostics::span_lint; | ||
use rustc_attr_data_structures::{find_attr, AttributeKind, InlineAttr}; | ||
use rustc_hir::Attribute; | ||
use rustc_lint::LateContext; | ||
use rustc_span::symbol::Symbol; | ||
use rustc_span::{Span, sym}; | ||
use rustc_span::Span; | ||
|
||
pub(super) fn check(cx: &LateContext<'_>, span: Span, name: Symbol, attrs: &[Attribute]) { | ||
if span.from_expansion() { | ||
return; | ||
} | ||
|
||
for attr in attrs { | ||
if let Some(values) = attr.meta_item_list() { | ||
if values.len() != 1 || !attr.has_name(sym::inline) { | ||
continue; | ||
} | ||
if is_word(&values[0], sym::always) { | ||
span_lint( | ||
cx, | ||
INLINE_ALWAYS, | ||
attr.span(), | ||
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"), | ||
); | ||
} | ||
} | ||
if let Some(span) = find_attr!(attrs, AttributeKind::Inline(InlineAttr::Always, span) => *span) { | ||
span_lint( | ||
cx, | ||
INLINE_ALWAYS, | ||
span, | ||
format!("you have declared `#[inline(always)]` on `{name}`. This is usually a bad idea"), | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[inline]"]' | ||
//@ is "$.index[?(@.name=='just_inline')].attrs" '["#[attr = Inline(Hint)]"]' | ||
oli-obk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#[inline] | ||
pub fn just_inline() {} | ||
|
||
//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[inline(always)]"]' | ||
//@ is "$.index[?(@.name=='inline_always')].attrs" '["#[attr = Inline(Always)]"]' | ||
#[inline(always)] | ||
pub fn inline_always() {} | ||
|
||
//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[inline(never)]"]' | ||
//@ is "$.index[?(@.name=='inline_never')].attrs" '["#[attr = Inline(Never)]"]' | ||
#[inline(never)] | ||
pub fn inline_never() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,3 @@ | ||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/multiple-invalid.rs:4:1 | ||
| | ||
LL | #[inline] | ||
| ^^^^^^^^^ | ||
... | ||
LL | const FOO: u8 = 0; | ||
| ------------------ not a function or closure | ||
|
||
error: attribute should be applied to a function definition | ||
--> $DIR/multiple-invalid.rs:6:1 | ||
| | ||
|
@@ -16,6 +7,15 @@ LL | | |
LL | const FOO: u8 = 0; | ||
| ------------------ not a function definition | ||
|
||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/multiple-invalid.rs:4:1 | ||
| | ||
LL | #[inline] | ||
| ^^^^^^^^^ | ||
... | ||
LL | const FOO: u8 = 0; | ||
| ------------------ not a function or closure | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error message moved |
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0518`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
error: malformed `rustc_confusables` attribute input | ||
--> $DIR/rustc_confusables.rs:34:5 | ||
| | ||
LL | #[rustc_confusables] | ||
| ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` | ||
|
||
error: expected at least one confusable name | ||
--> $DIR/rustc_confusables.rs:30:5 | ||
| | ||
LL | #[rustc_confusables()] | ||
| ^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0539]: expected a quoted string literal | ||
--> $DIR/rustc_confusables.rs:39:25 | ||
| | ||
LL | #[rustc_confusables(invalid_meta_item)] | ||
| ^^^^^^^^^^^^^^^^^ | ||
error[E0539]: malformed `rustc_confusables` attribute input | ||
--> $DIR/rustc_confusables.rs:34:5 | ||
| | ||
help: consider surrounding this with quotes | ||
LL | #[rustc_confusables] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| expected this to be a list | ||
| help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` | ||
|
||
error[E0539]: malformed `rustc_confusables` attribute input | ||
--> $DIR/rustc_confusables.rs:39:5 | ||
| | ||
LL | #[rustc_confusables("invalid_meta_item")] | ||
| + + | ||
LL | #[rustc_confusables(invalid_meta_item)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rewording, arguably worse but consistent with other error messages with a consistent error code (as opposed to a dedicated diagnostic for this attribute only) |
||
| ^^^^^^^^^^^^^^^^^^^^-----------------^^ | ||
| | | | ||
| | expected a string literal here | ||
| help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` | ||
|
||
error: attribute should be applied to an inherent method | ||
--> $DIR/rustc_confusables.rs:45:1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,43 +4,115 @@ error[E0541]: unknown meta item 'reason' | |
LL | #[deprecated(since = "a", note = "a", reason)] | ||
| ^^^^^^ expected one of `since`, `note` | ||
|
||
error[E0539]: expected a quoted string literal | ||
--> $DIR/deprecation-sanity.rs:7:31 | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:7:5 | ||
| | ||
LL | #[deprecated(since = "a", note)] | ||
| ^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^----^^ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. much more detailed error messages |
||
| | | ||
| expected this to be of the form `note = "..."` | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated(since = "a", note)] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated(since = "a", note)] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated(since = "a", note)] | ||
LL + #[deprecated] | ||
| | ||
|
||
error[E0539]: expected a quoted string literal | ||
--> $DIR/deprecation-sanity.rs:10:18 | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:10:5 | ||
| | ||
LL | #[deprecated(since, note = "a")] | ||
| ^^^^^ | ||
| ^^^^^^^^^^^^^-----^^^^^^^^^^^^^^ | ||
| | | ||
| expected this to be of the form `since = "..."` | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated(since, note = "a")] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated(since, note = "a")] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated(since, note = "a")] | ||
LL + #[deprecated] | ||
| | ||
|
||
error[E0539]: expected a quoted string literal | ||
--> $DIR/deprecation-sanity.rs:13:31 | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:13:5 | ||
| | ||
LL | #[deprecated(since = "a", note(b))] | ||
| ^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ | ||
| | | ||
| expected this to be of the form `note = "..."` | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated(since = "a", note(b))] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated(since = "a", note(b))] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated(since = "a", note(b))] | ||
LL + #[deprecated] | ||
| | ||
|
||
error[E0539]: expected a quoted string literal | ||
--> $DIR/deprecation-sanity.rs:16:18 | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:16:5 | ||
| | ||
LL | #[deprecated(since(b), note = "a")] | ||
| ^^^^^^^^ | ||
| ^^^^^^^^^^^^^--------^^^^^^^^^^^^^^ | ||
| | | ||
| expected this to be of the form `since = "..."` | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated(since(b), note = "a")] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated(since(b), note = "a")] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated(since(b), note = "a")] | ||
LL + #[deprecated] | ||
| | ||
|
||
error[E0565]: literal in `deprecated` value must be a string | ||
--> $DIR/deprecation-sanity.rs:19:25 | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:19:5 | ||
| | ||
LL | #[deprecated(note = b"test")] | ||
| -^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^-^^^^^^^^ | ||
| | | ||
| help: consider removing the prefix | ||
| | ||
= note: expected a normal string literal, not a byte string literal | ||
|
||
error[E0565]: item in `deprecated` must be a key/value pair | ||
--> $DIR/deprecation-sanity.rs:22:18 | ||
error[E0565]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:22:5 | ||
| | ||
LL | #[deprecated("test")] | ||
| ^^^^^^ | ||
| ^^^^^^^^^^^^^------^^ | ||
| | | ||
| didn't expect a literal here | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated("test")] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated("test")] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated("test")] | ||
LL + #[deprecated] | ||
| | ||
|
||
error: multiple `deprecated` attributes | ||
--> $DIR/deprecation-sanity.rs:27:1 | ||
|
@@ -54,11 +126,25 @@ note: attribute also specified here | |
LL | #[deprecated(since = "a", note = "b")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error[E0538]: multiple 'since' items | ||
--> $DIR/deprecation-sanity.rs:30:27 | ||
error[E0538]: malformed `deprecated` attribute input | ||
--> $DIR/deprecation-sanity.rs:30:1 | ||
| | ||
LL | #[deprecated(since = "a", since = "b", note = "c")] | ||
| ^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^-----------^^^^^^^^^^^^^^ | ||
| | | ||
| found `since` used as a key more than once | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[deprecated(since = "a", since = "b", note = "c")] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated(since = "a", since = "b", note = "c")] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated(since = "a", since = "b", note = "c")] | ||
LL + #[deprecated] | ||
| | ||
|
||
error: this `#[deprecated]` annotation has no effect | ||
--> $DIR/deprecation-sanity.rs:35:1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,13 @@ | ||
error: malformed `deprecated` attribute input | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/invalid-literal.rs:1:1 | ||
| | ||
LL | #[deprecated = b"test"] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL - #[deprecated = b"test"] | ||
LL + #[deprecated = "reason"] | ||
| | ||
LL - #[deprecated = b"test"] | ||
LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] | ||
| | ||
LL - #[deprecated = b"test"] | ||
LL + #[deprecated] | ||
| ^^^^^^^^^^^^^^^-^^^^^^^ | ||
| | | ||
| help: consider removing the prefix | ||
| | ||
= note: expected a normal string literal, not a byte string literal | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0539`. |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// repr currently doesn't support literals | ||
#[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0565 | ||
#[deprecated(since = b"1.29", note = "hi")] //~ ERROR E0539 | ||
struct A { } | ||
|
||
fn main() { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error[E0539]: malformed `deprecated` attribute input | ||
--> $DIR/E0539.rs:2:1 | ||
| | ||
LL | #[deprecated(since = b"1.29", note = "hi")] | ||
| ^^^^^^^^^^^^^^^^^^^^^-^^^^^^^^^^^^^^^^^^^^^ | ||
| | | ||
| help: consider removing the prefix | ||
| | ||
= note: expected a normal string literal, not a byte string literal | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0539`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#[inline()] //~ ERROR malformed `inline` attribute input | ||
pub fn something() {} | ||
|
||
fn main() { | ||
something(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0805]: malformed `inline` attribute input | ||
--> $DIR/E0540.rs:1:1 | ||
| | ||
LL | #[inline()] | ||
| ^^^^^^^^--^ | ||
| | | ||
| expected a single argument here | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL | #[inline(always|never)] | ||
| ++++++++++++ | ||
LL - #[inline()] | ||
LL + #[inline] | ||
| | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0805`. |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,16 +8,6 @@ LL | #![rustc_main] | |
= note: the `#[rustc_main]` attribute is an internal implementation detail that will never be stable | ||
= note: the `#[rustc_main]` attribute is used internally to specify test entry point function | ||
|
||
error: valid forms for the attribute are `#[inline]` and `#[inline(always|never)]` | ||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 | ||
| | ||
LL | #[inline = "2100"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
= note: `#[deny(ill_formed_attribute_input)]` on by default | ||
|
||
error[E0518]: attribute should be applied to function or closure | ||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:32:1 | ||
| | ||
|
@@ -314,6 +304,16 @@ error[E0517]: attribute should be applied to a struct, enum, or union | |
LL | #[repr(Rust)] impl S { } | ||
| ^^^^ ---------- not a struct, enum, or union | ||
|
||
error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` | ||
--> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:46:5 | ||
| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. error message moved |
||
LL | #[inline = "2100"] fn f() { } | ||
| ^^^^^^^^^^^^^^^^^^ | ||
| | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> | ||
= note: `#[deny(ill_formed_attribute_input)]` on by default | ||
|
||
error: aborting due to 38 previous errors | ||
|
||
Some errors have detailed explanations: E0517, E0518, E0658. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,71 @@ | ||
error: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:11:1 | ||
| | ||
LL | #[rustc_force_inline("foo")] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
help: the following are the possible correct uses | ||
| | ||
LL - #[rustc_force_inline("foo")] | ||
LL + #[rustc_force_inline = "reason"] | ||
| | ||
LL - #[rustc_force_inline("foo")] | ||
LL + #[rustc_force_inline] | ||
error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
--> $DIR/invalid.rs:132:11 | ||
| | ||
LL | fn barqux(#[rustc_force_inline] _x: u32) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:16:1 | ||
error[E0805]: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:15:1 | ||
| | ||
LL | #[rustc_force_inline(bar, baz)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^----------^ | ||
| | | ||
| expected a single argument here | ||
| | ||
help: the following are the possible correct uses | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[rustc_force_inline(bar, baz)] | ||
LL + #[rustc_force_inline = "reason"] | ||
| | ||
LL - #[rustc_force_inline(bar, baz)] | ||
LL + #[rustc_force_inline(reason)] | ||
| | ||
LL - #[rustc_force_inline(bar, baz)] | ||
LL + #[rustc_force_inline] | ||
| | ||
|
||
error: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:21:1 | ||
error[E0539]: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:20:1 | ||
| | ||
LL | #[rustc_force_inline(2)] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^-^^ | ||
| | | ||
| expected a string literal here | ||
| | ||
help: the following are the possible correct uses | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[rustc_force_inline(2)] | ||
LL + #[rustc_force_inline = "reason"] | ||
| | ||
LL - #[rustc_force_inline(2)] | ||
LL + #[rustc_force_inline(reason)] | ||
| | ||
LL - #[rustc_force_inline(2)] | ||
LL + #[rustc_force_inline] | ||
| | ||
|
||
error: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:26:1 | ||
error[E0539]: malformed `rustc_force_inline` attribute input | ||
--> $DIR/invalid.rs:25:1 | ||
| | ||
LL | #[rustc_force_inline = 2] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^-^ | ||
| | | ||
| expected a string literal here | ||
| | ||
help: the following are the possible correct uses | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[rustc_force_inline = 2] | ||
LL + #[rustc_force_inline = "reason"] | ||
| | ||
LL - #[rustc_force_inline = 2] | ||
LL + #[rustc_force_inline] | ||
LL + #[rustc_force_inline(reason)] | ||
| | ||
|
||
error: allow, cfg, cfg_attr, deny, expect, forbid, and warn are the only allowed built-in attributes in function parameters | ||
--> $DIR/invalid.rs:133:11 | ||
LL - #[rustc_force_inline = 2] | ||
LL + #[rustc_force_inline] | ||
| | ||
LL | fn barqux(#[rustc_force_inline] _x: u32) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is a genuine regression, I think because check_attr now has to see this as a parsed attribute, let me fix that |
||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:31:1 | ||
--> $DIR/invalid.rs:30:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -74,7 +74,7 @@ LL | extern crate std as other_std; | |
| ------------------------------ not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:35:1 | ||
--> $DIR/invalid.rs:34:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -83,7 +83,7 @@ LL | use std::collections::HashMap; | |
| ------------------------------ not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:39:1 | ||
--> $DIR/invalid.rs:38:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -92,7 +92,7 @@ LL | static _FOO: &'static str = "FOO"; | |
| ---------------------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:43:1 | ||
--> $DIR/invalid.rs:42:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -101,7 +101,7 @@ LL | const _BAR: u32 = 3; | |
| -------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:47:1 | ||
--> $DIR/invalid.rs:46:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -110,7 +110,7 @@ LL | mod foo { } | |
| ----------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:51:1 | ||
--> $DIR/invalid.rs:50:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -125,7 +125,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:67:1 | ||
--> $DIR/invalid.rs:66:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -134,7 +134,7 @@ LL | type Foo = u32; | |
| --------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:71:1 | ||
--> $DIR/invalid.rs:70:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -147,13 +147,13 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:73:10 | ||
--> $DIR/invalid.rs:72:10 | ||
| | ||
LL | enum Bar<#[rustc_force_inline] T> { | ||
| ^^^^^^^^^^^^^^^^^^^^^ - not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:75:5 | ||
--> $DIR/invalid.rs:74:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -162,7 +162,7 @@ LL | Baz(std::marker::PhantomData<T>), | |
| -------------------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:80:1 | ||
--> $DIR/invalid.rs:79:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -175,7 +175,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:83:5 | ||
--> $DIR/invalid.rs:82:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -184,7 +184,7 @@ LL | field: u32, | |
| ---------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:88:1 | ||
--> $DIR/invalid.rs:87:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -196,7 +196,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:95:1 | ||
--> $DIR/invalid.rs:94:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -211,7 +211,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:110:1 | ||
--> $DIR/invalid.rs:109:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -220,7 +220,7 @@ LL | trait FooQux = FooBaz; | |
| ---------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:114:1 | ||
--> $DIR/invalid.rs:113:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -233,7 +233,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:122:1 | ||
--> $DIR/invalid.rs:121:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -245,7 +245,7 @@ LL | | } | |
| |_- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:129:1 | ||
--> $DIR/invalid.rs:128:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -254,15 +254,15 @@ LL | macro_rules! barqux { ($foo:tt) => { $foo }; } | |
| ---------------------------------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:133:11 | ||
--> $DIR/invalid.rs:132:11 | ||
| | ||
LL | fn barqux(#[rustc_force_inline] _x: u32) {} | ||
| ^^^^^^^^^^^^^^^^^^^^^-------- | ||
| | | ||
| not a function definition | ||
|
||
error: attribute cannot be applied to a `async`, `gen` or `async gen` function | ||
--> $DIR/invalid.rs:137:1 | ||
--> $DIR/invalid.rs:136:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -271,7 +271,7 @@ LL | async fn async_foo() {} | |
| -------------------- `async`, `gen` or `async gen` function | ||
|
||
error: attribute cannot be applied to a `async`, `gen` or `async gen` function | ||
--> $DIR/invalid.rs:141:1 | ||
--> $DIR/invalid.rs:140:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -280,7 +280,7 @@ LL | gen fn gen_foo() {} | |
| ---------------- `async`, `gen` or `async gen` function | ||
|
||
error: attribute cannot be applied to a `async`, `gen` or `async gen` function | ||
--> $DIR/invalid.rs:145:1 | ||
--> $DIR/invalid.rs:144:1 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -289,19 +289,19 @@ LL | async gen fn async_gen_foo() {} | |
| ---------------------------- `async`, `gen` or `async gen` function | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:150:14 | ||
--> $DIR/invalid.rs:149:14 | ||
| | ||
LL | let _x = #[rustc_force_inline] || { }; | ||
| ^^^^^^^^^^^^^^^^^^^^^ ------ not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:152:14 | ||
--> $DIR/invalid.rs:151:14 | ||
| | ||
LL | let _y = #[rustc_force_inline] 3 + 4; | ||
| ^^^^^^^^^^^^^^^^^^^^^ - not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:154:5 | ||
--> $DIR/invalid.rs:153:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -310,7 +310,7 @@ LL | let _z = 3; | |
| ----------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:159:9 | ||
--> $DIR/invalid.rs:158:9 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -319,7 +319,7 @@ LL | 1 => (), | |
| ------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:98:5 | ||
--> $DIR/invalid.rs:97:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -328,7 +328,7 @@ LL | type Foo; | |
| --------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:101:5 | ||
--> $DIR/invalid.rs:100:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -337,7 +337,7 @@ LL | const Bar: i32; | |
| --------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:105:5 | ||
--> $DIR/invalid.rs:104:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -346,7 +346,7 @@ LL | fn foo() {} | |
| ----------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:117:5 | ||
--> $DIR/invalid.rs:116:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -355,7 +355,7 @@ LL | fn foo() {} | |
| ----------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:54:5 | ||
--> $DIR/invalid.rs:53:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -364,7 +364,7 @@ LL | static X: &'static u32; | |
| ----------------------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:58:5 | ||
--> $DIR/invalid.rs:57:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
|
@@ -373,13 +373,15 @@ LL | type Y; | |
| ------- not a function definition | ||
|
||
error: attribute should be applied to a function | ||
--> $DIR/invalid.rs:62:5 | ||
--> $DIR/invalid.rs:61:5 | ||
| | ||
LL | #[rustc_force_inline] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
LL | | ||
LL | fn foo(); | ||
| --------- not a function definition | ||
|
||
error: aborting due to 38 previous errors | ||
error: aborting due to 37 previous errors | ||
|
||
Some errors have detailed explanations: E0539, E0805. | ||
For more information about an error, try `rustc --explain E0539`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
error[E0534]: expected one argument | ||
error[E0805]: malformed `inline` attribute input | ||
--> $DIR/invalid-inline.rs:3:1 | ||
| | ||
LL | #[inline(please,no)] | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^-----------^ | ||
| | | ||
| expected a single argument here | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL - #[inline(please,no)] | ||
LL + #[inline(always|never)] | ||
| | ||
LL - #[inline(please,no)] | ||
LL + #[inline] | ||
| | ||
|
||
error[E0534]: expected one argument | ||
error[E0805]: malformed `inline` attribute input | ||
--> $DIR/invalid-inline.rs:7:1 | ||
| | ||
LL | #[inline()] | ||
| ^^^^^^^^^^^ | ||
| ^^^^^^^^--^ | ||
| | | ||
| expected a single argument here | ||
| | ||
help: try changing it to one of the following valid forms of the attribute | ||
| | ||
LL | #[inline(always|never)] | ||
| ++++++++++++ | ||
LL - #[inline()] | ||
LL + #[inline] | ||
| | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0534`. | ||
For more information about this error, try `rustc --explain E0805`. |
Uh oh!
There was an error while loading. Please reload this page.