about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2023-05-02 22:01:28 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2023-09-15 21:32:28 +0200
commit7681f63cab88109dd8d445cf7b49cbbd63f81e75 (patch)
tree663bd3e03b0f40c8cc0113a0d47406f374208775 /tests
parent4ce17fa30eeef32235e9b305f56b5651c6d35276 (diff)
downloadrust-7681f63cab88109dd8d445cf7b49cbbd63f81e75.tar.gz
rust-7681f63cab88109dd8d445cf7b49cbbd63f81e75.zip
Implement new eBNF for codeblock attributes
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs82
-rw-r--r--tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr90
-rw-r--r--tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs13
-rw-r--r--tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr17
-rw-r--r--tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr4
-rw-r--r--tests/rustdoc/custom_code_classes.rs2
6 files changed, 146 insertions, 62 deletions
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs
index c28921b01f1..dd8759b7e37 100644
--- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs
+++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.rs
@@ -6,14 +6,80 @@
 #![feature(no_core)]
 #![no_core]
 
-/// ```{. class= whatever=hehe #id} } {{
+/// ```{. }
 /// main;
 /// ```
-//~^^^ ERROR missing class name after `.`
-//~| ERROR missing class name after `class=`
-//~| ERROR unsupported attribute `whatever=hehe`
-//~| ERROR unsupported attribute `#id`
-//~| ERROR unexpected `}` outside attribute block (`{}`)
-//~| ERROR unclosed attribute block (`{}`): missing `}` at the end
-//~| ERROR unexpected `{` inside attribute block (`{}`)
+//~^^^ ERROR unexpected ` ` character after `.`
 pub fn foo() {}
+
+/// ```{class= a}
+/// main;
+/// ```
+//~^^^ ERROR unexpected ` ` character after `=`
+pub fn foo2() {}
+
+/// ```{#id}
+/// main;
+/// ```
+//~^^^ ERROR unexpected character `#`
+pub fn foo3() {}
+
+/// ```{{
+/// main;
+/// ```
+//~^^^ ERROR unexpected character `{`
+pub fn foo4() {}
+
+/// ```}
+/// main;
+/// ```
+//~^^^ ERROR unexpected character `}`
+pub fn foo5() {}
+
+/// ```)
+/// main;
+/// ```
+//~^^^ ERROR unexpected character `)`
+pub fn foo6() {}
+
+/// ```{class=}
+/// main;
+/// ```
+//~^^^ ERROR unexpected `}` character after `=`
+pub fn foo7() {}
+
+/// ```(
+/// main;
+/// ```
+//~^^^ ERROR unclosed comment: missing `)` at the end
+pub fn foo8() {}
+
+/// ```{class=one=two}
+/// main;
+/// ```
+//~^^^ ERROR unexpected `=`
+pub fn foo9() {}
+
+/// ```{.one.two}
+/// main;
+/// ```
+//~^^^ ERROR unexpected `.` character
+pub fn foo10() {}
+
+/// ```{class=.one}
+/// main;
+/// ```
+//~^^^ ERROR unexpected `.` character after `=`
+pub fn foo11() {}
+
+/// ```{class=one.two}
+/// main;
+/// ```
+//~^^^ ERROR unexpected `.` character
+pub fn foo12() {}
+
+/// ```{(comment)}
+/// main;
+/// ```
+//~^^^ ERROR unexpected character `(`
+pub fn foo13() {}
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr
index f19b62914db..3e0dc4b2f7a 100644
--- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr
+++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning.stderr
@@ -1,7 +1,7 @@
-error: missing class name after `.`
+error: unexpected ` ` character after `.`
   --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```{. }
 LL | | /// main;
 LL | | /// ```
    | |_______^
@@ -13,53 +13,101 @@ LL | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
 
-error: missing class name after `class=`
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected ` ` character after `=`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:15:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```{class= a}
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: unsupported attribute `whatever=hehe`
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected character `#`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:21:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```{#id}
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: unsupported attribute `#id`
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected character `{`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:27:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```{{
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: unexpected `}` outside attribute block (`{}`)
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected character `}`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:33:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```}
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: unexpected `{` inside attribute block (`{}`)
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected character `)`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:39:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```)
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: unclosed attribute block (`{}`): missing `}` at the end
-  --> $DIR/custom_code_classes_in_docs-warning.rs:9:1
+error: unexpected `}` character after `=`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:45:1
+   |
+LL | / /// ```{class=}
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unclosed comment: missing `)` at the end
+  --> $DIR/custom_code_classes_in_docs-warning.rs:51:1
+   |
+LL | / /// ```(
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unexpected `=` character
+  --> $DIR/custom_code_classes_in_docs-warning.rs:57:1
+   |
+LL | / /// ```{class=one=two}
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unexpected `.` character
+  --> $DIR/custom_code_classes_in_docs-warning.rs:63:1
+   |
+LL | / /// ```{.one.two}
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unexpected `.` character after `=`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:69:1
+   |
+LL | / /// ```{class=.one}
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unexpected `.` character
+  --> $DIR/custom_code_classes_in_docs-warning.rs:75:1
+   |
+LL | / /// ```{class=one.two}
+LL | | /// main;
+LL | | /// ```
+   | |_______^
+
+error: unexpected character `(`
+  --> $DIR/custom_code_classes_in_docs-warning.rs:81:1
    |
-LL | / /// ```{. class= whatever=hehe #id} } {{
+LL | / /// ```{(comment)}
 LL | | /// main;
 LL | | /// ```
    | |_______^
 
-error: aborting due to 7 previous errors
+error: aborting due to 13 previous errors
 
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs
deleted file mode 100644
index b2ce7407ec6..00000000000
--- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.rs
+++ /dev/null
@@ -1,13 +0,0 @@
-// This test ensures that warnings are working as expected for "custom_code_classes_in_docs"
-// feature.
-
-#![feature(custom_code_classes_in_docs)]
-#![deny(warnings)]
-#![feature(no_core)]
-#![no_core]
-
-/// ```{class=}
-/// main;
-/// ```
-//~^^^ ERROR missing class name after `class=`
-pub fn foo() {}
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr
deleted file mode 100644
index 52bb1dae9f6..00000000000
--- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning2.stderr
+++ /dev/null
@@ -1,17 +0,0 @@
-error: missing class name after `class=`
-  --> $DIR/custom_code_classes_in_docs-warning2.rs:9:1
-   |
-LL | / /// ```{class=}
-LL | | /// main;
-LL | | /// ```
-   | |_______^
-   |
-note: the lint level is defined here
-  --> $DIR/custom_code_classes_in_docs-warning2.rs:5:9
-   |
-LL | #![deny(warnings)]
-   |         ^^^^^^^^
-   = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
-
-error: aborting due to previous error
-
diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr
index 7432af19360..4f2ded78c29 100644
--- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr
+++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr
@@ -1,4 +1,4 @@
-error: unclosed quote string: missing `"` at the end
+error: unclosed quote string `"`
   --> $DIR/custom_code_classes_in_docs-warning3.rs:9:1
    |
 LL | / /// ```{class="}
@@ -17,7 +17,7 @@ LL | #![deny(warnings)]
    |         ^^^^^^^^
    = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]`
 
-error: unclosed quote string: missing `"` at the end
+error: unclosed quote string `"`
   --> $DIR/custom_code_classes_in_docs-warning3.rs:9:1
    |
 LL | / /// ```{class="}
diff --git a/tests/rustdoc/custom_code_classes.rs b/tests/rustdoc/custom_code_classes.rs
index f110721c5a7..cd20d8b7d6c 100644
--- a/tests/rustdoc/custom_code_classes.rs
+++ b/tests/rustdoc/custom_code_classes.rs
@@ -22,7 +22,7 @@
 ///
 /// Testing with multiple "unknown". Only the first should be used.
 ///
-/// ```whatever4{.huhu-c} whatever5
+/// ```whatever4,{.huhu-c} whatever5
 /// main;
 /// ```
 pub struct Bar;