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/setting-go-to-only-result.goml63
-rw-r--r--tests/ui/inference/char-as-str-single.fixed9
-rw-r--r--tests/ui/inference/char-as-str-single.rs9
-rw-r--r--tests/ui/inference/char-as-str-single.stderr15
4 files changed, 95 insertions, 1 deletions
diff --git a/tests/rustdoc-gui/setting-go-to-only-result.goml b/tests/rustdoc-gui/setting-go-to-only-result.goml
new file mode 100644
index 00000000000..3811011a64e
--- /dev/null
+++ b/tests/rustdoc-gui/setting-go-to-only-result.goml
@@ -0,0 +1,63 @@
+// Checks that the setting "Directly go to item in search if there is only one result " is working as expected.
+
+define-function: (
+    "check-setting",
+    (storage_value, setting_attribute_value),
+    block {
+        assert-local-storage: {"rustdoc-go-to-only-result": |storage_value|}
+        click: "#settings-menu"
+        wait-for: "#settings"
+        assert-property: ("#go-to-only-result", {"checked": |setting_attribute_value|})
+    }
+)
+
+goto: "file://" + |DOC_PATH| + "/lib2/index.html"
+
+call-function: ("check-setting", {
+    "storage_value": null,
+    "setting_attribute_value": "false",
+})
+
+// By default, the search doesn't automatically go to the page if there is only one result.
+goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+// It will timeout if the setting isn't working.
+wait-for: "#search"
+assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
+
+// Now we change its value.
+click: "#settings-menu"
+wait-for: "#settings"
+click: "#go-to-only-result"
+assert-local-storage: {"rustdoc-go-to-only-result": "true"}
+
+goto: "file://" + |DOC_PATH| + "/lib2/index.html"
+// We enter it into the search.
+write: (".search-input", "HasALongTraitWithParams")
+wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
+assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
+
+// We try again to see if it goes to the only result
+goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+wait-for-document-property: {"title": "HasALongTraitWithParams in lib2 - Rust"}
+assert-document-property: ({"URL": "/lib2/struct.HasALongTraitWithParams.html"}, ENDS_WITH)
+
+// We check the settings
+call-function: ("check-setting", {
+    "storage_value": "true",
+    "setting_attribute_value": "true",
+})
+
+// And now we re-disable the setting.
+click: "#go-to-only-result"
+assert-local-storage: {"rustdoc-go-to-only-result": "false"}
+
+goto: "file://" + |DOC_PATH| + "/lib2/index.html?search=HasALongTraitWithParams"
+// It will timeout if the setting isn't working.
+wait-for: "#search"
+assert-document-property: ({"URL": "/lib2/index.html"}, CONTAINS)
+
+// And we check everything is back the way it was before.
+call-function: ("check-setting", {
+    "storage_value": "false",
+    "setting_attribute_value": "false",
+})
diff --git a/tests/ui/inference/char-as-str-single.fixed b/tests/ui/inference/char-as-str-single.fixed
index bab1854dc51..1621a279f03 100644
--- a/tests/ui/inference/char-as-str-single.fixed
+++ b/tests/ui/inference/char-as-str-single.fixed
@@ -10,3 +10,12 @@ fn main() {
     let _: char = '人'; //~ ERROR mismatched types
     let _: char = '\''; //~ ERROR mismatched types
 }
+
+// regression test for https://github.com/rust-lang/rust/issues/109586
+#[allow(dead_code)]
+fn convert_c_to_str(c: char) {
+    match c {
+        'A' => {} //~ ERROR mismatched types
+        _ => {}
+    }
+}
diff --git a/tests/ui/inference/char-as-str-single.rs b/tests/ui/inference/char-as-str-single.rs
index 736920643b2..2903142f159 100644
--- a/tests/ui/inference/char-as-str-single.rs
+++ b/tests/ui/inference/char-as-str-single.rs
@@ -10,3 +10,12 @@ fn main() {
     let _: char = "人"; //~ ERROR mismatched types
     let _: char = "'"; //~ ERROR mismatched types
 }
+
+// regression test for https://github.com/rust-lang/rust/issues/109586
+#[allow(dead_code)]
+fn convert_c_to_str(c: char) {
+    match c {
+        "A" => {} //~ ERROR mismatched types
+        _ => {}
+    }
+}
diff --git a/tests/ui/inference/char-as-str-single.stderr b/tests/ui/inference/char-as-str-single.stderr
index 3375ec6ac32..9149efe3240 100644
--- a/tests/ui/inference/char-as-str-single.stderr
+++ b/tests/ui/inference/char-as-str-single.stderr
@@ -37,6 +37,19 @@ help: if you meant to write a `char` literal, use single quotes
 LL |     let _: char = '\'';
    |                   ~~~~
 
-error: aborting due to 3 previous errors
+error[E0308]: mismatched types
+  --> $DIR/char-as-str-single.rs:18:9
+   |
+LL |     match c {
+   |           - this expression has type `char`
+LL |         "A" => {}
+   |         ^^^ expected `char`, found `&str`
+   |
+help: if you meant to write a `char` literal, use single quotes
+   |
+LL |         'A' => {}
+   |         ~~~
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0308`.