[rustdoc] Retrieve cfg_attr information for derived impls for doc_cfg feature#159722
Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs cc @jdonszelmann, @JonathanBrouwer
cc @rust-lang/clippy Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
cfg_attr information for derived impls for doc_cfg featurecfg_attr information for derived impls for doc_cfg feature
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
[rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
e9bff38 to
42ec8ee
Compare
|
@bors try- |
|
Unknown command "try-". Run |
|
@bors try cancel |
|
Try build cancelled. Cancelled workflows: |
|
@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.
[rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature
|
LGTM, r=me when CI and perf are green, unless you want an additional rustdoc review from someone else. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Can you update the pr description as well? The implementation looks good to me, maybe consider a review from someone familiar with rustdoc. Up to you. |
|
Updated description. Just in case: r? @Urgau |
|
Another cleaver use of PR looks good to me as well. @bors r=petrochenkov,mejrs,Urgau |
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
…=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes rust-lang#103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc rust-lang#43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
Rollup of 12 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159666 (fix(ld64.lld): route version mismatch warnings to linker_info on macOS) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup of 14 pull requests Successful merges: - #159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - #159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - #158362 (trait solver: account for universes from replace_bound_vars) - #158372 (rustfmt: Discover modules via `cfg_select!`) - #159173 (Add allowed list check on EII implementations attributes) - #159718 (Make `DocLinkResMap` an `FxIndexMap`) - #159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - #159731 (std: Implement futex on wasip3 targets, update target spec) - #159755 (Improve consistency of attribute error messages) - #155795 (constify `vec![1, 2, 3]` macro) - #157776 (ci: Enable autodiff tests on x86_64 linux) - #158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - #159271 (str: add ASCII fast path to word_to_titlecase) - #159667 (Make some parser structured suggestions verbose and tweak their wording)
Rollup merge of #159722 - GuillaumeGomez:cfg_attr-doc_cfg, r=petrochenkov,mejrs,Urgau [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature Fixes #103300. After long last, this PR finally allows the derive proc-macro `cfg_attr` cfg predicates information to be kept so rustdoc can use it for its `doc_cfg` feature (cc #43781). It works as follows: for `impl` generated by macro expansion, we then look for the attributes on the type for which the `impl` block is implemented. Then, to know which `cfg_attr` attribute we want to look at, we use `expn_that_defined` on the impl's `DefId` which returns the `Span` where the macro was expanded. If it's part of a `cfg_attr`, then the `cfg_attr`'s `Span` will contain the derive's, so from then, we just need to add the `cfg` information. This PR also adds the cfg predicates into the `AttributeKind::CfgAttrTrace` variant so it can be reused by rustdoc (hence the `compiler/*` changes). Thanks a lot @petrochenkov for the pointers here! r? @petrochenkov
Rollup of 14 pull requests Successful merges: - rust-lang/rust#159765 (Avoid spurious rebuilds of JSON docs in bootstrap) - rust-lang/rust#159781 (Update bootstrap to use -Zembed-metadata=no instead of -Zno-embed-metadata) - rust-lang/rust#158362 (trait solver: account for universes from replace_bound_vars) - rust-lang/rust#158372 (rustfmt: Discover modules via `cfg_select!`) - rust-lang/rust#159173 (Add allowed list check on EII implementations attributes) - rust-lang/rust#159718 (Make `DocLinkResMap` an `FxIndexMap`) - rust-lang/rust#159722 ( [rustdoc] Retrieve `cfg_attr` information for derived impls for `doc_cfg` feature) - rust-lang/rust#159731 (std: Implement futex on wasip3 targets, update target spec) - rust-lang/rust#159755 (Improve consistency of attribute error messages) - rust-lang/rust#155795 (constify `vec![1, 2, 3]` macro) - rust-lang/rust#157776 (ci: Enable autodiff tests on x86_64 linux) - rust-lang/rust#158766 (Promote riscv64-unknown-linux-musl to tier 2 with host tools) - rust-lang/rust#159271 (str: add ASCII fast path to word_to_titlecase) - rust-lang/rust#159667 (Make some parser structured suggestions verbose and tweak their wording)
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
Minor `rustc_ast::ast` doc cleanups `P` is an outdated reference. `CfgAttrTrace` was updated in rust-lang#159722 Docs were formatted so that the entire paragraph doesn't show up on the module level docs (pet peeve of mine). r? @nnethercote
View all comments
Fixes #103300.
After long last, this PR finally allows the derive proc-macro
cfg_attrcfg predicates information to be kept so rustdoc can use it for itsdoc_cfgfeature (cc #43781).It works as follows: for
implgenerated by macro expansion, we then look for the attributes on the type for which theimplblock is implemented. Then, to know whichcfg_attrattribute we want to look at, we useexpn_that_definedon the impl'sDefIdwhich returns theSpanwhere the macro was expanded. If it's part of acfg_attr, then thecfg_attr'sSpanwill contain the derive's, so from then, we just need to add thecfginformation.This PR also adds the cfg predicates into the
AttributeKind::CfgAttrTracevariant so it can be reused by rustdoc (hence thecompiler/*changes).Thanks a lot @petrochenkov for the pointers here!
r? @petrochenkov