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

Attribute paths are not checked for absence of generic arguments #43424

Closed
petrochenkov opened this issue Jul 23, 2017 · 5 comments
Closed

Attribute paths are not checked for absence of generic arguments #43424

petrochenkov opened this issue Jul 23, 2017 · 5 comments
Assignees
Labels
A-attributes Area: #[attributes(..)] A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions C-bug Category: This is a bug. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

E.g. this successfully compiles on stable 1.19 / beta 1.20 /nightly

#![allow(unused)]

macro_rules! m {
    ($attr_path: path) => {
        #[$attr_path]
        fn f() {}
    }
}

m!(inline<'nonexistent_lifetime, u8, NonExistentType>);

fn main() {}

There are too many kinds of attributes - built in, custom, derives, legacy derives, procedural macros, legacy procedural macros, maybe something else - I'm not sure which of them are affected. Many of these attributes are removed from AST during expansion, so simply adding a check into AST validation pass won't be enough, the checking needs to be done during expansion, like for macro paths (

let msg = format!("type parameters are not allowed on {}s", kind);
).

cc @jseyfried

@petrochenkov petrochenkov added A-attributes Area: #[attributes(..)] A-macros Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..) A-syntaxext Area: Syntax extensions labels Jul 23, 2017
@petrochenkov
Copy link
Contributor Author

This is a regression from Rust 1.18, before that paths weren't accepted in attributes.

@petrochenkov petrochenkov added the regression-from-stable-to-stable Performance or correctness regression from one stable version to another. label Jul 23, 2017
@jseyfried jseyfried self-assigned this Jul 23, 2017
@Mark-Simulacrum Mark-Simulacrum added P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. I-nominated labels Jul 27, 2017
@Mark-Simulacrum
Copy link
Member

Nominating for prioritization.

@Mark-Simulacrum Mark-Simulacrum added P-high High priority and removed P-medium Medium priority labels Jul 27, 2017
@alexcrichton
Copy link
Member

cc @rust-lang/compiler

@Mark-Simulacrum Mark-Simulacrum added the C-bug Category: This is a bug. label Jul 28, 2017
@jseyfried
Copy link
Contributor

Sorry for delay; still working on this.

@jseyfried
Copy link
Contributor

Fixed in #43948.

bors added a commit that referenced this issue Aug 23, 2017
…henkov

Ensure that generic arguments don't end up in attribute paths.

Fixes #43424.
r? @petrochenkov or @nrc
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, ..) A-syntaxext Area: Syntax extensions C-bug Category: This is a bug. P-high High priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants