diff --git a/src/etc/htmldocck.py b/src/etc/htmldocck.py
index 2e0f832192fdc..3d7ead99282b9 100755
--- a/src/etc/htmldocck.py
+++ b/src/etc/htmldocck.py
@@ -240,9 +240,37 @@ def concat_multi_lines(f):
print_err(lineno, line, 'Trailing backslash at the end of the file')
+def get_known_directive_names():
+ def filter_line(line):
+ line = line.strip()
+ return line.startswith('"') and (line.endswith('",') or line.endswith('"'))
+
+ # Equivalent to `src/tools/compiletest/src/header.rs` constant of the same name.
+ with open(
+ os.path.join(
+ # We go back to `src`.
+ os.path.dirname(os.path.dirname(__file__)),
+ "tools/compiletest/src/command-list.rs",
+ ),
+ "r",
+ encoding="utf8"
+ ) as fd:
+ content = fd.read()
+ return [
+ line.strip().replace('",', '').replace('"', '')
+ for line in content.split('\n')
+ if filter_line(line)
+ ]
+
+
+# To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put
+# it into a common file which is included in rust code and parsed here.
+# FIXME: This setup is temporary until we figure out how to improve this situation.
+KNOWN_DIRECTIVE_NAMES = get_known_directive_names()
+
LINE_PATTERN = re.compile(r'''
- (?<=(?!?)@(?P!?)
- (?P[A-Za-z]+(?:-[A-Za-z]+)*)
+ //@\s+
+ (?P!?)(?P[A-Za-z0-9]+(?:-[A-Za-z0-9]+)*)
(?P.*)$
''', re.X | re.UNICODE)
@@ -254,17 +282,9 @@ def get_commands(template):
if not m:
continue
- negated = (m.group('negated') == '!')
cmd = m.group('cmd')
- if m.group('invalid') == '!':
- print_err(
- lineno,
- line,
- 'Invalid command: `!@{0}{1}`, (help: try with `@!{1}`)'.format(
- '!' if negated else '',
- cmd,
- ),
- )
+ negated = (m.group('negated') == '!')
+ if not negated and cmd in KNOWN_DIRECTIVE_NAMES:
continue
args = m.group('args')
if args and not args[:1].isspace():
@@ -549,7 +569,7 @@ def get_nb_matching_elements(cache, c, regexp, stop_at_first):
def check_files_in_folder(c, cache, folder, files):
files = files.strip()
if not files.startswith('[') or not files.endswith(']'):
- raise InvalidCheck("Expected list as second argument of @{} (ie '[]')".format(c.cmd))
+ raise InvalidCheck("Expected list as second argument of {} (ie '[]')".format(c.cmd))
folder = cache.get_absolute_path(folder)
@@ -558,7 +578,7 @@ def check_files_in_folder(c, cache, folder, files):
files_set = set()
for file in files:
if file in files_set:
- raise InvalidCheck("Duplicated file `{}` in @{}".format(file, c.cmd))
+ raise InvalidCheck("Duplicated file `{}` in {}".format(file, c.cmd))
files_set.add(file)
folder_set = set([f for f in os.listdir(folder) if f != "." and f != ".."])
@@ -590,7 +610,7 @@ def check_command(c, cache):
if c.cmd in ['has', 'hasraw', 'matches', 'matchesraw']: # string test
regexp = c.cmd.startswith('matches')
- # @has = file existence
+ # has = file existence
if len(c.args) == 1 and not regexp and 'raw' not in c.cmd:
try:
cache.get_file(c.args[0])
@@ -598,40 +618,40 @@ def check_command(c, cache):
except FailedCheck as err:
cerr = str(err)
ret = False
- # @hasraw/matchesraw = string test
+ # hasraw/matchesraw = string test
elif len(c.args) == 2 and 'raw' in c.cmd:
cerr = "`PATTERN` did not match"
ret = check_string(cache.get_file(c.args[0]), c.args[1], regexp)
- # @has/matches = XML tree test
+ # has/matches = XML tree test
elif len(c.args) == 3 and 'raw' not in c.cmd:
cerr = "`XPATH PATTERN` did not match"
ret = get_nb_matching_elements(cache, c, regexp, True) != 0
else:
- raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
+ raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd))
elif c.cmd == 'files': # check files in given folder
- if len(c.args) != 2: # @files
- raise InvalidCheck("Invalid number of @{} arguments".format(c.cmd))
+ if len(c.args) != 2: # files
+ raise InvalidCheck("Invalid number of {} arguments".format(c.cmd))
elif c.negated:
- raise InvalidCheck("@{} doesn't support negative check".format(c.cmd))
+ raise InvalidCheck("{} doesn't support negative check".format(c.cmd))
ret = check_files_in_folder(c, cache, c.args[0], c.args[1])
elif c.cmd == 'count': # count test
- if len(c.args) == 3: # @count = count test
+ if len(c.args) == 3: # count = count test
expected = int(c.args[2])
found = get_tree_count(cache.get_tree(c.args[0]), c.args[1])
cerr = "Expected {} occurrences but found {}".format(expected, found)
ret = expected == found
- elif len(c.args) == 4: # @count = count test
+ elif len(c.args) == 4: # count = count test
expected = int(c.args[3])
found = get_nb_matching_elements(cache, c, False, False)
cerr = "Expected {} occurrences but found {}".format(expected, found)
ret = found == expected
else:
- raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
+ raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd))
elif c.cmd == 'snapshot': # snapshot test
- if len(c.args) == 3: # @snapshot
+ if len(c.args) == 3: # snapshot
[snapshot_name, html_path, pattern] = c.args
tree = cache.get_tree(html_path)
xpath = normalize_xpath(pattern)
@@ -654,10 +674,10 @@ def check_command(c, cache):
else:
raise FailedCheck('Expected 1 match, but found {}'.format(len(subtrees)))
else:
- raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
+ raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd))
elif c.cmd == 'has-dir': # has-dir test
- if len(c.args) == 1: # @has-dir = has-dir test
+ if len(c.args) == 1: # has-dir = has-dir test
try:
cache.get_dir(c.args[0])
ret = True
@@ -665,22 +685,22 @@ def check_command(c, cache):
cerr = str(err)
ret = False
else:
- raise InvalidCheck('Invalid number of @{} arguments'.format(c.cmd))
+ raise InvalidCheck('Invalid number of {} arguments'.format(c.cmd))
elif c.cmd == 'valid-html':
- raise InvalidCheck('Unimplemented @valid-html')
+ raise InvalidCheck('Unimplemented valid-html')
elif c.cmd == 'valid-links':
- raise InvalidCheck('Unimplemented @valid-links')
+ raise InvalidCheck('Unimplemented valid-links')
else:
- raise InvalidCheck('Unrecognized @{}'.format(c.cmd))
+ raise InvalidCheck('Unrecognized {}'.format(c.cmd))
if ret == c.negated:
raise FailedCheck(cerr)
except FailedCheck as err:
- message = '@{}{} check failed'.format('!' if c.negated else '', c.cmd)
+ message = '{}{} check failed'.format('!' if c.negated else '', c.cmd)
print_err(c.lineno, c.context, str(err), message)
except InvalidCheck as err:
print_err(c.lineno, c.context, str(err))
diff --git a/src/tools/compiletest/src/command-list.rs b/src/tools/compiletest/src/command-list.rs
new file mode 100644
index 0000000000000..6e1685a8a9456
--- /dev/null
+++ b/src/tools/compiletest/src/command-list.rs
@@ -0,0 +1,230 @@
+/// This was originally generated by collecting directives from ui tests and then extracting their
+/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is
+/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
+const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
+ // tidy-alphabetical-start
+ "assembly-output",
+ "aux-bin",
+ "aux-build",
+ "aux-codegen-backend",
+ "aux-crate",
+ "build-aux-docs",
+ "build-fail",
+ "build-pass",
+ "check-fail",
+ "check-pass",
+ "check-run-results",
+ "check-stdout",
+ "check-test-line-numbers-match",
+ "compare-output-lines-by-subset",
+ "compile-flags",
+ "dont-check-compiler-stderr",
+ "dont-check-compiler-stdout",
+ "dont-check-failure-status",
+ "edition",
+ "error-pattern",
+ "exec-env",
+ "failure-status",
+ "filecheck-flags",
+ "forbid-output",
+ "force-host",
+ "ignore-16bit",
+ "ignore-32bit",
+ "ignore-64bit",
+ "ignore-aarch64",
+ "ignore-aarch64-unknown-linux-gnu",
+ "ignore-android",
+ "ignore-apple",
+ "ignore-arm",
+ "ignore-avr",
+ "ignore-beta",
+ "ignore-cdb",
+ "ignore-compare-mode-next-solver",
+ "ignore-compare-mode-polonius",
+ "ignore-cross-compile",
+ "ignore-debug",
+ "ignore-eabi",
+ "ignore-emscripten",
+ "ignore-endian-big",
+ "ignore-freebsd",
+ "ignore-fuchsia",
+ "ignore-gdb",
+ "ignore-gdb-version",
+ "ignore-gnu",
+ "ignore-haiku",
+ "ignore-horizon",
+ "ignore-i686-pc-windows-msvc",
+ "ignore-illumos",
+ "ignore-ios",
+ "ignore-linux",
+ "ignore-lldb",
+ "ignore-llvm-version",
+ "ignore-loongarch64",
+ "ignore-macabi",
+ "ignore-macos",
+ "ignore-mode-assembly",
+ "ignore-mode-codegen",
+ "ignore-mode-codegen-units",
+ "ignore-mode-coverage-map",
+ "ignore-mode-coverage-run",
+ "ignore-mode-crashes",
+ "ignore-mode-debuginfo",
+ "ignore-mode-incremental",
+ "ignore-mode-js-doc-test",
+ "ignore-mode-mir-opt",
+ "ignore-mode-pretty",
+ "ignore-mode-run-make",
+ "ignore-mode-run-pass-valgrind",
+ "ignore-mode-rustdoc",
+ "ignore-mode-rustdoc-json",
+ "ignore-mode-ui",
+ "ignore-mode-ui-fulldeps",
+ "ignore-msp430",
+ "ignore-msvc",
+ "ignore-musl",
+ "ignore-netbsd",
+ "ignore-nightly",
+ "ignore-none",
+ "ignore-nto",
+ "ignore-nvptx64",
+ "ignore-nvptx64-nvidia-cuda",
+ "ignore-openbsd",
+ "ignore-pass",
+ "ignore-remote",
+ "ignore-riscv64",
+ "ignore-s390x",
+ "ignore-sgx",
+ "ignore-spirv",
+ "ignore-stable",
+ "ignore-stage1",
+ "ignore-stage2",
+ "ignore-test",
+ "ignore-thumb",
+ "ignore-thumbv8m.base-none-eabi",
+ "ignore-thumbv8m.main-none-eabi",
+ "ignore-tvos",
+ "ignore-unix",
+ "ignore-unknown",
+ "ignore-uwp",
+ "ignore-visionos",
+ "ignore-vxworks",
+ "ignore-wasi",
+ "ignore-wasm",
+ "ignore-wasm32",
+ "ignore-wasm32-bare",
+ "ignore-wasm64",
+ "ignore-watchos",
+ "ignore-windows",
+ "ignore-windows-gnu",
+ "ignore-x32",
+ "ignore-x86",
+ "ignore-x86_64",
+ "ignore-x86_64-apple-darwin",
+ "ignore-x86_64-unknown-linux-gnu",
+ "incremental",
+ "known-bug",
+ "llvm-cov-flags",
+ "min-cdb-version",
+ "min-gdb-version",
+ "min-lldb-version",
+ "min-llvm-version",
+ "min-system-llvm-version",
+ "needs-asm-support",
+ "needs-dlltool",
+ "needs-dynamic-linking",
+ "needs-force-clang-based-tests",
+ "needs-git-hash",
+ "needs-llvm-components",
+ "needs-profiler-support",
+ "needs-relocation-model-pic",
+ "needs-run-enabled",
+ "needs-rust-lld",
+ "needs-rust-lldb",
+ "needs-sanitizer-address",
+ "needs-sanitizer-cfi",
+ "needs-sanitizer-dataflow",
+ "needs-sanitizer-hwaddress",
+ "needs-sanitizer-kcfi",
+ "needs-sanitizer-leak",
+ "needs-sanitizer-memory",
+ "needs-sanitizer-memtag",
+ "needs-sanitizer-safestack",
+ "needs-sanitizer-shadow-call-stack",
+ "needs-sanitizer-support",
+ "needs-sanitizer-thread",
+ "needs-symlink",
+ "needs-threads",
+ "needs-unwind",
+ "needs-wasmtime",
+ "needs-xray",
+ "no-auto-check-cfg",
+ "no-prefer-dynamic",
+ "normalize-stderr-32bit",
+ "normalize-stderr-64bit",
+ "normalize-stderr-test",
+ "normalize-stdout-test",
+ "only-16bit",
+ "only-32bit",
+ "only-64bit",
+ "only-aarch64",
+ "only-apple",
+ "only-arm",
+ "only-avr",
+ "only-beta",
+ "only-bpf",
+ "only-cdb",
+ "only-gnu",
+ "only-i686-pc-windows-msvc",
+ "only-ios",
+ "only-linux",
+ "only-loongarch64",
+ "only-loongarch64-unknown-linux-gnu",
+ "only-macos",
+ "only-mips",
+ "only-mips64",
+ "only-msp430",
+ "only-msvc",
+ "only-nightly",
+ "only-nvptx64",
+ "only-riscv64",
+ "only-sparc",
+ "only-sparc64",
+ "only-stable",
+ "only-thumb",
+ "only-tvos",
+ "only-unix",
+ "only-visionos",
+ "only-wasm32",
+ "only-wasm32-bare",
+ "only-wasm32-wasip1",
+ "only-watchos",
+ "only-windows",
+ "only-x86",
+ "only-x86_64",
+ "only-x86_64-fortanix-unknown-sgx",
+ "only-x86_64-pc-windows-gnu",
+ "only-x86_64-pc-windows-msvc",
+ "only-x86_64-unknown-linux-gnu",
+ "pp-exact",
+ "pretty-compare-only",
+ "pretty-expanded",
+ "pretty-mode",
+ "regex-error-pattern",
+ "remap-src-base",
+ "revisions",
+ "run-fail",
+ "run-flags",
+ "run-pass",
+ "run-rustfix",
+ "rustc-env",
+ "rustfix-only-machine-applicable",
+ "should-fail",
+ "should-ice",
+ "stderr-per-bitwidth",
+ "test-mir-pass",
+ "unset-exec-env",
+ "unset-rustc-env",
+ // Used by the tidy check `unknown_revision`.
+ "unused-revision-names",
+ // tidy-alphabetical-end
+];
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 31ae0deb7ec3c..63d1efd42fae1 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -723,235 +723,28 @@ pub fn line_directive<'line>(
}
}
-/// This was originally generated by collecting directives from ui tests and then extracting their
-/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is
-/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
-const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
- // tidy-alphabetical-start
- "assembly-output",
- "aux-bin",
- "aux-build",
- "aux-codegen-backend",
- "aux-crate",
- "build-aux-docs",
- "build-fail",
- "build-pass",
- "check-fail",
- "check-pass",
- "check-run-results",
- "check-stdout",
- "check-test-line-numbers-match",
- "compare-output-lines-by-subset",
- "compile-flags",
- "dont-check-compiler-stderr",
- "dont-check-compiler-stdout",
- "dont-check-failure-status",
- "edition",
- "error-pattern",
- "exec-env",
- "failure-status",
- "filecheck-flags",
- "forbid-output",
- "force-host",
- "ignore-16bit",
- "ignore-32bit",
- "ignore-64bit",
- "ignore-aarch64",
- "ignore-aarch64-unknown-linux-gnu",
- "ignore-android",
- "ignore-apple",
- "ignore-arm",
- "ignore-avr",
- "ignore-beta",
- "ignore-cdb",
- "ignore-compare-mode-next-solver",
- "ignore-compare-mode-polonius",
- "ignore-cross-compile",
- "ignore-debug",
- "ignore-eabi",
- "ignore-emscripten",
- "ignore-endian-big",
- "ignore-freebsd",
- "ignore-fuchsia",
- "ignore-gdb",
- "ignore-gdb-version",
- "ignore-gnu",
- "ignore-haiku",
- "ignore-horizon",
- "ignore-i686-pc-windows-msvc",
- "ignore-illumos",
- "ignore-ios",
- "ignore-linux",
- "ignore-lldb",
- "ignore-llvm-version",
- "ignore-loongarch64",
- "ignore-macabi",
- "ignore-macos",
- "ignore-mode-assembly",
- "ignore-mode-codegen",
- "ignore-mode-codegen-units",
- "ignore-mode-coverage-map",
- "ignore-mode-coverage-run",
- "ignore-mode-crashes",
- "ignore-mode-debuginfo",
- "ignore-mode-incremental",
- "ignore-mode-js-doc-test",
- "ignore-mode-mir-opt",
- "ignore-mode-pretty",
- "ignore-mode-run-make",
- "ignore-mode-run-pass-valgrind",
- "ignore-mode-rustdoc",
- "ignore-mode-rustdoc-json",
- "ignore-mode-ui",
- "ignore-mode-ui-fulldeps",
- "ignore-msp430",
- "ignore-msvc",
- "ignore-musl",
- "ignore-netbsd",
- "ignore-nightly",
- "ignore-none",
- "ignore-nto",
- "ignore-nvptx64",
- "ignore-nvptx64-nvidia-cuda",
- "ignore-openbsd",
- "ignore-pass",
- "ignore-remote",
- "ignore-riscv64",
- "ignore-s390x",
- "ignore-sgx",
- "ignore-spirv",
- "ignore-stable",
- "ignore-stage1",
- "ignore-stage2",
- "ignore-test",
- "ignore-thumb",
- "ignore-thumbv8m.base-none-eabi",
- "ignore-thumbv8m.main-none-eabi",
- "ignore-tvos",
- "ignore-unix",
- "ignore-unknown",
- "ignore-uwp",
- "ignore-visionos",
- "ignore-vxworks",
- "ignore-wasi",
- "ignore-wasm",
- "ignore-wasm32",
- "ignore-wasm32-bare",
- "ignore-wasm64",
- "ignore-watchos",
- "ignore-windows",
- "ignore-windows-gnu",
- "ignore-x32",
- "ignore-x86",
- "ignore-x86_64",
- "ignore-x86_64-apple-darwin",
- "ignore-x86_64-unknown-linux-gnu",
- "incremental",
- "known-bug",
- "llvm-cov-flags",
- "min-cdb-version",
- "min-gdb-version",
- "min-lldb-version",
- "min-llvm-version",
- "min-system-llvm-version",
- "needs-asm-support",
- "needs-dlltool",
- "needs-dynamic-linking",
- "needs-force-clang-based-tests",
- "needs-git-hash",
- "needs-llvm-components",
- "needs-profiler-support",
- "needs-relocation-model-pic",
- "needs-run-enabled",
- "needs-rust-lld",
- "needs-rust-lldb",
- "needs-sanitizer-address",
- "needs-sanitizer-cfi",
- "needs-sanitizer-dataflow",
- "needs-sanitizer-hwaddress",
- "needs-sanitizer-kcfi",
- "needs-sanitizer-leak",
- "needs-sanitizer-memory",
- "needs-sanitizer-memtag",
- "needs-sanitizer-safestack",
- "needs-sanitizer-shadow-call-stack",
- "needs-sanitizer-support",
- "needs-sanitizer-thread",
- "needs-symlink",
- "needs-threads",
- "needs-unwind",
- "needs-wasmtime",
- "needs-xray",
- "no-auto-check-cfg",
- "no-prefer-dynamic",
- "normalize-stderr-32bit",
- "normalize-stderr-64bit",
- "normalize-stderr-test",
- "normalize-stdout-test",
- "only-16bit",
- "only-32bit",
- "only-64bit",
- "only-aarch64",
- "only-apple",
- "only-arm",
- "only-avr",
- "only-beta",
- "only-bpf",
- "only-cdb",
- "only-gnu",
- "only-i686-pc-windows-msvc",
- "only-ios",
- "only-linux",
- "only-loongarch64",
- "only-loongarch64-unknown-linux-gnu",
- "only-macos",
- "only-mips",
- "only-mips64",
- "only-msp430",
- "only-msvc",
- "only-nightly",
- "only-nvptx64",
- "only-riscv64",
- "only-sparc",
- "only-sparc64",
- "only-stable",
- "only-thumb",
- "only-tvos",
- "only-unix",
- "only-visionos",
- "only-wasm32",
- "only-wasm32-bare",
- "only-wasm32-wasip1",
- "only-watchos",
- "only-windows",
- "only-x86",
- "only-x86_64",
- "only-x86_64-fortanix-unknown-sgx",
- "only-x86_64-pc-windows-gnu",
- "only-x86_64-pc-windows-msvc",
- "only-x86_64-unknown-linux-gnu",
- "pp-exact",
- "pretty-compare-only",
- "pretty-expanded",
- "pretty-mode",
- "regex-error-pattern",
- "remap-src-base",
- "revisions",
- "run-fail",
- "run-flags",
- "run-pass",
- "run-rustfix",
- "rustc-env",
- "rustfix-only-machine-applicable",
- "should-fail",
- "should-ice",
- "stderr-per-bitwidth",
- "test-mir-pass",
- "unset-exec-env",
- "unset-rustc-env",
- // Used by the tidy check `unknown_revision`.
- "unused-revision-names",
- // tidy-alphabetical-end
+// To prevent duplicating the list of commmands between `compiletest` and `htmldocck`, we put
+// it into a common file which is included in rust code and parsed here.
+// FIXME: This setup is temporary until we figure out how to improve this situation.
+include!("command-list.rs");
+
+const KNOWN_RUSTDOC_DIRECTIVE_NAMES: &[&str] = &[
+ "count",
+ "!count",
+ "files",
+ "!files",
+ "has",
+ "!has",
+ "has-dir",
+ "!has-dir",
+ "hasraw",
+ "!hasraw",
+ "matches",
+ "!matches",
+ "matchesraw",
+ "!matchesraw",
+ "snapshot",
+ "!snapshot",
];
/// The broken-down contents of a line containing a test header directive,
@@ -988,20 +781,30 @@ pub(crate) struct CheckDirectiveResult<'ln> {
trailing_directive: Option<&'ln str>,
}
-pub(crate) fn check_directive(directive_ln: &str) -> CheckDirectiveResult<'_> {
+pub(crate) fn check_directive<'a>(
+ directive_ln: &'a str,
+ is_rustdoc: bool,
+ original_line: &str,
+) -> CheckDirectiveResult<'a> {
let (directive_name, post) = directive_ln.split_once([':', ' ']).unwrap_or((directive_ln, ""));
let trailing = post.trim().split_once(' ').map(|(pre, _)| pre).unwrap_or(post);
+ let is_known = |s: &str| {
+ KNOWN_DIRECTIVE_NAMES.contains(&s)
+ || (is_rustdoc
+ && original_line.starts_with("//@")
+ && KNOWN_RUSTDOC_DIRECTIVE_NAMES.contains(&s))
+ };
let trailing_directive = {
// 1. is the directive name followed by a space? (to exclude `:`)
matches!(directive_ln.get(directive_name.len()..), Some(s) if s.starts_with(' '))
// 2. is what is after that directive also a directive (ex: "only-x86 only-arm")
- && KNOWN_DIRECTIVE_NAMES.contains(&trailing)
+ && is_known(trailing)
}
.then_some(trailing);
CheckDirectiveResult {
- is_known_directive: KNOWN_DIRECTIVE_NAMES.contains(&directive_name),
+ is_known_directive: is_known(&directive_name),
directive_name: directive_ln,
trailing_directive,
}
@@ -1072,7 +875,7 @@ fn iter_header(
let directive_ln = non_revisioned_directive_line.trim();
let CheckDirectiveResult { is_known_directive, trailing_directive, .. } =
- check_directive(directive_ln);
+ check_directive(directive_ln, mode == Mode::Rustdoc, ln);
if !is_known_directive {
*poisoned = true;
@@ -1125,7 +928,7 @@ fn iter_header(
let rest = rest.trim_start();
let CheckDirectiveResult { is_known_directive, directive_name, .. } =
- check_directive(rest);
+ check_directive(rest, mode == Mode::Rustdoc, ln);
if is_known_directive {
*poisoned = true;
diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs
index 7bcb85335e07d..e4d54d2a2b589 100644
--- a/src/tools/tidy/src/style.rs
+++ b/src/tools/tidy/src/style.rs
@@ -186,6 +186,11 @@ fn should_ignore(line: &str) -> bool {
// - `//@[rev] normalize-stderr-test`
|| static_regex!("\\s*//@(\\[.*\\]) (compile-flags|normalize-stderr-test|error-pattern).*")
.is_match(line)
+ // Matching for rustdoc tests commands.
+ // It allows to prevent them emitting warnings like `line longer than 100 chars`.
+ || static_regex!(
+ "\\s*//@ \\!?(count|files|has|has-dir|hasraw|matches|matchesraw|snapshot)\\s.*"
+ ).is_match(line)
}
/// Returns `true` if `line` is allowed to be longer than the normal limit.
diff --git a/tests/rustdoc/alias-reexport.rs b/tests/rustdoc/alias-reexport.rs
index 0f77d8b3f96fc..41f1f8df0f692 100644
--- a/tests/rustdoc/alias-reexport.rs
+++ b/tests/rustdoc/alias-reexport.rs
@@ -7,11 +7,11 @@
extern crate alias_reexport2;
-// @has 'foo/reexport/fn.foo.html'
-// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
-// @has 'foo/reexport/fn.foo2.html'
-// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result'
-// @has 'foo/reexport/type.Reexported.html'
-// @has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;'
+//@ has 'foo/reexport/fn.foo.html'
+//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
+//@ has 'foo/reexport/fn.foo2.html'
+//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result'
+//@ has 'foo/reexport/type.Reexported.html'
+//@ has - '//*[@class="rust item-decl"]' 'pub type Reexported = u8;'
#[doc(inline)]
pub use alias_reexport2 as reexport;
diff --git a/tests/rustdoc/alias-reexport2.rs b/tests/rustdoc/alias-reexport2.rs
index 60b7a5f9b83d5..2fb69b922c8b3 100644
--- a/tests/rustdoc/alias-reexport2.rs
+++ b/tests/rustdoc/alias-reexport2.rs
@@ -9,9 +9,9 @@ extern crate alias_reexport;
use alias_reexport::Reexported;
-// @has 'foo/fn.foo.html'
-// @has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
+//@ has 'foo/fn.foo.html'
+//@ has - '//*[@class="rust item-decl"]' 'pub fn foo() -> Reexported'
pub fn foo() -> Reexported { 0 }
-// @has 'foo/fn.foo2.html'
-// @has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result'
+//@ has 'foo/fn.foo2.html'
+//@ has - '//*[@class="rust item-decl"]' 'pub fn foo2() -> Result'
pub fn foo2() -> Result { Ok(0) }
diff --git a/tests/rustdoc/all.rs b/tests/rustdoc/all.rs
index 4c8d023109559..7056af8e3438d 100644
--- a/tests/rustdoc/all.rs
+++ b/tests/rustdoc/all.rs
@@ -1,11 +1,11 @@
#![crate_name = "foo"]
-// @has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
-// @has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
-// @has foo/all.html '//a[@href="union.Union.html"]' 'Union'
-// @has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
-// @has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
-// @has foo/all.html '//a[@href="fn.function.html"]' 'function'
+//@ has foo/all.html '//a[@href="struct.Struct.html"]' 'Struct'
+//@ has foo/all.html '//a[@href="enum.Enum.html"]' 'Enum'
+//@ has foo/all.html '//a[@href="union.Union.html"]' 'Union'
+//@ has foo/all.html '//a[@href="constant.CONST.html"]' 'CONST'
+//@ has foo/all.html '//a[@href="static.STATIC.html"]' 'STATIC'
+//@ has foo/all.html '//a[@href="fn.function.html"]' 'function'
pub struct Struct;
pub enum Enum {
@@ -23,6 +23,6 @@ mod private_module {
pub struct ReexportedStruct;
}
-// @has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
-// @!hasraw foo/all.html 'private_module'
+//@ has foo/all.html '//a[@href="struct.ReexportedStruct.html"]' 'ReexportedStruct'
+//@ !hasraw foo/all.html 'private_module'
pub use private_module::ReexportedStruct;
diff --git a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs
index ffb0765d3c3f6..5fa6891b23d02 100644
--- a/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs
+++ b/tests/rustdoc/anchor-id-duplicate-method-name-25001.rs
@@ -1,7 +1,7 @@
// https://github.com/rust-lang/rust/issues/25001
#![crate_name="issue_25001"]
-// @has issue_25001/struct.Foo.html
+//@ has issue_25001/struct.Foo.html
pub struct Foo(T);
pub trait Bar {
@@ -11,36 +11,36 @@ pub trait Bar {
}
impl Foo {
- // @has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()'
+ //@ has - '//*[@id="method.pass"]//h4[@class="code-header"]' 'fn pass()'
pub fn pass() {}
}
impl Foo {
- // @has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize'
+ //@ has - '//*[@id="method.pass-1"]//h4[@class="code-header"]' 'fn pass() -> usize'
pub fn pass() -> usize { 42 }
}
impl Foo {
- // @has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize'
+ //@ has - '//*[@id="method.pass-2"]//h4[@class="code-header"]' 'fn pass() -> isize'
pub fn pass() -> isize { 42 }
}
impl Bar for Foo {
- // @has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T'
+ //@ has - '//*[@id="associatedtype.Item-1"]//h4[@class="code-header"]' 'type Item = T'
type Item=T;
- // @has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)'
+ //@ has - '//*[@id="method.quux"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a Foo {
- // @has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T"
+ //@ has - '//*[@id="associatedtype.Item"]//h4[@class="code-header"]' "type Item = &'a T"
type Item=&'a T;
- // @has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)'
+ //@ has - '//*[@id="method.quux-1"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
impl<'a, T> Bar for &'a mut Foo {
- // @has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T"
+ //@ has - '//*[@id="associatedtype.Item-2"]//h4[@class="code-header"]' "type Item = &'a mut T"
type Item=&'a mut T;
- // @has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)'
+ //@ has - '//*[@id="method.quux-2"]//h4[@class="code-header"]' 'fn quux(self)'
fn quux(self) {}
}
diff --git a/tests/rustdoc/anchor-id-trait-method-15169.rs b/tests/rustdoc/anchor-id-trait-method-15169.rs
index 26bb59c1875fd..19eeeaee9d1b6 100644
--- a/tests/rustdoc/anchor-id-trait-method-15169.rs
+++ b/tests/rustdoc/anchor-id-trait-method-15169.rs
@@ -1,4 +1,4 @@
-// @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq'
+//@ has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq'
// https://github.com/rust-lang/rust/issues/15169
#![crate_name="issue_15169"]
diff --git a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs
index 5685040dc1e1b..e7adba7d06ec2 100644
--- a/tests/rustdoc/anchor-id-trait-tymethod-28478.rs
+++ b/tests/rustdoc/anchor-id-trait-tymethod-28478.rs
@@ -3,32 +3,32 @@
#![feature(associated_type_defaults)]
-// @has issue_28478/trait.Bar.html
+//@ has issue_28478/trait.Bar.html
pub trait Bar {
- // @has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
- // @has - '//*[@href="#associatedtype.Bar"]' 'Bar'
+ //@ has - '//*[@id="associatedtype.Bar"]' 'type Bar = ()'
+ //@ has - '//*[@href="#associatedtype.Bar"]' 'Bar'
type Bar = ();
- // @has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
- // @has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
+ //@ has - '//*[@id="associatedconstant.Baz"]' 'const Baz: usize'
+ //@ has - '//*[@href="#associatedconstant.Baz"]' 'Baz'
const Baz: usize = 7;
- // @has - '//*[@id="tymethod.bar"]' 'fn bar'
+ //@ has - '//*[@id="tymethod.bar"]' 'fn bar'
fn bar();
- // @has - '//*[@id="method.baz"]' 'fn baz'
+ //@ has - '//*[@id="method.baz"]' 'fn baz'
fn baz() { }
}
-// @has issue_28478/struct.Foo.html
+//@ has issue_28478/struct.Foo.html
pub struct Foo;
impl Foo {
- // @has - '//*[@href="#method.foo"]' 'foo'
+ //@ has - '//*[@href="#method.foo"]' 'foo'
pub fn foo() {}
}
impl Bar for Foo {
- // @has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar'
- // @has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz'
- // @has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar'
+ //@ has - '//*[@href="trait.Bar.html#associatedtype.Bar"]' 'Bar'
+ //@ has - '//*[@href="trait.Bar.html#associatedconstant.Baz"]' 'Baz'
+ //@ has - '//*[@href="trait.Bar.html#tymethod.bar"]' 'bar'
fn bar() {}
- // @has - '//*[@href="trait.Bar.html#method.baz"]' 'baz'
+ //@ has - '//*[@href="trait.Bar.html#method.baz"]' 'baz'
}
diff --git a/tests/rustdoc/anchors.rs b/tests/rustdoc/anchors.rs
index 034cf8eaf4ff7..255ef87351cb6 100644
--- a/tests/rustdoc/anchors.rs
+++ b/tests/rustdoc/anchors.rs
@@ -6,44 +6,44 @@
pub struct Foo;
-// @has 'foo/trait.Bar.html'
+//@ has 'foo/trait.Bar.html'
pub trait Bar {
// There should be no anchors here.
- // @snapshot no_type_anchor - '//*[@id="associatedtype.T"]'
+ //@ snapshot no_type_anchor - '//*[@id="associatedtype.T"]'
type T;
// There should be no anchors here.
- // @snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]'
+ //@ snapshot no_const_anchor - '//*[@id="associatedconstant.YOLO"]'
const YOLO: u32;
// There should be no anchors here.
- // @snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]'
+ //@ snapshot no_tymethod_anchor - '//*[@id="tymethod.foo"]'
fn foo();
// There should be no anchors here.
- // @snapshot no_trait_method_anchor - '//*[@id="method.bar"]'
+ //@ snapshot no_trait_method_anchor - '//*[@id="method.bar"]'
fn bar() {}
}
-// @has 'foo/struct.Foo.html'
+//@ has 'foo/struct.Foo.html'
impl Bar for Foo {
- // @has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' ''
+ //@ has - '//*[@id="associatedtype.T"]/a[@class="anchor"]' ''
type T = u32;
- // @has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' ''
+ //@ has - '//*[@id="associatedconstant.YOLO"]/a[@class="anchor"]' ''
const YOLO: u32 = 0;
- // @has - '//*[@id="method.foo"]/a[@class="anchor"]' ''
+ //@ has - '//*[@id="method.foo"]/a[@class="anchor"]' ''
fn foo() {}
// Same check for provided "bar" method.
- // @has - '//*[@id="method.bar"]/a[@class="anchor"]' ''
+ //@ has - '//*[@id="method.bar"]/a[@class="anchor"]' ''
}
impl Foo {
- // @snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]'
+ //@ snapshot no_const_anchor2 - '//*[@id="associatedconstant.X"]'
// There should be no anchors here.
pub const X: i32 = 0;
- // @snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]'
+ //@ snapshot no_type_anchor2 - '//*[@id="associatedtype.Y"]'
// There should be no anchors here.
pub type Y = u32;
- // @snapshot no_method_anchor - '//*[@id="method.new"]'
+ //@ snapshot no_method_anchor - '//*[@id="method.new"]'
// There should be no anchors here.
pub fn new() -> Self { Self }
}
diff --git a/tests/rustdoc/anonymous-lifetime.rs b/tests/rustdoc/anonymous-lifetime.rs
index 390ed5a1f938b..872f31a3602b5 100644
--- a/tests/rustdoc/anonymous-lifetime.rs
+++ b/tests/rustdoc/anonymous-lifetime.rs
@@ -11,8 +11,8 @@ pub trait Stream {
fn size_hint(&self) -> (usize, Option);
}
-// @has 'foo/trait.Stream.html'
-// @has - '//*[@class="code-header"]' 'impl Stream for &mut S'
+//@ has 'foo/trait.Stream.html'
+//@ has - '//*[@class="code-header"]' 'impl Stream for &mut S'
impl Stream for &mut S {
type Item = S::Item;
diff --git a/tests/rustdoc/anonymous-reexport.rs b/tests/rustdoc/anonymous-reexport.rs
index 839c1a3034604..8021008dc6684 100644
--- a/tests/rustdoc/anonymous-reexport.rs
+++ b/tests/rustdoc/anonymous-reexport.rs
@@ -2,16 +2,16 @@
// This test ensures we don't display anonymous (non-inline) re-exports of public items.
-// @has 'foo/index.html'
-// @has - '//*[@id="main-content"]' ''
+//@ has 'foo/index.html'
+//@ has - '//*[@id="main-content"]' ''
// We check that the only "h2" present are "Structs" (for "Bla") and "Re-exports".
-// @count - '//*[@id="main-content"]/h2' 2
-// @has - '//*[@id="main-content"]/h2' 'Structs'
-// @has - '//*[@id="main-content"]/h2' 'Re-exports'
+//@ count - '//*[@id="main-content"]/h2' 2
+//@ has - '//*[@id="main-content"]/h2' 'Structs'
+//@ has - '//*[@id="main-content"]/h2' 'Re-exports'
// The 3 re-exports.
-// @count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
+//@ count - '//*[@id="main-content"]//*[@class="item-table"]//li//code' 3
// The public struct.
-// @count - '//*[@id="main-content"]//a[@class="struct"]' 1
+//@ count - '//*[@id="main-content"]//a[@class="struct"]' 1
mod ext {
pub trait Foo {}
diff --git a/tests/rustdoc/array-links.rs b/tests/rustdoc/array-links.rs
index 8ee294daa963d..d185233c728cd 100644
--- a/tests/rustdoc/array-links.rs
+++ b/tests/rustdoc/array-links.rs
@@ -3,26 +3,26 @@
pub struct MyBox(*const T);
-// @has 'foo/fn.alpha.html'
-// @snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code'
+//@ has 'foo/fn.alpha.html'
+//@ snapshot link_slice_u32 - '//pre[@class="rust item-decl"]/code'
pub fn alpha() -> &'static [u32; 1] {
loop {}
}
-// @has 'foo/fn.beta.html'
-// @snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code'
+//@ has 'foo/fn.beta.html'
+//@ snapshot link_slice_generic - '//pre[@class="rust item-decl"]/code'
pub fn beta() -> &'static [T; 1] {
loop {}
}
-// @has 'foo/fn.gamma.html'
-// @snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code'
+//@ has 'foo/fn.gamma.html'
+//@ snapshot link_box_u32 - '//pre[@class="rust item-decl"]/code'
pub fn gamma() -> MyBox<[u32; 1]> {
loop {}
}
-// @has 'foo/fn.delta.html'
-// @snapshot link_box_generic - '//pre[@class="rust item-decl"]/code'
+//@ has 'foo/fn.delta.html'
+//@ snapshot link_box_generic - '//pre[@class="rust item-decl"]/code'
pub fn delta() -> MyBox<[T; 1]> {
loop {}
}
diff --git a/tests/rustdoc/asm-foreign.rs b/tests/rustdoc/asm-foreign.rs
index d7550ca5aca31..ebae53ea19c70 100644
--- a/tests/rustdoc/asm-foreign.rs
+++ b/tests/rustdoc/asm-foreign.rs
@@ -2,7 +2,7 @@
use std::arch::asm;
-// @has asm_foreign/fn.aarch64.html
+//@ has asm_foreign/fn.aarch64.html
pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
let c;
asm!("add {:d}, {:d}, d0", out(vreg) c, in(vreg) a, in("d0") {
@@ -12,7 +12,7 @@ pub unsafe fn aarch64(a: f64, b: f64) -> f64 {
c
}
-// @has asm_foreign/fn.x86.html
+//@ has asm_foreign/fn.x86.html
pub unsafe fn x86(a: f64, b: f64) -> f64 {
let c;
asm!("addsd {}, {}, xmm0", out(xmm_reg) c, in(xmm_reg) a, in("xmm0") b);
diff --git a/tests/rustdoc/asm-foreign2.rs b/tests/rustdoc/asm-foreign2.rs
index c3b194b166041..c0f3224a90fb6 100644
--- a/tests/rustdoc/asm-foreign2.rs
+++ b/tests/rustdoc/asm-foreign2.rs
@@ -3,7 +3,7 @@
use std::arch::asm;
-// @has asm_foreign2/fn.x86.html
+//@ has asm_foreign2/fn.x86.html
pub unsafe fn x86(x: i64) -> i64 {
let y;
asm!("movq {}, {}", in(reg) x, out(reg) y, options(att_syntax));
diff --git a/tests/rustdoc/asref-for-and-of-local-82465.rs b/tests/rustdoc/asref-for-and-of-local-82465.rs
index e620468890435..9c96b72ee2714 100644
--- a/tests/rustdoc/asref-for-and-of-local-82465.rs
+++ b/tests/rustdoc/asref-for-and-of-local-82465.rs
@@ -4,14 +4,14 @@
use std::convert::AsRef;
pub struct Local;
-// @has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef for Local'
+//@ has foo/struct.Local.html '//h3[@class="code-header"]' 'impl AsRef for Local'
impl AsRef for Local {
fn as_ref(&self) -> &str {
todo!()
}
}
-// @has - '//h3[@class="code-header"]' 'impl AsRef for str'
+//@ has - '//h3[@class="code-header"]' 'impl AsRef for str'
impl AsRef for str {
fn as_ref(&self) -> &Local {
todo!()
diff --git a/tests/rustdoc/assoc-consts-version.rs b/tests/rustdoc/assoc-consts-version.rs
index 6060bc0a6fd5c..db4d759acabc2 100644
--- a/tests/rustdoc/assoc-consts-version.rs
+++ b/tests/rustdoc/assoc-consts-version.rs
@@ -8,7 +8,7 @@
pub struct SomeStruct;
impl SomeStruct {
- // @has 'foo/struct.SomeStruct.html' \
+ //@ has 'foo/struct.SomeStruct.html' \
// '//*[@id="associatedconstant.SOME_CONST"]//span[@class="since"]' '1.1.2'
#[stable(since="1.1.2", feature="rust2")]
pub const SOME_CONST: usize = 0;
diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs
index 08dfa879d4363..cb8e839541c3b 100644
--- a/tests/rustdoc/assoc-consts.rs
+++ b/tests/rustdoc/assoc-consts.rs
@@ -1,11 +1,11 @@
pub trait Foo {
- // @has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \
+ //@ has assoc_consts/trait.Foo.html '//pre[@class="rust item-decl"]' \
// 'const FOO: usize = 13usize;'
- // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
+ //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
const FOO: usize = 12 + 1;
- // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
+ //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
const FOO_NO_DEFAULT: bool;
- // @!hasraw - FOO_HIDDEN
+ //@ !hasraw - FOO_HIDDEN
#[doc(hidden)]
const FOO_HIDDEN: u8 = 0;
}
@@ -13,22 +13,22 @@ pub trait Foo {
pub struct Bar;
impl Foo for Bar {
- // @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar'
- // @has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
+ //@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Foo for Bar'
+ //@ has - '//*[@id="associatedconstant.FOO"]' 'const FOO: usize'
const FOO: usize = 12;
- // @has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
+ //@ has - '//*[@id="associatedconstant.FOO_NO_DEFAULT"]' 'const FOO_NO_DEFAULT: bool'
const FOO_NO_DEFAULT: bool = false;
- // @!hasraw - FOO_HIDDEN
+ //@ !hasraw - FOO_HIDDEN
#[doc(hidden)]
const FOO_HIDDEN: u8 = 0;
}
impl Bar {
- // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
+ //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAR"]' \
// 'const BAR: usize'
pub const BAR: usize = 3;
- // @has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \
+ //@ has - '//*[@id="associatedconstant.BAR_ESCAPED"]' \
// "const BAR_ESCAPED: &'static str = \"markup\""
pub const BAR_ESCAPED: &'static str = "markup";
}
@@ -36,7 +36,7 @@ impl Bar {
pub struct Baz<'a, U: 'a, T>(T, &'a [U]);
impl Bar {
- // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \
+ //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.BAZ"]' \
// "const BAZ: Baz<'static, u8, u32>"
pub const BAZ: Baz<'static, u8, u32> = Baz(321, &[1, 2, 3]);
}
@@ -44,60 +44,60 @@ impl Bar {
pub fn f(_: &(ToString + 'static)) {}
impl Bar {
- // @has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
+ //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \
// "const F: fn(_: &(dyn ToString + 'static))"
pub const F: fn(_: &(ToString + 'static)) = f;
}
impl Bar {
- // @!hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE'
+ //@ !hasraw assoc_consts/struct.Bar.html 'BAR_PRIVATE'
const BAR_PRIVATE: char = 'a';
- // @!hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN'
+ //@ !hasraw assoc_consts/struct.Bar.html 'BAR_HIDDEN'
#[doc(hidden)]
pub const BAR_HIDDEN: &'static str = "a";
}
-// @has assoc_consts/trait.Qux.html
+//@ has assoc_consts/trait.Qux.html
pub trait Qux {
- // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
- // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
/// Docs for QUX0 in trait.
const QUX0: u8;
- // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
- // @has - '//*[@class="docblock"]' "Docs for QUX1 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX1 in trait."
/// Docs for QUX1 in trait.
const QUX1: i8;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
- // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
/// Docs for QUX_DEFAULT12 in trait.
const QUX_DEFAULT0: u16 = 1;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
- // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in trait."
/// Docs for QUX_DEFAULT1 in trait.
const QUX_DEFAULT1: i16 = 2;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
- // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
/// Docs for QUX_DEFAULT2 in trait.
const QUX_DEFAULT2: u32 = 3;
}
-// @has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar'
+//@ has assoc_consts/struct.Bar.html '//h3[@class="code-header"]' 'impl Qux for Bar'
impl Qux for Bar {
- // @has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
- // @has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX0"]' 'const QUX0: u8'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX0 in trait."
/// Docs for QUX0 in trait.
const QUX0: u8 = 4;
- // @has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
- // @has - '//*[@class="docblock"]' "Docs for QUX1 in impl."
+ //@ has - '//*[@id="associatedconstant.QUX1"]' 'const QUX1: i8'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX1 in impl."
/// Docs for QUX1 in impl.
const QUX1: i8 = 5;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
- // @has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT0"]' 'const QUX_DEFAULT0: u16'
+ //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT12 in trait."
const QUX_DEFAULT0: u16 = 6;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
- // @has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT1"]' 'const QUX_DEFAULT1: i16'
+ //@ has - '//*[@class="docblock"]' "Docs for QUX_DEFAULT1 in impl."
/// Docs for QUX_DEFAULT1 in impl.
const QUX_DEFAULT1: i16 = 7;
- // @has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
- // @has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
+ //@ has - '//*[@id="associatedconstant.QUX_DEFAULT2"]' 'const QUX_DEFAULT2: u32'
+ //@ has - '//div[@class="impl-items"]//*[@class="docblock"]' "Docs for QUX_DEFAULT2 in trait."
}
diff --git a/tests/rustdoc/assoc-item-cast.rs b/tests/rustdoc/assoc-item-cast.rs
index ad8235985bcf0..17b7cf6f0dad8 100644
--- a/tests/rustdoc/assoc-item-cast.rs
+++ b/tests/rustdoc/assoc-item-cast.rs
@@ -9,6 +9,6 @@ pub trait AsExpression {
fn as_expression(self) -> Self::Expression;
}
-// @has foo/type.AsExprOf.html
-// @has - '//pre[@class="rust item-decl"]' 'type AsExprOf- =
- >::Expression;'
+//@ has foo/type.AsExprOf.html
+//@ has - '//pre[@class="rust item-decl"]' 'type AsExprOf
- =
- >::Expression;'
pub type AsExprOf
- =
- >::Expression;
diff --git a/tests/rustdoc/assoc-type-bindings-20646.rs b/tests/rustdoc/assoc-type-bindings-20646.rs
index 3d752551d1b6b..c79d07ff5bd7d 100644
--- a/tests/rustdoc/assoc-type-bindings-20646.rs
+++ b/tests/rustdoc/assoc-type-bindings-20646.rs
@@ -7,22 +7,22 @@
extern crate issue_20646;
-// @has issue_20646/trait.Trait.html \
+//@ has issue_20646/trait.Trait.html \
// '//*[@id="associatedtype.Output"]' \
// 'type Output'
pub trait Trait {
type Output;
}
-// @has issue_20646/fn.fun.html \
+//@ has issue_20646/fn.fun.html \
// '//pre[@class="rust item-decl"]' 'where T: Trait