Skip to content

MCP: pub(macro) #59

@eopb

Description

@eopb

Proposal

Summary and problem statement

This idea came from this line of code from the log crate https://github.com/rust-lang/log/blob/master/src/lib.rs#L1441

There is currently no way of keeping a function private while also using them in a public macro. This causes crate developers to resort to warning comments and function name prefixes.

With my feature, functions marked pub(macro) would become public to macros defined in the same crate.

Motivation, use-cases, and solution sketches

With my feature

// WARNING: this is not part of the crate's public API and is subject to change at any time	 
#[doc(hidden)]	 
pub fn __private_api_log(

would become

pub(macro) fn log(

Prioritization

This fits with "Targeted ergonomic wins and extensions". Warning comments and function prefixes do not feel ergonomic.

Links and related work

I understand that hygienic macros could make this feature no longer needed in future. I hope this could act as a smaller, easier to implement incremental step.

rust-lang/rfcs#2968

Initial people involved

TBD

What happens now?

This issue is part of the experimental MCP process described in RFC 2936. Once this issue is filed, a Zulip topic will be opened for discussion, and the lang-team will review open MCPs in its weekly triage meetings. You should receive feedback within a week or two.

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-langdisposition-closeThe FCP starter wants to close thisfinal-comment-periodThe FCP has started, most (if not all) team members are in agreementmajor-changeMajor change proposalto-announceNot yet announced MCP proposals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions