Don't merge cfg and doc(cfg) attributes for re-exports - #113091
Conversation
This comment has been minimized.
This comment has been minimized.
cffeed8 to
cd5cf8e
Compare
This comment has been minimized.
This comment has been minimized.
|
The test failures are expected, my argument in the issue is that those tests are wrong. (I didn't go looking to see whether there's other tests that I'd expect to fail but didn't). |
|
Sorry should have precised: just realized that this wasn't ready yet. I'm finishing another PR first then coming back to this one. |
cd5cf8e to
3bc899a
Compare
|
It's now ready. So in any case, this will need to go through an FCP. But I'm personally not a big fan of this change:
Anyway, that was my two cents on this. We'll see what the others think about it. |
The compilation failure will be triggered at the reexport site, or in other words, I'd consider it a bug if the item is not provided. Another thing that speaks in favour of this PR is that there is often patterns like: #[cfg(target_os = "linux")]
mod impl {
pub fn foo() { /* impl for linux */ }
}
#[cfg(target_os = "windows")]
mod impl {
pub fn foo() { /* impl for linux */ }
}
use impl::foo;Here, there should ideally be no cfg documented as there is implementations for all operating systems. |
|
But in this case, there is no #[cfg(target_os = "linux")]
pub fn foo() { /* impl for linux */ }
#[cfg(target_os = "windows")]
pub fn foo() { /* impl for windows */ }
pub use self::foo as reexport; |
|
(I would suggest maybe doing FCP in the issue since that's where I documented my rationale for the change). |
|
You could also start it here and add an explanation text too. As you prefer. |
|
@rfcbot pr merge My reasoning for this change from the issue: When re-exporting things with different cfgs there are two things that can happen:
This only applies to non-glob inlined re-exports, for glob re-exports the item may or may not exist to be re-exported (potentially the cfgs on the path up until the glob can be removed, and only cfgs on the globbed item itself matter, but I haven't thought through all the details), for non-inlined re-exports see #85043. |
|
Team member @Nemo157 has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
☔ The latest upstream changes (presumably #114115) made this pull request unmergeable. Please resolve the merge conflicts. |
4be2842 to
be881f8
Compare
|
Fixed merge conflict. |
|
☔ The latest upstream changes (presumably #117875) made this pull request unmergeable. Please resolve the merge conflicts. |
be881f8 to
823148f
Compare
|
Fixed merged conflict. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
|
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
commented
Dec 15, 2023
|
@bors r=rustdoc |

Fixes #112881.
Explanations
When re-exporting things with different
cfgs there are two things that can happen:cfgs, this subset is sufficient so that the item will appear exactly with the subsetcfgs (e.g. like the example I posted just above where the re-export is ungated), if the non-subsetcfgs are active (e.g. compiling that example on windows) then this will be a compile error as the item doesn't exist to re-export, if the subsetcfgs are active it behaves like 1.Glob re-exports?
This only applies to non-glob inlined re-exports. For glob re-exports the item may or may not exist to be re-exported (potentially the
cfgs on the path up until the glob can be removed, and onlycfgs on the globbed item itself matter), for non-inlined re-exports see #85043.cc @Nemo157
r? @notriddle