-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Fix invalid add of duplicated call locations for the rustdoc scraped examples feature #154017
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
Merged
rust-bors
merged 2 commits into
rust-lang:main
from
GuillaumeGomez:duplicated-locs-scraped
Mar 24, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
10 changes: 10 additions & 0 deletions
10
tests/run-make-cargo/rustdoc-scrape-examples-duplicated-calls/Cargo.toml
This file contains hidden or 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,10 @@ | ||
| [workspace] | ||
|
|
||
| [package] | ||
| edition = "2024" | ||
| name = "tester" | ||
| version = "0.1.0" | ||
|
|
||
| [[example]] | ||
| doc-scrape-examples = true | ||
| name = "window" |
24 changes: 24 additions & 0 deletions
24
tests/run-make-cargo/rustdoc-scrape-examples-duplicated-calls/examples/window.rs
This file contains hidden or 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,24 @@ | ||
| #![allow(dead_code)] | ||
| use tester::Window; | ||
|
|
||
| macro_rules! info { | ||
| ($s:literal, $x:expr) => {{ | ||
| let _ = $x; | ||
| }}; | ||
| } | ||
|
|
||
| struct WindowState { | ||
| window: Window, | ||
| } | ||
|
|
||
| impl WindowState { | ||
| fn takes_ref(&self) { | ||
| info!("{:?}", self.window.id()); | ||
| } | ||
|
|
||
| fn takes_mut(&mut self) { | ||
| info!("{:?}", self.window.id()); | ||
| } | ||
| } | ||
|
|
||
| fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/run-make-cargo/rustdoc-scrape-examples-duplicated-calls/rmake.rs
This file contains hidden or 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,11 @@ | ||
| //! This test ensures that the call locations are not duplicated when generating scraped examples. | ||
| //! To ensure that, we check that this call doesn't fail. | ||
| //! Regression test for <https://github.com/rust-lang/rust/issues/153837>. | ||
|
|
||
| use run_make_support::{cargo, htmldocck}; | ||
|
|
||
| fn main() { | ||
| cargo().args(["rustdoc", "-Zunstable-options", "-Zrustdoc-scrape-examples"]).run(); | ||
Urgau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| htmldocck().arg("target/doc").arg("src/lib.rs").run(); | ||
| } | ||
13 changes: 13 additions & 0 deletions
13
tests/run-make-cargo/rustdoc-scrape-examples-duplicated-calls/src/lib.rs
This file contains hidden or 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,13 @@ | ||
| //@has tester/struct.Window.html | ||
| //@count - '//*[@class="docblock scraped-example-list"]//span[@class="highlight"]' 1 | ||
| //@has - '//*[@class="docblock scraped-example-list"]//span[@class="highlight"]' 'id' | ||
| //@count - '//*[@class="docblock scraped-example-list"]//span[@class="highlight focus"]' 1 | ||
| //@has - '//*[@class="docblock scraped-example-list"]//span[@class="highlight focus"]' 'id' | ||
|
|
||
| pub struct Window {} | ||
|
|
||
| impl Window { | ||
| pub fn id(&self) -> u64 { | ||
| todo!() | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 test is sadly lacking: the only way to ensure it works is to check it didn't fail to generate docs with the feature... Would be better to look at the generated
target/debug/deps/*.examplefile but that would involve to reparse it, including compiler crates, etc. And unless I missed something obvious, there is sadly no easy way to achieve that...