about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/rustdoc-gui/search-result-impl-disambiguation.goml21
-rw-r--r--tests/rustdoc-gui/src/lib2/another_mod/mod.rs20
-rw-r--r--tests/rustdoc-ui/remap-path-prefix-lint.rs10
-rw-r--r--tests/rustdoc-ui/remap-path-prefix-lint.stderr14
-rw-r--r--tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.rs15
-rw-r--r--tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.stderr51
6 files changed, 130 insertions, 1 deletions
diff --git a/tests/rustdoc-gui/search-result-impl-disambiguation.goml b/tests/rustdoc-gui/search-result-impl-disambiguation.goml
index 3e49ac33025..bca52b46498 100644
--- a/tests/rustdoc-gui/search-result-impl-disambiguation.goml
+++ b/tests/rustdoc-gui/search-result-impl-disambiguation.goml
@@ -41,3 +41,24 @@ assert-document-property: ({
     "URL": "struct.ZyxwvutMethodDisambiguation.html#method.method_impl_disambiguation-1"
 }, ENDS_WITH)
 assert: "section:target"
+
+// Checks that, if a type has two methods with the same name,
+// and if it has multiple inherent impl blocks, that the numeric
+// impl block's disambiguator is also acted upon.
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=MultiImplBlockStruct->bool"
+wait-for: "#search-tabs"
+assert-count: ("a.result-method", 1)
+assert-attribute: ("a.result-method", {
+    "href": "../lib2/another_mod/struct.MultiImplBlockStruct.html#impl-MultiImplBlockStruct/method.second_fn"
+})
+click: "a.result-method"
+wait-for: "details:has(summary > #impl-MultiImplBlockStruct-1) > div section[id='method.second_fn']:target"
+
+go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=MultiImplBlockStruct->u32"
+wait-for: "#search-tabs"
+assert-count: ("a.result-method", 1)
+assert-attribute: ("a.result-method", {
+    "href": "../lib2/another_mod/struct.MultiImplBlockStruct.html#impl-MultiImplBlockTrait-for-MultiImplBlockStruct/method.second_fn"
+})
+click: "a.result-method"
+wait-for: "details:has(summary > #impl-MultiImplBlockTrait-for-MultiImplBlockStruct) > div section[id='method.second_fn-1']:target"
diff --git a/tests/rustdoc-gui/src/lib2/another_mod/mod.rs b/tests/rustdoc-gui/src/lib2/another_mod/mod.rs
index 9a4f007a2f0..77f83d29766 100644
--- a/tests/rustdoc-gui/src/lib2/another_mod/mod.rs
+++ b/tests/rustdoc-gui/src/lib2/another_mod/mod.rs
@@ -1 +1,19 @@
-pub fn tadam() {}
+pub struct MultiImplBlockStruct;
+
+impl MultiImplBlockStruct {
+    pub fn first_fn() {}
+}
+
+impl MultiImplBlockStruct {
+    pub fn second_fn(self) -> bool { true }
+}
+
+pub trait MultiImplBlockTrait {
+    fn first_fn();
+    fn second_fn(self) -> u32;
+}
+
+impl MultiImplBlockTrait for MultiImplBlockStruct {
+    fn first_fn() {}
+    fn second_fn(self) -> u32 { 1 }
+}
diff --git a/tests/rustdoc-ui/remap-path-prefix-lint.rs b/tests/rustdoc-ui/remap-path-prefix-lint.rs
new file mode 100644
index 00000000000..f27863e825d
--- /dev/null
+++ b/tests/rustdoc-ui/remap-path-prefix-lint.rs
@@ -0,0 +1,10 @@
+// Regression test for remapped paths in rustdoc errors
+// <https://github.com/rust-lang/rust/issues/69264>.
+
+//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path
+//@ rustc-env:RUST_BACKTRACE=0
+
+#![deny(rustdoc::invalid_html_tags)]
+
+/// </script>
+pub struct Bar;
diff --git a/tests/rustdoc-ui/remap-path-prefix-lint.stderr b/tests/rustdoc-ui/remap-path-prefix-lint.stderr
new file mode 100644
index 00000000000..d7c1bb1965d
--- /dev/null
+++ b/tests/rustdoc-ui/remap-path-prefix-lint.stderr
@@ -0,0 +1,14 @@
+error: unopened HTML tag `script`
+  --> remapped_path/remap-path-prefix-lint.rs:9:5
+   |
+LL | /// </script>
+   |     ^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> remapped_path/remap-path-prefix-lint.rs:7:9
+   |
+LL | #![deny(rustdoc::invalid_html_tags)]
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.rs b/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.rs
new file mode 100644
index 00000000000..f5f8fa51e37
--- /dev/null
+++ b/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.rs
@@ -0,0 +1,15 @@
+trait Trait<Type> {
+    type Type;
+
+    fn one(&self, val:  impl Trait<Type: Default>);
+    //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied
+
+    fn two<T: Trait<Type: Default>>(&self) -> T;
+    //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied
+
+    fn three<T>(&self) -> T where
+        T: Trait<Type: Default>,;
+    //~^ ERROR trait takes 1 generic argument but 0 generic arguments were supplied
+}
+
+fn main() {}
diff --git a/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.stderr b/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.stderr
new file mode 100644
index 00000000000..06ab06003a1
--- /dev/null
+++ b/tests/ui/associated-type-bounds/name-same-as-generic-type-issue-128249.stderr
@@ -0,0 +1,51 @@
+error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:4:30
+   |
+LL |     fn one(&self, val:  impl Trait<Type: Default>);
+   |                              ^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `Type`
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7
+   |
+LL | trait Trait<Type> {
+   |       ^^^^^ ----
+help: add missing generic argument
+   |
+LL |     fn one(&self, val:  impl Trait<Type, Type: Default>);
+   |                                    +++++
+
+error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:7:15
+   |
+LL |     fn two<T: Trait<Type: Default>>(&self) -> T;
+   |               ^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `Type`
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7
+   |
+LL | trait Trait<Type> {
+   |       ^^^^^ ----
+help: add missing generic argument
+   |
+LL |     fn two<T: Trait<Type, Type: Default>>(&self) -> T;
+   |                     +++++
+
+error[E0107]: trait takes 1 generic argument but 0 generic arguments were supplied
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:11:12
+   |
+LL |         T: Trait<Type: Default>,;
+   |            ^^^^^ expected 1 generic argument
+   |
+note: trait defined here, with 1 generic parameter: `Type`
+  --> $DIR/name-same-as-generic-type-issue-128249.rs:1:7
+   |
+LL | trait Trait<Type> {
+   |       ^^^^^ ----
+help: add missing generic argument
+   |
+LL |         T: Trait<Type, Type: Default>,;
+   |                  +++++
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0107`.