Skip to content

Disallow cfg attribute (maybe others) on generic parameters #51279

Closed
@Havvy

Description

@Havvy

As of 1.27, it is legal to put attributes on generic parameters. E.g. fn foo<#[allow(dead_code)] T>(_t: T){}, although none of the current attributes do anything. This includes attributes we may want to use in the future, such as cfg. To avoid doing the warning song and dance we did with #[must_use] on functions, we should disallow them before the feature actually stabilizes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)T-langRelevant to the language team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions