1
Fork 0

Add diagnostic items for macros

This commit is contained in:
Alex Macleod 2022-01-06 14:50:46 +00:00
parent f1ce0e6a00
commit 7ea03db04a
5 changed files with 62 additions and 0 deletions

View file

@ -334,8 +334,10 @@ symbols! {
asm_sym, asm_sym,
asm_unwind, asm_unwind,
assert, assert,
assert_eq_macro,
assert_inhabited, assert_inhabited,
assert_macro, assert_macro,
assert_ne_macro,
assert_receiver_is_total_eq, assert_receiver_is_total_eq,
assert_uninit_valid, assert_uninit_valid,
assert_zero_valid, assert_zero_valid,
@ -405,6 +407,7 @@ symbols! {
cfg_doctest, cfg_doctest,
cfg_eval, cfg_eval,
cfg_hide, cfg_hide,
cfg_macro,
cfg_panic, cfg_panic,
cfg_sanitize, cfg_sanitize,
cfg_target_abi, cfg_target_abi,
@ -432,15 +435,18 @@ symbols! {
coerce_unsized, coerce_unsized,
cold, cold,
column, column,
column_macro,
compare_and_swap, compare_and_swap,
compare_exchange, compare_exchange,
compare_exchange_weak, compare_exchange_weak,
compile_error, compile_error,
compile_error_macro,
compiler_builtins, compiler_builtins,
compiler_fence, compiler_fence,
concat, concat,
concat_bytes, concat_bytes,
concat_idents, concat_idents,
concat_macro,
conservative_impl_trait, conservative_impl_trait,
console, console,
const_allocate, const_allocate,
@ -520,10 +526,13 @@ symbols! {
custom_inner_attributes, custom_inner_attributes,
custom_test_frameworks, custom_test_frameworks,
d, d,
dbg_macro,
dead_code, dead_code,
dealloc, dealloc,
debug, debug,
debug_assert_eq_macro,
debug_assert_macro, debug_assert_macro,
debug_assert_ne_macro,
debug_assertions, debug_assertions,
debug_struct, debug_struct,
debug_trait_builder, debug_trait_builder,
@ -593,6 +602,9 @@ symbols! {
enclosing_scope, enclosing_scope,
encode, encode,
env, env,
env_macro,
eprint_macro,
eprintln_macro,
eq, eq,
ermsb_target_feature, ermsb_target_feature,
exact_div, exact_div,
@ -640,6 +652,7 @@ symbols! {
field, field,
field_init_shorthand, field_init_shorthand,
file, file,
file_macro,
fill, fill,
finish, finish,
flags, flags,
@ -662,6 +675,7 @@ symbols! {
format, format,
format_args, format_args,
format_args_capture, format_args_capture,
format_args_macro,
format_args_nl, format_args_nl,
format_macro, format_macro,
freeze, freeze,
@ -728,7 +742,10 @@ symbols! {
in_band_lifetimes, in_band_lifetimes,
include, include,
include_bytes, include_bytes,
include_bytes_macro,
include_macro,
include_str, include_str,
include_str_macro,
inclusive_range_syntax, inclusive_range_syntax,
index, index,
index_mut, index_mut,
@ -776,6 +793,7 @@ symbols! {
lifetime, lifetime,
likely, likely,
line, line,
line_macro,
link, link,
link_args, link_args,
link_cfg, link_cfg,
@ -819,6 +837,7 @@ symbols! {
masked, masked,
match_beginning_vert, match_beginning_vert,
match_default_bindings, match_default_bindings,
matches_macro,
maxnumf32, maxnumf32,
maxnumf64, maxnumf64,
may_dangle, may_dangle,
@ -855,6 +874,7 @@ symbols! {
modifiers, modifiers,
module, module,
module_path, module_path,
module_path_macro,
more_qualified_paths, more_qualified_paths,
more_struct_aliases, more_struct_aliases,
movbe_target_feature, movbe_target_feature,
@ -938,6 +958,7 @@ symbols! {
optin_builtin_traits, optin_builtin_traits,
option, option,
option_env, option_env,
option_env_macro,
options, options,
or, or,
or_patterns, or_patterns,
@ -1001,6 +1022,8 @@ symbols! {
prelude_import, prelude_import,
preserves_flags, preserves_flags,
primitive, primitive,
print_macro,
println_macro,
proc_dash_macro: "proc-macro", proc_dash_macro: "proc-macro",
proc_macro, proc_macro,
proc_macro_attribute, proc_macro_attribute,
@ -1288,6 +1311,7 @@ symbols! {
str, str,
str_alloc, str_alloc,
stringify, stringify,
stringify_macro,
struct_field_attributes, struct_field_attributes,
struct_inherit, struct_inherit,
struct_variant, struct_variant,
@ -1331,6 +1355,8 @@ symbols! {
then_with, then_with,
thread, thread,
thread_local, thread_local,
thread_local_macro,
todo_macro,
tool_attributes, tool_attributes,
tool_lints, tool_lints,
trace_macros, trace_macros,
@ -1381,6 +1407,7 @@ symbols! {
underscore_imports, underscore_imports,
underscore_lifetimes, underscore_lifetimes,
uniform_paths, uniform_paths,
unimplemented_macro,
unit, unit,
universal_impl_trait, universal_impl_trait,
unix, unix,
@ -1389,6 +1416,7 @@ symbols! {
unpin, unpin,
unreachable, unreachable,
unreachable_code, unreachable_code,
unreachable_macro,
unrestricted_attribute_tokens, unrestricted_attribute_tokens,
unsafe_block_in_unsafe_fn, unsafe_block_in_unsafe_fn,
unsafe_cell, unsafe_cell,
@ -1419,6 +1447,7 @@ symbols! {
var, var,
variant_count, variant_count,
vec, vec,
vec_macro,
version, version,
vis, vis,
visible_private_types, visible_private_types,
@ -1443,7 +1472,9 @@ symbols! {
wrapping_sub, wrapping_sub,
wreg, wreg,
write_bytes, write_bytes,
write_macro,
write_str, write_str,
writeln_macro,
x87_reg, x87_reg,
xer, xer,
xmm_reg, xmm_reg,

View file

@ -37,6 +37,7 @@
#[cfg(not(test))] #[cfg(not(test))]
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "vec_macro"]
#[allow_internal_unstable(box_syntax, liballoc_internals)] #[allow_internal_unstable(box_syntax, liballoc_internals)]
macro_rules! vec { macro_rules! vec {
() => ( () => (

View file

@ -31,6 +31,7 @@ macro_rules! panic {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "assert_eq_macro")]
#[allow_internal_unstable(core_panic)] #[allow_internal_unstable(core_panic)]
macro_rules! assert_eq { macro_rules! assert_eq {
($left:expr, $right:expr $(,)?) => ({ ($left:expr, $right:expr $(,)?) => ({
@ -80,6 +81,7 @@ macro_rules! assert_eq {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "assert_ne", since = "1.13.0")] #[stable(feature = "assert_ne", since = "1.13.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "assert_ne_macro")]
#[allow_internal_unstable(core_panic)] #[allow_internal_unstable(core_panic)]
macro_rules! assert_ne { macro_rules! assert_ne {
($left:expr, $right:expr $(,)?) => ({ ($left:expr, $right:expr $(,)?) => ({
@ -236,6 +238,7 @@ macro_rules! debug_assert {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "debug_assert_eq_macro")]
macro_rules! debug_assert_eq { macro_rules! debug_assert_eq {
($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); }) ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_eq!($($arg)*); })
} }
@ -261,6 +264,7 @@ macro_rules! debug_assert_eq {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "assert_ne", since = "1.13.0")] #[stable(feature = "assert_ne", since = "1.13.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "debug_assert_ne_macro")]
macro_rules! debug_assert_ne { macro_rules! debug_assert_ne {
($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); }) ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert_ne!($($arg)*); })
} }
@ -320,6 +324,7 @@ pub macro debug_assert_matches($($arg:tt)*) {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "matches_macro", since = "1.42.0")] #[stable(feature = "matches_macro", since = "1.42.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "matches_macro")]
macro_rules! matches { macro_rules! matches {
($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => { ($expression:expr, $(|)? $( $pattern:pat_param )|+ $( if $guard: expr )? $(,)?) => {
match $expression { match $expression {
@ -475,6 +480,7 @@ macro_rules! r#try {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "write_macro")]
macro_rules! write { macro_rules! write {
($dst:expr, $($arg:tt)*) => ($dst.write_fmt($crate::format_args!($($arg)*))) ($dst:expr, $($arg:tt)*) => ($dst.write_fmt($crate::format_args!($($arg)*)))
} }
@ -525,6 +531,7 @@ macro_rules! write {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "writeln_macro")]
#[allow_internal_unstable(format_args_nl)] #[allow_internal_unstable(format_args_nl)]
macro_rules! writeln { macro_rules! writeln {
($dst:expr $(,)?) => ( ($dst:expr $(,)?) => (
@ -589,6 +596,7 @@ macro_rules! writeln {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "unreachable_macro")]
#[allow_internal_unstable(core_panic)] #[allow_internal_unstable(core_panic)]
macro_rules! unreachable { macro_rules! unreachable {
() => ({ () => ({
@ -675,6 +683,7 @@ macro_rules! unreachable {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "unimplemented_macro")]
#[allow_internal_unstable(core_panic)] #[allow_internal_unstable(core_panic)]
macro_rules! unimplemented { macro_rules! unimplemented {
() => ($crate::panicking::panic("not implemented")); () => ($crate::panicking::panic("not implemented"));
@ -737,6 +746,7 @@ macro_rules! unimplemented {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "todo_macro", since = "1.40.0")] #[stable(feature = "todo_macro", since = "1.40.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "todo_macro")]
#[allow_internal_unstable(core_panic)] #[allow_internal_unstable(core_panic)]
macro_rules! todo { macro_rules! todo {
() => ($crate::panicking::panic("not yet implemented")); () => ($crate::panicking::panic("not yet implemented"));
@ -786,6 +796,7 @@ pub(crate) mod builtin {
#[stable(feature = "compile_error_macro", since = "1.20.0")] #[stable(feature = "compile_error_macro", since = "1.20.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "compile_error_macro")]
macro_rules! compile_error { macro_rules! compile_error {
($msg:expr $(,)?) => {{ /* compiler built-in */ }}; ($msg:expr $(,)?) => {{ /* compiler built-in */ }};
} }
@ -835,6 +846,7 @@ pub(crate) mod builtin {
/// assert_eq!(s, format!("hello {}", "world")); /// assert_eq!(s, format!("hello {}", "world"));
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "format_args_macro")]
#[allow_internal_unsafe] #[allow_internal_unsafe]
#[allow_internal_unstable(fmt_internals)] #[allow_internal_unstable(fmt_internals)]
#[rustc_builtin_macro] #[rustc_builtin_macro]
@ -905,6 +917,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "env_macro")]
macro_rules! env { macro_rules! env {
($name:expr $(,)?) => {{ /* compiler built-in */ }}; ($name:expr $(,)?) => {{ /* compiler built-in */ }};
($name:expr, $error_msg:expr $(,)?) => {{ /* compiler built-in */ }}; ($name:expr, $error_msg:expr $(,)?) => {{ /* compiler built-in */ }};
@ -930,6 +943,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "option_env_macro")]
macro_rules! option_env { macro_rules! option_env {
($name:expr $(,)?) => {{ /* compiler built-in */ }}; ($name:expr $(,)?) => {{ /* compiler built-in */ }};
} }
@ -1015,6 +1029,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "concat_macro")]
macro_rules! concat { macro_rules! concat {
($($e:expr),* $(,)?) => {{ /* compiler built-in */ }}; ($($e:expr),* $(,)?) => {{ /* compiler built-in */ }};
} }
@ -1040,6 +1055,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "line_macro")]
macro_rules! line { macro_rules! line {
() => { () => {
/* compiler built-in */ /* compiler built-in */
@ -1079,6 +1095,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "column_macro")]
macro_rules! column { macro_rules! column {
() => { () => {
/* compiler built-in */ /* compiler built-in */
@ -1104,6 +1121,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "file_macro")]
macro_rules! file { macro_rules! file {
() => { () => {
/* compiler built-in */ /* compiler built-in */
@ -1128,6 +1146,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "stringify_macro")]
macro_rules! stringify { macro_rules! stringify {
($($t:tt)*) => { ($($t:tt)*) => {
/* compiler built-in */ /* compiler built-in */
@ -1169,6 +1188,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "include_str_macro")]
macro_rules! include_str { macro_rules! include_str {
($file:expr $(,)?) => {{ /* compiler built-in */ }}; ($file:expr $(,)?) => {{ /* compiler built-in */ }};
} }
@ -1208,6 +1228,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "include_bytes_macro")]
macro_rules! include_bytes { macro_rules! include_bytes {
($file:expr $(,)?) => {{ /* compiler built-in */ }}; ($file:expr $(,)?) => {{ /* compiler built-in */ }};
} }
@ -1232,6 +1253,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "module_path_macro")]
macro_rules! module_path { macro_rules! module_path {
() => { () => {
/* compiler built-in */ /* compiler built-in */
@ -1265,6 +1287,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "cfg_macro")]
macro_rules! cfg { macro_rules! cfg {
($($cfg:tt)*) => { ($($cfg:tt)*) => {
/* compiler built-in */ /* compiler built-in */
@ -1315,6 +1338,7 @@ pub(crate) mod builtin {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[rustc_builtin_macro] #[rustc_builtin_macro]
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "include_macro")]
macro_rules! include { macro_rules! include {
($file:expr $(,)?) => {{ /* compiler built-in */ }}; ($file:expr $(,)?) => {{ /* compiler built-in */ }};
} }

View file

@ -57,6 +57,7 @@ macro_rules! panic {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "print_macro")]
#[allow_internal_unstable(print_internals)] #[allow_internal_unstable(print_internals)]
macro_rules! print { macro_rules! print {
($($arg:tt)*) => ($crate::io::_print($crate::format_args!($($arg)*))); ($($arg:tt)*) => ($crate::io::_print($crate::format_args!($($arg)*)));
@ -90,6 +91,7 @@ macro_rules! print {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "println_macro")]
#[allow_internal_unstable(print_internals, format_args_nl)] #[allow_internal_unstable(print_internals, format_args_nl)]
macro_rules! println { macro_rules! println {
() => ($crate::print!("\n")); () => ($crate::print!("\n"));
@ -121,6 +123,7 @@ macro_rules! println {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "eprint", since = "1.19.0")] #[stable(feature = "eprint", since = "1.19.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "eprint_macro")]
#[allow_internal_unstable(print_internals)] #[allow_internal_unstable(print_internals)]
macro_rules! eprint { macro_rules! eprint {
($($arg:tt)*) => ($crate::io::_eprint($crate::format_args!($($arg)*))); ($($arg:tt)*) => ($crate::io::_eprint($crate::format_args!($($arg)*)));
@ -149,6 +152,7 @@ macro_rules! eprint {
/// ``` /// ```
#[macro_export] #[macro_export]
#[stable(feature = "eprint", since = "1.19.0")] #[stable(feature = "eprint", since = "1.19.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "eprintln_macro")]
#[allow_internal_unstable(print_internals, format_args_nl)] #[allow_internal_unstable(print_internals, format_args_nl)]
macro_rules! eprintln { macro_rules! eprintln {
() => ($crate::eprint!("\n")); () => ($crate::eprint!("\n"));
@ -282,6 +286,7 @@ macro_rules! eprintln {
/// [`debug!`]: https://docs.rs/log/*/log/macro.debug.html /// [`debug!`]: https://docs.rs/log/*/log/macro.debug.html
/// [`log`]: https://crates.io/crates/log /// [`log`]: https://crates.io/crates/log
#[macro_export] #[macro_export]
#[cfg_attr(not(test), rustc_diagnostic_item = "dbg_macro")]
#[stable(feature = "dbg_macro", since = "1.32.0")] #[stable(feature = "dbg_macro", since = "1.32.0")]
macro_rules! dbg { macro_rules! dbg {
// NOTE: We cannot use `concat!` to make a static string as a format argument // NOTE: We cannot use `concat!` to make a static string as a format argument

View file

@ -142,6 +142,7 @@ impl<T: 'static> fmt::Debug for LocalKey<T> {
/// [`std::thread::LocalKey`]: crate::thread::LocalKey /// [`std::thread::LocalKey`]: crate::thread::LocalKey
#[macro_export] #[macro_export]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "thread_local_macro")]
#[allow_internal_unstable(thread_local_internals)] #[allow_internal_unstable(thread_local_internals)]
macro_rules! thread_local { macro_rules! thread_local {
// empty (base case for the recursion) // empty (base case for the recursion)