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

Comments

Projects
None yet
5 participants
@petrochenkov
Copy link
Contributor

petrochenkov commented Jul 23, 2017

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

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Jul 23, 2017

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

@Mark-Simulacrum

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jul 27, 2017

Nominating for prioritization.

@Mark-Simulacrum Mark-Simulacrum added P-high and removed P-medium labels Jul 27, 2017

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 27, 2017

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented Aug 3, 2017

Sorry for delay; still working on this.

@jseyfried

This comment has been minimized.

Copy link
Contributor

jseyfried commented Aug 17, 2017

Fixed in #43948.

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

Auto merge of #43948 - jseyfried:generic_arguments_in_paths, r=petroc…
…henkov

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

Fixes #43424.
r? @petrochenkov or @nrc

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

Auto merge of #43948 - jseyfried:generic_arguments_in_paths, r=petroc…
…henkov

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

Fixes #43424.
r? @petrochenkov or @nrc

@bors bors closed this in #43948 Aug 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.