summaryrefslogtreecommitdiffstats
path: root/tests/ui/mismatched_types/suggest-option-asderef.stderr
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/mismatched_types/suggest-option-asderef.stderr')
-rw-r--r--tests/ui/mismatched_types/suggest-option-asderef.stderr88
1 files changed, 88 insertions, 0 deletions
diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr
new file mode 100644
index 000000000..01341603d
--- /dev/null
+++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr
@@ -0,0 +1,88 @@
+error[E0631]: type mismatch in function arguments
+ --> $DIR/suggest-option-asderef.rs:25:52
+ |
+LL | fn takes_str(_: &str) -> Option<()> {
+ | ----------------------------------- found signature defined here
+...
+LL | let _: Option<()> = produces_string().and_then(takes_str);
+ | -------- ^^^^^^^^^ expected due to this
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: expected function signature `fn(String) -> _`
+ found function signature `for<'a> fn(&'a str) -> _`
+note: required by a bound in `Option::<T>::and_then`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+help: call `Option::as_deref()` first
+ |
+LL | let _: Option<()> = produces_string().as_deref().and_then(takes_str);
+ | +++++++++++
+
+error[E0631]: type mismatch in function arguments
+ --> $DIR/suggest-option-asderef.rs:28:55
+ |
+LL | fn takes_str(_: &str) -> Option<()> {
+ | ----------------------------------- found signature defined here
+...
+LL | let _: Option<Option<()>> = produces_string().map(takes_str);
+ | --- ^^^^^^^^^ expected due to this
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: expected function signature `fn(String) -> _`
+ found function signature `for<'a> fn(&'a str) -> _`
+note: required by a bound in `Option::<T>::map`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+help: call `Option::as_deref()` first
+ |
+LL | let _: Option<Option<()>> = produces_string().as_deref().map(takes_str);
+ | +++++++++++
+
+error[E0631]: type mismatch in function arguments
+ --> $DIR/suggest-option-asderef.rs:31:55
+ |
+LL | fn takes_str_mut(_: &mut str) -> Option<()> {
+ | ------------------------------------------- found signature defined here
+...
+LL | let _: Option<Option<()>> = produces_string().map(takes_str_mut);
+ | --- ^^^^^^^^^^^^^ expected due to this
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: expected function signature `fn(String) -> _`
+ found function signature `for<'a> fn(&'a mut str) -> _`
+note: required by a bound in `Option::<T>::map`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+help: call `Option::as_deref_mut()` first
+ |
+LL | let _: Option<Option<()>> = produces_string().as_deref_mut().map(takes_str_mut);
+ | +++++++++++++++
+
+error[E0631]: type mismatch in function arguments
+ --> $DIR/suggest-option-asderef.rs:36:40
+ |
+LL | fn generic_ref<T>(_: &T) -> Option<()> {
+ | -------------------------------------- found signature defined here
+...
+LL | let _ = produces_string().and_then(generic_ref);
+ | -------- ^^^^^^^^^^^ expected due to this
+ | |
+ | required by a bound introduced by this call
+ |
+ = note: expected function signature `fn(String) -> _`
+ found function signature `for<'a> fn(&'a _) -> _`
+note: required by a bound in `Option::<T>::and_then`
+ --> $SRC_DIR/core/src/option.rs:LL:COL
+help: do not borrow the argument
+ |
+LL - fn generic_ref<T>(_: &T) -> Option<()> {
+LL + fn generic_ref<T>(_: T) -> Option<()> {
+ |
+help: call `Option::as_deref()` first
+ |
+LL | let _ = produces_string().as_deref().and_then(generic_ref);
+ | +++++++++++
+
+error: aborting due to 4 previous errors
+
+For more information about this error, try `rustc --explain E0631`.