about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/suggestions/issue-104961.fixed16
-rw-r--r--tests/ui/suggestions/issue-104961.rs16
-rw-r--r--tests/ui/suggestions/issue-104961.stderr37
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/ui/suggestions/issue-104961.fixed b/tests/ui/suggestions/issue-104961.fixed
new file mode 100644
index 00000000000..520d638b174
--- /dev/null
+++ b/tests/ui/suggestions/issue-104961.fixed
@@ -0,0 +1,16 @@
+// run-rustfix
+
+fn foo(x: &str) -> bool {
+    x.starts_with(&("hi".to_string() + " you"))
+    //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+}
+
+fn foo2(x: &str) -> bool {
+    x.starts_with(&"hi".to_string())
+    //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+}
+
+fn main() {
+    foo("hi you");
+    foo2("hi");
+}
diff --git a/tests/ui/suggestions/issue-104961.rs b/tests/ui/suggestions/issue-104961.rs
new file mode 100644
index 00000000000..aeb787abb6f
--- /dev/null
+++ b/tests/ui/suggestions/issue-104961.rs
@@ -0,0 +1,16 @@
+// run-rustfix
+
+fn foo(x: &str) -> bool {
+    x.starts_with("hi".to_string() + " you")
+    //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+}
+
+fn foo2(x: &str) -> bool {
+    x.starts_with("hi".to_string())
+    //~^ ERROR expected a `FnMut<(char,)>` closure, found `String`
+}
+
+fn main() {
+    foo("hi you");
+    foo2("hi");
+}
diff --git a/tests/ui/suggestions/issue-104961.stderr b/tests/ui/suggestions/issue-104961.stderr
new file mode 100644
index 00000000000..8cec6a3f827
--- /dev/null
+++ b/tests/ui/suggestions/issue-104961.stderr
@@ -0,0 +1,37 @@
+error[E0277]: expected a `FnMut<(char,)>` closure, found `String`
+  --> $DIR/issue-104961.rs:4:19
+   |
+LL |     x.starts_with("hi".to_string() + " you")
+   |       ----------- ^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Pattern<'_>` is not implemented for `String`
+   |       |
+   |       required by a bound introduced by this call
+   |
+   = note: the trait bound `String: Pattern<'_>` is not satisfied
+   = note: required for `String` to implement `Pattern<'_>`
+note: required by a bound in `core::str::<impl str>::starts_with`
+  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+help: consider borrowing here
+   |
+LL |     x.starts_with(&("hi".to_string() + " you"))
+   |                   ++                         +
+
+error[E0277]: expected a `FnMut<(char,)>` closure, found `String`
+  --> $DIR/issue-104961.rs:9:19
+   |
+LL |     x.starts_with("hi".to_string())
+   |       ----------- ^^^^^^^^^^^^^^^^ the trait `Pattern<'_>` is not implemented for `String`
+   |       |
+   |       required by a bound introduced by this call
+   |
+   = note: the trait bound `String: Pattern<'_>` is not satisfied
+   = note: required for `String` to implement `Pattern<'_>`
+note: required by a bound in `core::str::<impl str>::starts_with`
+  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+help: consider borrowing here
+   |
+LL |     x.starts_with(&"hi".to_string())
+   |                   +
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0277`.