forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#108057 - GuillaumeGomez:fix-reexport-attr-m…
…erge, r=notriddle Prevent some attributes from being merged with others on reexports Final fix for rust-lang#59368. As discussed on zulip [here](https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Filtering.20sub.20attributes.20in.20ast.3A.3AAttribute), we need to clone the `Attribute` to be able to filter some parts of it. Then we need to go through the attributes to able to only keep what we want (everything except a few attributes in short). As for the second commit, when I wrote the test, I realized that the code to traverse all reexports one by one to collect all their attributes was not completely working so I fixed the few issues remaining. r? `@notriddle`
- Loading branch information
Showing
2 changed files
with
178 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Regression test for <https://github.com/rust-lang/rust/issues/59368>. | ||
// The goal is to ensure that `doc(hidden)`, `doc(inline)` and `doc(no_inline)` | ||
// are not copied from an item when inlined. | ||
|
||
#![crate_name = "foo"] | ||
#![feature(doc_cfg)] | ||
|
||
// @has 'foo/index.html' | ||
|
||
#[doc(hidden, cfg(feature = "foo"))] | ||
pub struct Foo; | ||
|
||
#[doc(hidden, no_inline, cfg(feature = "bar"))] | ||
pub use Foo as Foo1; | ||
|
||
#[doc(hidden, inline)] | ||
pub use Foo1 as Foo2; | ||
|
||
// First we ensure that only the reexport `Bar2` and the inlined struct `Bar` | ||
// are inlined. | ||
// @count - '//a[@class="struct"]' 2 | ||
// Then we check that both `cfg` are displayed. | ||
// @has - '//*[@class="stab portability"]' 'foo' | ||
// @has - '//*[@class="stab portability"]' 'bar' | ||
// And finally we check that the only element displayed is `Bar`. | ||
// @has - '//a[@class="struct"]' 'Bar' | ||
#[doc(inline)] | ||
pub use Foo2 as Bar; | ||
|
||
// This one should appear but `Bar2` won't be linked because there is no | ||
// `#[doc(inline)]`. | ||
// @has - '//*[@id="reexport.Bar2"]' 'pub use Foo2 as Bar2;' | ||
pub use Foo2 as Bar2; |