Skip to content

Commit 0d588e9

Browse files
committed
rustdoc: Fix incorrect usage of @!has and @!matches
`@!has` (and `@!matches`) with two arguments used to treat the second argument as a literal string of HTML code. Now, that feature has been renamed into `@!hasraw` (and `@!matchesraw`), and the arity-2 `@!has` version is an error. These uses thought the second argument was being treated as an XPath, as with the arity-3 version, but in fact was being treated as literal HTML. Because these were checking for the *absence* of the string, the tests silently did nothing -- an XPath string won't ever be showing up in the test's generated HTML!
1 parent b34e240 commit 0d588e9

11 files changed

+24
-22
lines changed

src/test/rustdoc/internal.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
// Check that the unstable marker is not added for "rustc_private".
44

5-
// @!matchesraw internal/index.html \
6-
// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]'
7-
// @!matchesraw internal/index.html \
8-
// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]'
5+
// @!matches internal/index.html \
6+
// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' \
7+
// ''
8+
// @!matches internal/index.html \
9+
// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' \
10+
// ''
911
// @matches - '//*[@class="item-right docblock-short"]' 'Docs'
1012

11-
// @!hasraw internal/struct.S.html '//*[@class="stab unstable"]'
12-
// @!hasraw internal/struct.S.html '//*[@class="stab internal"]'
13+
// @!has internal/struct.S.html '//*[@class="stab unstable"]' ''
14+
// @!has internal/struct.S.html '//*[@class="stab internal"]' ''
1315
/// Docs
1416
pub struct S;
1517

src/test/rustdoc/issue-61592.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ extern crate foo;
55
// @has issue_61592/index.html
66
// @has - '//a[@href="#reexports"]' 'Re-exports'
77
// @has - '//code' 'pub use foo::FooTrait as _;'
8-
// @!hasraw - '//a[@href="trait._.html"]'
8+
// @!has - '//a[@href="trait._.html"]' ''
99
pub use foo::FooTrait as _;
1010

1111
// @has issue_61592/index.html
1212
// @has - '//a[@href="#reexports"]' 'Re-exports'
1313
// @has - '//code' 'pub use foo::FooStruct as _;'
14-
// @!hasraw - '//a[@href="struct._.html"]'
14+
// @!has - '//a[@href="struct._.html"]' ''
1515
pub use foo::FooStruct as _;

src/test/rustdoc/no-crate-filter.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
// compile-flags: -Z unstable-options --disable-per-crate-search
44

5-
// @!hasraw 'foo/struct.Foo.html' '//*[id="crate-search"]'
5+
// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' ''
66
pub struct Foo;

src/test/rustdoc/recursive-deref.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl G {
5151

5252
// @has recursive_deref/struct.D.html '//h3[@class="code-header in-band"]' 'impl Deref for D'
5353
// We also check that `G::g` method isn't rendered because there is no `self` argument.
54-
// @!hasraw '-' '//*[@id="deref-methods-G"]'
54+
// @!has '-' '//*[@id="deref-methods-G"]' ''
5555
impl Deref for D {
5656
type Target = E;
5757

@@ -62,7 +62,7 @@ impl Deref for D {
6262

6363
// @has recursive_deref/struct.E.html '//h3[@class="code-header in-band"]' 'impl Deref for E'
6464
// We also check that `G::g` method isn't rendered because there is no `self` argument.
65-
// @!hasraw '-' '//*[@id="deref-methods-G"]'
65+
// @!has '-' '//*[@id="deref-methods-G"]' ''
6666
impl Deref for E {
6767
type Target = F;
6868

@@ -73,7 +73,7 @@ impl Deref for E {
7373

7474
// @has recursive_deref/struct.F.html '//h3[@class="code-header in-band"]' 'impl Deref for F'
7575
// We also check that `G::g` method isn't rendered because there is no `self` argument.
76-
// @!hasraw '-' '//*[@id="deref-methods-G"]'
76+
// @!has '-' '//*[@id="deref-methods-G"]' ''
7777
impl Deref for F {
7878
type Target = G;
7979

@@ -101,7 +101,7 @@ impl I {
101101
}
102102

103103
// @has recursive_deref/struct.H.html '//h3[@class="code-header in-band"]' 'impl Deref for H'
104-
// @!hasraw '-' '//*[@id="deref-methods-I"]'
104+
// @!has '-' '//*[@id="deref-methods-I"]' ''
105105
impl Deref for H {
106106
type Target = I;
107107

src/test/rustdoc/remove-url-from-headings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![crate_name = "foo"]
22

33
// @has foo/fn.foo.html
4-
// @!hasraw - '//a[@href="http://a.a"]'
4+
// @!has - '//a[@href="http://a.a"]' ''
55
// @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere'
66
// @has - '//a[@href="#another-one-urg"]' 'Another one urg'
77

src/test/rustdoc/sized_trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
#![crate_name = "foo"]
22

33
// @has foo/struct.Bar.html
4-
// @!hasraw - '//*[@id="impl-Sized"]'
4+
// @!has - '//*[@id="impl-Sized"]' ''
55
pub struct Bar {
66
a: u16,
77
}
88

99
// @has foo/struct.Foo.html
10-
// @!hasraw - '//*[@id="impl-Sized"]'
10+
// @!has - '//*[@id="impl-Sized"]' ''
1111
pub struct Foo<T: ?Sized>(T);
1212

1313
// @has foo/struct.Unsized.html

src/test/rustdoc/table-in-docblock.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// @has foo/struct.Foo.html
44
// @count - '//*[@class="docblock"]/div/table' 2
5-
// @!hasraw - '//*[@class="docblock"]/table'
5+
// @!has - '//*[@class="docblock"]/table' ''
66
/// | hello | hello2 |
77
/// | ----- | ------ |
88
/// | data | data2 |

src/test/rustdoc/toggle-item-contents.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct PrivStruct {
6262
}
6363

6464
// @has 'toggle_item_contents/enum.Enum.html'
65-
// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]'
65+
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' ''
6666
pub enum Enum {
6767
A, B, C,
6868
D {
@@ -72,7 +72,7 @@ pub enum Enum {
7272
}
7373

7474
// @has 'toggle_item_contents/enum.EnumStructVariant.html'
75-
// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]'
75+
// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' ''
7676
pub enum EnumStructVariant {
7777
A, B, C,
7878
D {

src/test/rustdoc/trait-impl-items-links-and-anchors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub struct MyStruct;
5959

6060
// We check that associated items with default values aren't generated in the implementors list.
6161
impl MyTrait for (u8, u8) {
62-
// @!hasraw trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]'
62+
// @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' ''
6363
type Assoc = bool;
6464
fn trait_function(&self) {}
6565
}

src/test/rustdoc/trait-impl.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Trait for Struct {
4040
fn c() {}
4141

4242
// @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works'
43-
// @!hasraw - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em'
43+
// @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' ''
4444
fn d() {}
4545

4646
// @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html'

src/test/rustdoc/tuple-struct-fields-doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields'
66
// @has - '//*[@id="structfield.0"]' '0: u32'
77
// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello'
8-
// @!hasraw - '//*[@id="structfield.1"]'
8+
// @!has - '//*[@id="structfield.1"]' ''
99
// @has - '//*[@id="structfield.2"]' '2: char'
1010
// @has - '//*[@id="structfield.3"]' '3: i8'
1111
// @has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello'

0 commit comments

Comments
 (0)