-
Notifications
You must be signed in to change notification settings - Fork 903
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
Reapply "Initial work on formatting headers" #6457
base: master
Are you sure you want to change the base?
Conversation
This reverts commit f2c84b5.
#[derive(Debug)] | ||
pub(crate) struct HeaderPart { | ||
/// snippet of this part without surrounding space | ||
snippet: Cow<'static, str>, | ||
span: Span, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the snippet
need to be a Cow<'static, str>
? Could we make it a Cow<'a, str>
or are there lifetime issues that prevent that?
Self { | ||
snippet: rewrite_ident(context, ident).to_owned().into(), | ||
span: ident.span, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be implemented in terms of HeaderPart::new
? Would save you needing to call .into()
.
Self { | |
snippet: rewrite_ident(context, ident).to_owned().into(), | |
span: ident.span, | |
} | |
let snippet = rewrite_ident(context, ident).to_owned(); | |
Self::new(snippet, ident.span) |
If we can make HeaderPart
hold a Cow<'a, str>
, then this could probably be written as:
Self::new(rewrite_ident(context, ident), ident.span)
let path = segments_iter.collect::<Vec<_>>().join("::"); | ||
let in_str = if is_keyword(&path) { "" } else { "in " }; | ||
|
||
Cow::from(format!("pub({}{})", in_str, path)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not something that we need to fix right now, but we're potentially missing comments within the visibility modifier. e.g pub( /* comment */ crate /* comment */)
.
As per this comment.
This reimplements the header formatting infrastructure to resume porting to this system, if there are comments between header parts, we preserve the original whitespace/comments snippet instead of realigning/reformatting them.
This reverts commit f2c84b5.