Skip to content

rustc_parse: restore public visibility on parse_attribute #79433

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

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions compiler/rustc_parse/src/parser/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use rustc_span::{sym, Span};

use tracing::debug;

// Public for rustfmt usage
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot make this private if parse_attribute is public, so the comment seems unnecessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can remove this if you'd prefer, but I've been trying to be very explicit about calling out instances where rustfmt ends up needing a higher visibility on something within the compiler than what would've been done otherwise.

Naturally the public visibility on the function requires this to be public as well, and in this case the two happen to be in the same file and fairly close together. However, I just think that for anyone looking at this code down the road and wondering "why is this enum public?" that it's beneficial to have the inline comment in context vs. having to do a search to find the comment on the function or reducing the visibility to try to let the compiler tell them.

Let me know how you'd like to proceed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, leaving this at your discretion.

#[derive(Debug)]
pub(super) enum InnerAttrPolicy<'a> {
pub enum InnerAttrPolicy<'a> {
Permitted,
Forbidden { reason: &'a str, saw_doc_comment: bool, prev_attr_sp: Option<Span> },
}
Expand Down Expand Up @@ -78,7 +79,8 @@ impl<'a> Parser<'a> {

/// Matches `attribute = # ! [ meta_item ]`.
/// `inner_parse_policy` prescribes how to handle inner attributes.
fn parse_attribute(
// Public for rustfmt usage.
pub fn parse_attribute(
&mut self,
inner_parse_policy: InnerAttrPolicy<'_>,
) -> PResult<'a, ast::Attribute> {
Expand Down