Skip to content

Commit 4b51df3

Browse files
Rollup merge of #100355 - camelid:has2-rename, r=GuillaumeGomez
rustdoc: Rename `@has FILE PATTERN` to `@hasraw FILE PATTERN` Fixes #100354.
2 parents 75b7e52 + 0d588e9 commit 4b51df3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+310
-304
lines changed

src/etc/htmldocck.py

+13-9
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
`PATH` is relative to the output directory. It can be given as `-`
4242
which repeats the most recently used `PATH`.
4343
44-
* `@has PATH PATTERN` and `@matches PATH PATTERN` checks for
45-
the occurrence of the given pattern `PATTERN` in the specified file.
44+
* `@hasraw PATH PATTERN` and `@matchesraw PATH PATTERN` checks
45+
for the occurrence of the given pattern `PATTERN` in the specified file.
4646
Only one occurrence of the pattern is enough.
4747
48-
For `@has`, `PATTERN` is a whitespace-normalized (every consecutive
48+
For `@hasraw`, `PATTERN` is a whitespace-normalized (every consecutive
4949
whitespace being replaced by one single space character) string.
5050
The entire file is also whitespace-normalized including newlines.
5151
52-
For `@matches`, `PATTERN` is a Python-supported regular expression.
52+
For `@matchesraw`, `PATTERN` is a Python-supported regular expression.
5353
The file remains intact but the regexp is matched without the `MULTILINE`
5454
and `IGNORECASE` options. You can still use a prefix `(?m)` or `(?i)`
5555
to override them, and `\A` and `\Z` for definitely matching
@@ -542,19 +542,23 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
542542
def check_command(c, cache):
543543
try:
544544
cerr = ""
545-
if c.cmd == 'has' or c.cmd == 'matches': # string test
546-
regexp = (c.cmd == 'matches')
547-
if len(c.args) == 1 and not regexp: # @has <path> = file existence
545+
if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test
546+
regexp = c.cmd.startswith('matches')
547+
548+
# @has <path> = file existence
549+
if len(c.args) == 1 and not regexp and 'raw' not in c.cmd:
548550
try:
549551
cache.get_file(c.args[0])
550552
ret = True
551553
except FailedCheck as err:
552554
cerr = str(err)
553555
ret = False
554-
elif len(c.args) == 2: # @has/matches <path> <pat> = string test
556+
# @hasraw/matchesraw <path> <pat> = string test
557+
elif len(c.args) == 2 and 'raw' in c.cmd:
555558
cerr = "`PATTERN` did not match"
556559
ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)
557-
elif len(c.args) == 3: # @has/matches <path> <pat> <match> = XML tree test
560+
# @has/matches <path> <pat> <match> = XML tree test
561+
elif len(c.args) == 3 and 'raw' not in c.cmd:
558562
cerr = "`XPATH PATTERN` did not match"
559563
ret = get_nb_matching_elements(cache, c, regexp, True) != 0
560564
else:

src/test/rustdoc/all.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ mod private_module {
2424
}
2525

2626
// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
27-
// @!has foo/all.html 'private_module'
27+
// @!hasraw foo/all.html 'private_module'
2828
pub use private_module::ReexportedStruct;

src/test/rustdoc/assoc-consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub trait Foo {
55
const FOO: usize = 12 + 1;
66
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
77
const FOO_NO_DEFAULT: bool;
8-
// @!has - FOO_HIDDEN
8+
// @!hasraw - FOO_HIDDEN
99
#[doc(hidden)]
1010
const FOO_HIDDEN: u8 = 0;
1111
}
@@ -18,7 +18,7 @@ impl Foo for Bar {
1818
const FOO: usize = 12;
1919
// @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
2020
const FOO_NO_DEFAULT: bool = false;
21-
// @!has - FOO_HIDDEN
21+
// @!hasraw - FOO_HIDDEN
2222
#[doc(hidden)]
2323
const FOO_HIDDEN: u8 = 0;
2424
}
@@ -50,9 +50,9 @@ impl Bar {
5050
}
5151

5252
impl Bar {
53-
// @!has assoc_consts/struct.Bar.html 'BAR_PRIVATE'
53+
// @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE'
5454
const BAR_PRIVATE: char = 'a';
55-
// @!has assoc_consts/struct.Bar.html 'BAR_HIDDEN'
55+
// @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN'
5656
#[doc(hidden)]
5757
pub const BAR_HIDDEN: &'static str = "a";
5858
}

src/test/rustdoc/const-display.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pub const fn foo() -> u32 { 42 }
2020
pub const unsafe fn foo_unsafe() -> u32 { 42 }
2121

2222
// @has 'foo/fn.foo2.html' '//pre' 'pub const fn foo2() -> u32'
23-
// @!has - '//span[@class="since"]'
23+
// @!hasraw - '//span[@class="since"]'
2424
#[unstable(feature = "humans", issue = "none")]
2525
pub const fn foo2() -> u32 { 42 }
2626

@@ -32,7 +32,7 @@ pub const fn bar2() -> u32 { 42 }
3232

3333

3434
// @has 'foo/fn.foo2_gated.html' '//pre' 'pub const unsafe fn foo2_gated() -> u32'
35-
// @!has - '//span[@class="since"]'
35+
// @!hasraw - '//span[@class="since"]'
3636
#[unstable(feature = "foo2", issue = "none")]
3737
pub const unsafe fn foo2_gated() -> u32 { 42 }
3838

@@ -43,7 +43,7 @@ pub const unsafe fn foo2_gated() -> u32 { 42 }
4343
pub const unsafe fn bar2_gated() -> u32 { 42 }
4444

4545
// @has 'foo/fn.bar_not_gated.html' '//pre' 'pub const unsafe fn bar_not_gated() -> u32'
46-
// @!has - '//span[@class="since"]'
46+
// @!hasraw - '//span[@class="since"]'
4747
pub const unsafe fn bar_not_gated() -> u32 { 42 }
4848

4949
pub struct Foo;

src/test/rustdoc/deprecated-impls.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ pub struct Foo0;
55

66
impl Foo0 {
77
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.1: fn_with_doc'
8-
// @has - 'fn_with_doc short'
9-
// @has - 'fn_with_doc full'
8+
// @hasraw - 'fn_with_doc short'
9+
// @hasraw - 'fn_with_doc full'
1010
/// fn_with_doc short
1111
///
1212
/// fn_with_doc full
@@ -52,8 +52,8 @@ pub struct Foo1;
5252

5353
impl Bar for Foo1 {
5454
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc'
55-
// @has - 'fn_empty_with_doc_impl short'
56-
// @has - 'fn_empty_with_doc_impl full'
55+
// @hasraw - 'fn_empty_with_doc_impl short'
56+
// @hasraw - 'fn_empty_with_doc_impl full'
5757
/// fn_empty_with_doc_impl short
5858
///
5959
/// fn_empty_with_doc_impl full
@@ -63,8 +63,8 @@ impl Bar for Foo1 {
6363
fn fn_empty_without_doc() {}
6464

6565
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc'
66-
// @has - 'fn_def_with_doc_impl short'
67-
// @has - 'fn_def_with_doc_impl full'
66+
// @hasraw - 'fn_def_with_doc_impl short'
67+
// @hasraw - 'fn_def_with_doc_impl full'
6868
/// fn_def_with_doc_impl short
6969
///
7070
/// fn_def_with_doc_impl full
@@ -74,8 +74,8 @@ impl Bar for Foo1 {
7474
fn fn_def_without_doc() {}
7575

7676
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc'
77-
// @has - 'fn_def_def_with_doc short'
78-
// @!has - 'fn_def_def_with_doc full'
77+
// @hasraw - 'fn_def_def_with_doc short'
78+
// @!hasraw - 'fn_def_def_with_doc full'
7979

8080
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc'
8181
}
@@ -85,34 +85,34 @@ pub struct Foo2;
8585

8686
impl Bar for Foo2 {
8787
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.3: fn_empty_with_doc'
88-
// @has - 'fn_empty_with_doc short'
89-
// @!has - 'fn_empty_with_doc full'
88+
// @hasraw - 'fn_empty_with_doc short'
89+
// @!hasraw - 'fn_empty_with_doc full'
9090
fn fn_empty_with_doc() {}
9191

9292
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.4: fn_empty_without_doc'
93-
// @has - 'fn_empty_without_doc_impl short'
94-
// @has - 'fn_empty_without_doc_impl full'
93+
// @hasraw - 'fn_empty_without_doc_impl short'
94+
// @hasraw - 'fn_empty_without_doc_impl full'
9595
/// fn_empty_without_doc_impl short
9696
///
9797
/// fn_empty_without_doc_impl full
9898
fn fn_empty_without_doc() {}
9999

100100
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.5: fn_def_with_doc'
101-
// @has - 'fn_def_with_doc short'
102-
// @!has - 'fn_def_with_doc full'
101+
// @hasraw - 'fn_def_with_doc short'
102+
// @!hasraw - 'fn_def_with_doc full'
103103
fn fn_def_with_doc() {}
104104

105105
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.6: fn_def_without_doc'
106-
// @has - 'fn_def_without_doc_impl short'
107-
// @has - 'fn_def_without_doc_impl full'
106+
// @hasraw - 'fn_def_without_doc_impl short'
107+
// @hasraw - 'fn_def_without_doc_impl full'
108108
/// fn_def_without_doc_impl short
109109
///
110110
/// fn_def_without_doc_impl full
111111
fn fn_def_without_doc() {}
112112

113113
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.7: fn_def_def_with_doc'
114-
// @has - 'fn_def_def_with_doc short'
115-
// @!has - 'fn_def_def_with_doc full'
114+
// @hasraw - 'fn_def_def_with_doc short'
115+
// @!hasraw - 'fn_def_def_with_doc full'
116116

117117
// @has - '//*[@class="stab deprecated"]' 'Deprecated since 1.0.8: fn_def_def_without_doc'
118118
}

src/test/rustdoc/elided-lifetime.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,33 @@ pub struct Ref<'a>(&'a u32);
1111
type ARef<'a> = Ref<'a>;
1212

1313
// @has foo/fn.test1.html
14-
// @matches - "Ref</a>&lt;'_&gt;"
14+
// @matchesraw - "Ref</a>&lt;'_&gt;"
1515
pub fn test1(a: &u32) -> Ref {
1616
Ref(a)
1717
}
1818

1919
// @has foo/fn.test2.html
20-
// @matches - "Ref</a>&lt;'_&gt;"
20+
// @matchesraw - "Ref</a>&lt;'_&gt;"
2121
pub fn test2(a: &u32) -> Ref<'_> {
2222
Ref(a)
2323
}
2424

2525
// @has foo/fn.test3.html
26-
// @matches - "Ref</a>&lt;'_&gt;"
26+
// @matchesraw - "Ref</a>&lt;'_&gt;"
2727
pub fn test3(a: &u32) -> ARef {
2828
Ref(a)
2929
}
3030

3131
// @has foo/fn.test4.html
32-
// @matches - "Ref</a>&lt;'_&gt;"
32+
// @matchesraw - "Ref</a>&lt;'_&gt;"
3333
pub fn test4(a: &u32) -> ARef<'_> {
3434
Ref(a)
3535
}
3636

3737
// Ensure external paths in inlined docs also display elided lifetime
3838
// @has foo/bar/fn.test5.html
39-
// @matches - "Ref</a>&lt;'_&gt;"
39+
// @matchesraw - "Ref</a>&lt;'_&gt;"
4040
// @has foo/bar/fn.test6.html
41-
// @matches - "Ref</a>&lt;'_&gt;"
41+
// @matchesraw - "Ref</a>&lt;'_&gt;"
4242
#[doc(inline)]
4343
pub extern crate bar;

src/test/rustdoc/empty-mod-private.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// compile-flags: --document-private-items
22

33
// @has 'empty_mod_private/index.html' '//a[@href="foo/index.html"]' 'foo'
4-
// @has 'empty_mod_private/sidebar-items.js' 'foo'
4+
// @hasraw 'empty_mod_private/sidebar-items.js' 'foo'
55
// @matches 'empty_mod_private/foo/index.html' '//h1' 'Module empty_mod_private::foo'
66
mod foo {}
77

88
// @has 'empty_mod_private/index.html' '//a[@href="bar/index.html"]' 'bar'
9-
// @has 'empty_mod_private/sidebar-items.js' 'bar'
9+
// @hasraw 'empty_mod_private/sidebar-items.js' 'bar'
1010
// @matches 'empty_mod_private/bar/index.html' '//h1' 'Module empty_mod_private::bar'
1111
mod bar {
1212
// @has 'empty_mod_private/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
13-
// @has 'empty_mod_private/bar/sidebar-items.js' 'baz'
13+
// @hasraw 'empty_mod_private/bar/sidebar-items.js' 'baz'
1414
// @matches 'empty_mod_private/bar/baz/index.html' '//h1' 'Module empty_mod_private::bar::baz'
1515
mod baz {}
1616
}

src/test/rustdoc/empty-mod-public.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// @has 'empty_mod_public/index.html' '//a[@href="foo/index.html"]' 'foo'
2-
// @has 'empty_mod_public/sidebar-items.js' 'foo'
2+
// @hasraw 'empty_mod_public/sidebar-items.js' 'foo'
33
// @matches 'empty_mod_public/foo/index.html' '//h1' 'Module empty_mod_public::foo'
44
pub mod foo {}
55

66
// @has 'empty_mod_public/index.html' '//a[@href="bar/index.html"]' 'bar'
7-
// @has 'empty_mod_public/sidebar-items.js' 'bar'
7+
// @hasraw 'empty_mod_public/sidebar-items.js' 'bar'
88
// @matches 'empty_mod_public/bar/index.html' '//h1' 'Module empty_mod_public::bar'
99
pub mod bar {
1010
// @has 'empty_mod_public/bar/index.html' '//a[@href="baz/index.html"]' 'baz'
11-
// @has 'empty_mod_public/bar/sidebar-items.js' 'baz'
11+
// @hasraw 'empty_mod_public/bar/sidebar-items.js' 'baz'
1212
// @matches 'empty_mod_public/bar/baz/index.html' '//h1' 'Module empty_mod_public::bar::baz'
1313
pub mod baz {}
1414
}

src/test/rustdoc/empty-section.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
pub struct Foo;
66

77
// @has foo/struct.Foo.html
8-
// @!has - 'Auto Trait Implementations'
8+
// @!hasraw - 'Auto Trait Implementations'
99
impl !Send for Foo {}
1010
impl !Sync for Foo {}
1111
impl !std::marker::Unpin for Foo {}

src/test/rustdoc/generic-associated-types/issue-94683.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ pub trait Trait {
88
// Make sure that the elided lifetime shows up
99

1010
// @has foo/type.T.html
11-
// @has - "pub type T = "
12-
// @has - "&lt;'_&gt;"
11+
// @hasraw - "pub type T = "
12+
// @hasraw - "&lt;'_&gt;"
1313
pub type T = fn(&<() as Trait>::Gat<'_>);

src/test/rustdoc/hidden-impls.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub mod __hidden {
1111
}
1212

1313
// @has foo/trait.Clone.html
14-
// @!has - 'Foo'
14+
// @!hasraw - 'Foo'
1515
// @has implementors/core/clone/trait.Clone.js
16-
// @!has - 'Foo'
16+
// @!hasraw - 'Foo'
1717
pub use std::clone::Clone;

src/test/rustdoc/hidden-line.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@
1515
/// ```
1616
pub fn foo() {}
1717

18-
// @!has hidden_line/fn.foo.html invisible
18+
// @!hasraw hidden_line/fn.foo.html invisible
1919
// @matches - //pre "#\[derive\(PartialEq\)\] // Bar"

src/test/rustdoc/hidden-methods.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ pub mod hidden {
1717
}
1818

1919
// @has foo/struct.Foo.html
20-
// @!has - 'Methods'
20+
// @!hasraw - 'Methods'
2121
// @!has - '//code' 'impl Foo'
22-
// @!has - 'this_should_be_hidden'
22+
// @!hasraw - 'this_should_be_hidden'
2323
pub use hidden::Foo;
2424

2525
// @has foo/struct.Bar.html
26-
// @!has - 'Methods'
26+
// @!hasraw - 'Methods'
2727
// @!has - '//code' 'impl Bar'
28-
// @!has - 'this_should_be_hidden'
28+
// @!hasraw - 'this_should_be_hidden'
2929
pub use hidden::Bar;

src/test/rustdoc/hide-unstable-trait.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
extern crate unstable_trait;
77

8-
// @has foo/struct.Foo.html 'bar'
9-
// @has foo/struct.Foo.html 'bar2'
8+
// @hasraw foo/struct.Foo.html 'bar'
9+
// @hasraw foo/struct.Foo.html 'bar2'
1010
#[doc(inline)]
1111
pub use unstable_trait::Foo;

src/test/rustdoc/impl-parts-crosscrate.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ pub struct Bar<T> { t: T }
1212
// full impl string. Instead, just make sure something from each part
1313
// is mentioned.
1414

15-
// @has implementors/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar
16-
// @has - Send
17-
// @has - !AnAutoTrait
18-
// @has - Copy
15+
// @hasraw implementors/rustdoc_impl_parts_crosscrate/trait.AnAutoTrait.js Bar
16+
// @hasraw - Send
17+
// @hasraw - !AnAutoTrait
18+
// @hasraw - Copy
1919
impl<T: Send> !rustdoc_impl_parts_crosscrate::AnAutoTrait for Bar<T>
2020
where T: Copy {}

src/test/rustdoc/impl-trait-alias.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
trait MyTrait {}
44
impl MyTrait for i32 {}
55

6-
// @has impl_trait_alias/type.Foo.html 'Foo'
6+
// @hasraw impl_trait_alias/type.Foo.html 'Foo'
77
/// debug type
88
pub type Foo = impl MyTrait;
99

10-
// @has impl_trait_alias/fn.foo.html 'foo'
10+
// @hasraw impl_trait_alias/fn.foo.html 'foo'
1111
/// debug function
1212
pub fn foo() -> Foo {
1313
1

src/test/rustdoc/inline_cross/add-docs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ extern crate inner;
44

55

66
// @has add_docs/struct.MyStruct.html
7-
// @has add_docs/struct.MyStruct.html "Doc comment from ‘pub use’, Doc comment from definition"
7+
// @hasraw add_docs/struct.MyStruct.html "Doc comment from ‘pub use’, Doc comment from definition"
88
/// Doc comment from 'pub use',
99
pub use inner::MyStruct;

src/test/rustdoc/inline_cross/assoc-items.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
extern crate assoc_items;
88

99
// @has foo/struct.MyStruct.html
10-
// @!has - 'PrivateConst'
10+
// @!hasraw - 'PrivateConst'
1111
// @has - '//*[@id="associatedconstant.PublicConst"]' 'pub const PublicConst: u8'
1212
// @has - '//*[@class="docblock"]' 'docs for PublicConst'
13-
// @!has - 'private_method'
13+
// @!hasraw - 'private_method'
1414
// @has - '//*[@id="method.public_method"]' 'pub fn public_method()'
1515
// @has - '//*[@class="docblock"]' 'docs for public_method'
1616
// @has - '//*[@id="associatedconstant.ConstNoDefault"]' 'const ConstNoDefault: i16'

0 commit comments

Comments
 (0)