Skip to content

#[used] should work on functions #68322

Open
@jonas-schievink

Description

Currently #[used] only works on static items. It would be more consistent and useful if it also worked on functions.

My motivation for this is to prevent some cases of user errors when using cortex-m-rt's #[exception] and #[interrupt] attributes. As can be seen in this test, it is possible to use those inside of private modules, which results in the function never ending up in the binary.

Note that #[used] cannot be made to work on functions that have generics in scope, since those can end up producing arbitrary monomorphizations depending on the parameters (and there's no single canonical thing that #[used] would make show up in the binary).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-attributesArea: Attributes (`#[…]`, `#![…]`)A-linkageArea: linking into static, shared libraries and binariesC-feature-requestCategory: A feature request, i.e: not implemented / a PR.T-langRelevant to the language team, which will review and decide on the PR/issue.WG-embeddedWorking group: Embedded systems

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions