rust/src/test/rustdoc/trait-impl.rs
Noah Lev 0d588e928e 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!
2022-08-13 00:56:16 -04:00

47 lines
1.9 KiB
Rust

pub trait Trait {
/// Some long docs here.
///
/// These docs are long enough that a link will be added to the end.
fn a();
/// These docs contain a [reference link].
///
/// [reference link]: https://example.com
fn b();
/// ```
/// This code block should not be in the output, but a Read more link should be generated
/// ```
fn c();
/// Escaped formatting a\*b\*c\* works
fn d();
}
pub struct Struct;
impl Trait for Struct {
// @has trait_impl/struct.Struct.html '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'Some long docs'
// @!has - '//*[@id="method.a"]/../../div[@class="docblock"]/p' 'link will be added'
// @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a' 'Read more'
// @has - '//*[@id="method.a"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.a'
fn a() {}
// @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p' 'These docs contain'
// @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'reference link'
// @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'https://example.com'
// @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a' 'Read more'
// @has - '//*[@id="method.b"]/../../div[@class="docblock"]/p/a/@href' 'trait.Trait.html#tymethod.b'
fn b() {}
// @!has - '//*[@id="method.c"]/../../div[@class="docblock"]/p' 'code block'
// @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a' 'Read more'
// @has - '//*[@id="method.c"]/../../div[@class="docblock"]/a/@href' 'trait.Trait.html#tymethod.c'
fn c() {}
// @has - '//*[@id="method.d"]/../../div[@class="docblock"]/p' 'Escaped formatting a*b*c* works'
// @!has - '//*[@id="method.d"]/../../div[@class="docblock"]/p/em' ''
fn d() {}
// @has - '//*[@id="impl-Trait-for-Struct"]/h3//a/@href' 'trait.Trait.html'
}