From 0d588e928e7db77f9a810b1b5de02521dbf5ee5e Mon Sep 17 00:00:00 2001 From: Noah Lev Date: Sat, 13 Aug 2022 00:56:16 -0400 Subject: [PATCH] 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! --- src/test/rustdoc/internal.rs | 14 ++++++++------ src/test/rustdoc/issue-61592.rs | 4 ++-- src/test/rustdoc/no-crate-filter.rs | 2 +- src/test/rustdoc/recursive-deref.rs | 8 ++++---- src/test/rustdoc/remove-url-from-headings.rs | 2 +- src/test/rustdoc/sized_trait.rs | 4 ++-- src/test/rustdoc/table-in-docblock.rs | 2 +- src/test/rustdoc/toggle-item-contents.rs | 4 ++-- .../rustdoc/trait-impl-items-links-and-anchors.rs | 2 +- src/test/rustdoc/trait-impl.rs | 2 +- src/test/rustdoc/tuple-struct-fields-doc.rs | 2 +- 11 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/test/rustdoc/internal.rs b/src/test/rustdoc/internal.rs index 572ec0e1d93..caad43a087c 100644 --- a/src/test/rustdoc/internal.rs +++ b/src/test/rustdoc/internal.rs @@ -2,14 +2,16 @@ // Check that the unstable marker is not added for "rustc_private". -// @!matchesraw internal/index.html \ -// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' -// @!matchesraw internal/index.html \ -// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' +// @!matches internal/index.html \ +// '//*[@class="item-right docblock-short"]/span[@class="stab unstable"]' \ +// '' +// @!matches internal/index.html \ +// '//*[@class="item-right docblock-short"]/span[@class="stab internal"]' \ +// '' // @matches - '//*[@class="item-right docblock-short"]' 'Docs' -// @!hasraw internal/struct.S.html '//*[@class="stab unstable"]' -// @!hasraw internal/struct.S.html '//*[@class="stab internal"]' +// @!has internal/struct.S.html '//*[@class="stab unstable"]' '' +// @!has internal/struct.S.html '//*[@class="stab internal"]' '' /// Docs pub struct S; diff --git a/src/test/rustdoc/issue-61592.rs b/src/test/rustdoc/issue-61592.rs index 3adeb751d33..4b6c37b94aa 100644 --- a/src/test/rustdoc/issue-61592.rs +++ b/src/test/rustdoc/issue-61592.rs @@ -5,11 +5,11 @@ extern crate foo; // @has issue_61592/index.html // @has - '//a[@href="#reexports"]' 'Re-exports' // @has - '//code' 'pub use foo::FooTrait as _;' -// @!hasraw - '//a[@href="trait._.html"]' +// @!has - '//a[@href="trait._.html"]' '' pub use foo::FooTrait as _; // @has issue_61592/index.html // @has - '//a[@href="#reexports"]' 'Re-exports' // @has - '//code' 'pub use foo::FooStruct as _;' -// @!hasraw - '//a[@href="struct._.html"]' +// @!has - '//a[@href="struct._.html"]' '' pub use foo::FooStruct as _; diff --git a/src/test/rustdoc/no-crate-filter.rs b/src/test/rustdoc/no-crate-filter.rs index d11c66b54ea..b2f89906480 100644 --- a/src/test/rustdoc/no-crate-filter.rs +++ b/src/test/rustdoc/no-crate-filter.rs @@ -2,5 +2,5 @@ // compile-flags: -Z unstable-options --disable-per-crate-search -// @!hasraw 'foo/struct.Foo.html' '//*[id="crate-search"]' +// @!has 'foo/struct.Foo.html' '//*[id="crate-search"]' '' pub struct Foo; diff --git a/src/test/rustdoc/recursive-deref.rs b/src/test/rustdoc/recursive-deref.rs index 8c899447e8a..2ab9d44be6d 100644 --- a/src/test/rustdoc/recursive-deref.rs +++ b/src/test/rustdoc/recursive-deref.rs @@ -51,7 +51,7 @@ impl G { // @has recursive_deref/struct.D.html '//h3[@class="code-header in-band"]' 'impl Deref for D' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!hasraw '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for D { type Target = E; @@ -62,7 +62,7 @@ impl Deref for D { // @has recursive_deref/struct.E.html '//h3[@class="code-header in-band"]' 'impl Deref for E' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!hasraw '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for E { type Target = F; @@ -73,7 +73,7 @@ impl Deref for E { // @has recursive_deref/struct.F.html '//h3[@class="code-header in-band"]' 'impl Deref for F' // We also check that `G::g` method isn't rendered because there is no `self` argument. -// @!hasraw '-' '//*[@id="deref-methods-G"]' +// @!has '-' '//*[@id="deref-methods-G"]' '' impl Deref for F { type Target = G; @@ -101,7 +101,7 @@ impl I { } // @has recursive_deref/struct.H.html '//h3[@class="code-header in-band"]' 'impl Deref for H' -// @!hasraw '-' '//*[@id="deref-methods-I"]' +// @!has '-' '//*[@id="deref-methods-I"]' '' impl Deref for H { type Target = I; diff --git a/src/test/rustdoc/remove-url-from-headings.rs b/src/test/rustdoc/remove-url-from-headings.rs index 8fb38cc8bf3..599c429a6e1 100644 --- a/src/test/rustdoc/remove-url-from-headings.rs +++ b/src/test/rustdoc/remove-url-from-headings.rs @@ -1,7 +1,7 @@ #![crate_name = "foo"] // @has foo/fn.foo.html -// @!hasraw - '//a[@href="http://a.a"]' +// @!has - '//a[@href="http://a.a"]' '' // @has - '//a[@href="#implementing-stuff-somewhere"]' 'Implementing stuff somewhere' // @has - '//a[@href="#another-one-urg"]' 'Another one urg' diff --git a/src/test/rustdoc/sized_trait.rs b/src/test/rustdoc/sized_trait.rs index 77aa13294d8..36718ebe1a6 100644 --- a/src/test/rustdoc/sized_trait.rs +++ b/src/test/rustdoc/sized_trait.rs @@ -1,13 +1,13 @@ #![crate_name = "foo"] // @has foo/struct.Bar.html -// @!hasraw - '//*[@id="impl-Sized"]' +// @!has - '//*[@id="impl-Sized"]' '' pub struct Bar { a: u16, } // @has foo/struct.Foo.html -// @!hasraw - '//*[@id="impl-Sized"]' +// @!has - '//*[@id="impl-Sized"]' '' pub struct Foo(T); // @has foo/struct.Unsized.html diff --git a/src/test/rustdoc/table-in-docblock.rs b/src/test/rustdoc/table-in-docblock.rs index 1463a276427..194f49f16d0 100644 --- a/src/test/rustdoc/table-in-docblock.rs +++ b/src/test/rustdoc/table-in-docblock.rs @@ -2,7 +2,7 @@ // @has foo/struct.Foo.html // @count - '//*[@class="docblock"]/div/table' 2 -// @!hasraw - '//*[@class="docblock"]/table' +// @!has - '//*[@class="docblock"]/table' '' /// | hello | hello2 | /// | ----- | ------ | /// | data | data2 | diff --git a/src/test/rustdoc/toggle-item-contents.rs b/src/test/rustdoc/toggle-item-contents.rs index 37e51741a1c..dbaf195e1a9 100644 --- a/src/test/rustdoc/toggle-item-contents.rs +++ b/src/test/rustdoc/toggle-item-contents.rs @@ -62,7 +62,7 @@ pub struct PrivStruct { } // @has 'toggle_item_contents/enum.Enum.html' -// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]' +// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' '' pub enum Enum { A, B, C, D { @@ -72,7 +72,7 @@ pub enum Enum { } // @has 'toggle_item_contents/enum.EnumStructVariant.html' -// @!hasraw - '//details[@class="rustdoc-toggle type-contents-toggle"]' +// @!has - '//details[@class="rustdoc-toggle type-contents-toggle"]' '' pub enum EnumStructVariant { A, B, C, D { diff --git a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs index c303a1052de..fba594c3827 100644 --- a/src/test/rustdoc/trait-impl-items-links-and-anchors.rs +++ b/src/test/rustdoc/trait-impl-items-links-and-anchors.rs @@ -59,7 +59,7 @@ pub struct MyStruct; // We check that associated items with default values aren't generated in the implementors list. impl MyTrait for (u8, u8) { - // @!hasraw trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' + // @!has trait_impl_items_links_and_anchors/trait.MyTrait.html '//div[@id="associatedconstant.VALUE-4"]' '' type Assoc = bool; fn trait_function(&self) {} } diff --git a/src/test/rustdoc/trait-impl.rs b/src/test/rustdoc/trait-impl.rs index abfa93b757c..4d5173f6024 100644 --- a/src/test/rustdoc/trait-impl.rs +++ b/src/test/rustdoc/trait-impl.rs @@ -40,7 +40,7 @@ impl Trait for Struct { fn c() {} // @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works' - // @!hasraw - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' + // @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' '' fn d() {} // @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html' diff --git a/src/test/rustdoc/tuple-struct-fields-doc.rs b/src/test/rustdoc/tuple-struct-fields-doc.rs index b5a90043395..66bb409325c 100644 --- a/src/test/rustdoc/tuple-struct-fields-doc.rs +++ b/src/test/rustdoc/tuple-struct-fields-doc.rs @@ -5,7 +5,7 @@ // @has - '//h3[@class="sidebar-title"]/a[@href="#fields"]' 'Tuple Fields' // @has - '//*[@id="structfield.0"]' '0: u32' // @has - '//*[@id="main-content"]/div[@class="docblock"]' 'hello' -// @!hasraw - '//*[@id="structfield.1"]' +// @!has - '//*[@id="structfield.1"]' '' // @has - '//*[@id="structfield.2"]' '2: char' // @has - '//*[@id="structfield.3"]' '3: i8' // @has - '//*[@id="main-content"]/div[@class="docblock"]' 'not hello'