-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Port doc attributes to new attribute API
#149645
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
base: main
Are you sure you want to change the base?
Conversation
|
Some changes occurred in compiler/rustc_passes/src/check_attr.rs Some changes occurred in compiler/rustc_attr_parsing These commits modify the If this was unintentional then you should revert the changes before this PR is merged. Some changes occurred in compiler/rustc_hir/src/attrs |
|
Just to be safe: @bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Port `doc` attributes to new attribute API
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
fc40ba1 to
b27592e
Compare
This comment has been minimized.
This comment has been minimized.
|
Ah right, forgot about clippy. Updating it as well. |
|
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (4f24013): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -0.2%, secondary 1.5%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (secondary 2.0%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.5%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 468.725s -> 473.041s (0.92%) |
|
Strange, one doc test has a regression but all others are faster. |
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #149646) made this pull request unmergeable. Please resolve the merge conflicts. |
|
I'd say since perf looks very good on primary benchmarks and is mixed on secondary benchmarks, I'm happy with perf as-is. I am wondering what caused the regression on |
…tEmitter` instead of `NodeId`
…g::cfg_matches` API
db01fba to
fc00bb8
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
fc00bb8 to
f657ca7
Compare
| ConstStabilityParser, | ||
| DocParser, | ||
| MacroUseParser, | ||
|
|
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.
nit: extra newline
| @@ -0,0 +1,571 @@ | |||
| // FIXME: to be removed | |||
| #![allow(unused_imports)] | |||
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.
nit: Can you remove this one?
| // if self.attribute.$ident.is_some() { | ||
| // cx.duplicate_key(path.span(), path.word_sym().unwrap()); | ||
| // return; | ||
| // } |
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 leaving this out cause a regression? If so please fix, otherwise we can leave it like this
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.
No, the opposite. If we uncomment it, bootstrap command will fail because rustdoc args are duplicated. Gonna need to fix that.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
649f660 to
9d4ba5b
Compare
|
The job Click to see the possible cause of the failure (guessed by this bot) |
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.
I did a first pass through all the code changes (not the tests yet). Will probably do a second pass because I went quite quickly and might've missed things, but this should be most of it
| pub no_crate_inject: Option<Span>, | ||
| } | ||
|
|
||
| impl Default for DocAttribute { |
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.
Is this different from a derive(Default)? If not, lets derive this
| span, | ||
| errors::DocInlineOnlyUse { | ||
| attr_span: meta.span(), | ||
| item_span: (style == AttrStyle::Outer).then(|| self.tcx.hir_span(hir_id)), |
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.
I see a bunch of these checks got removed, why?
| self.check_doc_search_unbox(meta, hir_id); | ||
| } | ||
| } | ||
| fn check_doc_attrs(&self, attr: &DocAttribute, hir_id: HirId, target: Target) { |
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.
Ooh I love how much nicer this file got, ty :3
| | CfgEntry::NameValue { .. } | ||
| | CfgEntry::Not(..) | ||
| | CfgEntry::Version(..) | ||
| | CfgEntry::All(..) => true, |
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 we recursively check for an Any inside the All here?
| if cfgs.is_empty() { None } else { Some(CfgEntry::All(cfgs, DUMMY_SP)) } | ||
| } | ||
| CfgEntry::Version(..) => { | ||
| // FIXME: Should be handled. |
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.
Why is this not handled the way it is?
| { | ||
| let mut iter = stream.into_iter().peekable(); | ||
| while let Some(token) = iter.next() { | ||
| if let TokenTree::Ident(i) = token { |
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.
This code silently fails if the span does not match the expected structure of an attribute. Is there anywhere we check that it does match it, and error otherwise?
Fine with this hack (honestly surprisingly elegant) but I'm anticipating this hack might be hard to fix and this code might be here for a while, wanna make sure it's not silently failing while it is
| let i = i.to_string(); | ||
| let peek = iter.peek(); | ||
| match peek { | ||
| Some(TokenTree::Group(g)) => { |
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.
I don't fully understand the cases in this match here, could you add some clarifying comments?
| Attribute::Parsed(AttributeKind::Doc(d)) if !d.cfg.is_empty() => { | ||
| let mut new_attr = DocAttribute::default(); | ||
| new_attr.cfg = d.cfg.clone(); | ||
| Some(Attribute::Parsed(AttributeKind::Doc(Box::new(new_attr)))) |
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.
Why are we doing this weird clone of only the cfg condition here? Performance?
(If so, please add a comment explaining it)
| indexmap = { version = "2", features = ["serde"] } | ||
| itertools = "0.12" | ||
| minifier = { version = "0.3.5", default-features = false } | ||
| proc-macro2 = "1.0.103" |
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.
Could we use TokenStream from rustc_ast instead of proc-macro2? Is that better/worse?
| for lint in &delayed_lints.lints { | ||
| match lint { | ||
| DelayedLint::AttributeParsing(attribute_lint) => { | ||
| rustc_attr_parsing::emit_attribute_lint(attribute_lint, tcx) |
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.
This will slightly change after you rebase, but should be easy enough to fix
|
☔ The latest upstream changes (presumably #149701) made this pull request unmergeable. Please resolve the merge conflicts. |
Part of #131229.
This PR ports the
docattributes to the new attribute API. However, there are things that will need to be fixed in a follow-up:cfg_old.rsare likely unused now, so they should be removed.doc(test(attr(...)))is handled in a horrifying manner currently. Until we can handle it correctly with theAttributesystem, it'll remain that thing we're all very ashamed of. 😈Docare suboptimal, likeinlinewhich instead of being anOptionis aThinVecbecause we report the error later on. Part of the things I'm not super happy about but can be postponed to future me.And finally, once this PR is merged, I plan to finally stabilize
doc_cfgfeature. :)cc @jdonszelmann
r? @JonathanBrouwer