Skip to content

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

Closed
@petrochenkov

Description

@petrochenkov

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

Metadata

Metadata

Assignees

Labels

A-attributesArea: Attributes (`#[…]`, `#![…]`)A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)A-syntaxextArea: Syntax extensionsC-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions