Attributes on macro does not trigger error or warning
b6bd825
Opened by Seiichi Uchida at
Using rustc 1.25.0-nightly (9fd7da904 2018-01-25),
fn foo() {
println!("hello world");
}
fn main() {
#[rustfmt_skip]
foo ();
}
the abvoe code triggers an error:
error[E0658]: The attribute `rustfmt_skip` is currently unknown to the compiler and may have meaning added to it in the future (see issue #29642)
--> test.rs:18:5
|
18 | #[rustfmt_skip]
| ^^^^^^^^^^^^^^^
|
= help: add #![feature(custom_attribute)] to the crate attributes to enable
error: aborting due to previous error
However, the following code compiles without any error:
fn main() {
#[rustfmt_skip]
println! ("hello world");
}
It looks like the attributes on macros are entirely ignored from the compiler. Is this an expected behavior?
Two potentially relevant comments?—
https://github.com/rust-lang/rust/blob/8ccab7eed5f4fc93500fbf242e575073ca70d7cb/src/libsyntax/visit.rs#L110-L117
https://github.com/rust-lang/rust/blob/8ccab7eed5f4fc93500fbf242e575073ca70d7cb/src/libsyntax/feature_gate.rs#L1101-L1111
Zack M. Davis at 2018-02-01 00:57:37
This no longer produces a compiler error (playground):
fn foo() { println!("hello world"); } fn main() { #[rustfmt::skip] foo (); #[rustfmt::skip] println! ("hello world"); }hello world hello worldCan we close?
Ben Reeves at 2021-12-29 04:03:26