Add regression test for #153837

This commit is contained in:
Guillaume Gomez
2026-03-17 22:53:48 +01:00
parent 7d82c5dab3
commit c399464211
4 changed files with 58 additions and 0 deletions
@@ -0,0 +1,10 @@
[workspace]
[package]
edition = "2024"
name = "tester"
version = "0.1.0"
[[example]]
doc-scrape-examples = true
name = "window"
@@ -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() {}
@@ -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();
htmldocck().arg("target/doc").arg("src/lib.rs").run();
}
@@ -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!()
}
}