Skip to content
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

Deprecated attributes do not apply to macro-expanded items #57679

Closed
euclio opened this issue Jan 16, 2019 · 6 comments
Closed

Deprecated attributes do not apply to macro-expanded items #57679

euclio opened this issue Jan 16, 2019 · 6 comments
Labels
A-attributes Area: #[attributes(..)] A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)

Comments

@euclio
Copy link
Contributor

euclio commented Jan 16, 2019

Example at: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fc72706e6b3151479a1a454611827c50

I expected the deprecation lint to be fired on use of the wrapped function. If this is intentional behavior, I would expect a warning that the deprecated attribute is meaningless in that position.

@Centril
Copy link
Contributor

Centril commented Jan 17, 2019

I believe this is intentional; the attribute is applied to the macro call as opposed to the expansion thereof.

cc @petrochenkov @rust-lang/lang

@Centril Centril added A-attributes Area: #[attributes(..)] A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) labels Jan 17, 2019
@petrochenkov
Copy link
Contributor

petrochenkov commented Jan 17, 2019

Yes, attributes applied to macro calls are eliminated during expansion of the macro.
They should be reported as unused or rejected if they have no effect on the macro call itself.

@euclio
Copy link
Contributor Author

euclio commented Jan 18, 2019

What are the attributes that do have an effect on the macro call? cfg, cfg_attr, and the lint check attributes are the only ones I can think of.

@petrochenkov
Copy link
Contributor

Also, something like #[rustfmt::skip].
(And macro attributes of course, but those are not lost, but rather expanded similarly to cfg and cfg_attr.)

Centril added a commit to Centril/rust that referenced this issue Jan 19, 2019
…enkov

add applicability to remaining suggestions

Fixes rust-lang#50723.

I noticed that the suggestion methods on `DiagnosticBuilder` weren't actually deprecated due to rust-lang#57679. This PR deprecates them properly and fixes the remaining usages.

There's also a PR for clippy at rust-lang/rust-clippy#3667.
@ocstl
Copy link

ocstl commented Oct 28, 2021

The deprecated attribute seems to (now) be correctly reported as unused in the example above (as well as for edition 2021: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f655167d9102a4464f4cc00ee9a181c0).

Is it possible it was overlooked when #50723 was fixed?

@euclio
Copy link
Contributor Author

euclio commented Oct 28, 2021

I did a quick bisect, and this was fixed by #87296. Closing.

@euclio euclio closed this as completed Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: #[attributes(..)] A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
Projects
None yet
Development

No branches or pull requests

4 participants