11error[E0631]: type mismatch in function arguments
2- --> $DIR/suggest-option-asderef-unfixable.rs:24 :40
2+ --> $DIR/suggest-option-asderef-unfixable.rs:20 :40
33 |
4- LL | fn takes_str_but_too_many_refs(_: && str) -> Option<()> {
5- | ------------------------------------------------------ found signature defined here
4+ LL | fn takes_str_but_too_many_refs(_: &str) -> Option<()> {
5+ | ----------------------------------------------------- found signature defined here
66...
77LL | let _ = produces_string().and_then(takes_str_but_too_many_refs);
88 | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this
99 | |
1010 | required by a bound introduced by this call
1111 |
1212 = note: expected function signature `fn(String) -> _`
13- found function signature `fn(&& str) -> _`
13+ found function signature `fn(&str) -> _`
1414note: required by a bound in `Option::<T>::and_then`
1515 --> $SRC_DIR/core/src/option.rs:LL:COL
1616help: consider wrapping the function in a closure
1717 |
18- LL | let _ = produces_string().and_then(|arg0: String| takes_str_but_too_many_refs(/* &&str */));
19- | ++++++++++++++ +++++++++++++
20-
21- error[E0277]: expected an `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
22- --> $DIR/suggest-option-asderef-unfixable.rs:26:40
23- |
24- LL | let _ = produces_string().and_then(takes_str_but_wrong_abi);
25- | -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
26- | |
27- | required by a bound introduced by this call
18+ LL | let _ = produces_string().and_then(|arg0: String| takes_str_but_too_many_refs(/* &str */));
19+ | ++++++++++++++ ++++++++++++
20+ help: call `Option::as_deref()` first
2821 |
29- = help: the trait `FnOnce(String)` is not implemented for fn item `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
30- note: required by a bound in `Option::<T>::and_then`
31- --> $SRC_DIR/core/src/option.rs:LL:COL
22+ LL | let _ = produces_string().as_deref().and_then(takes_str_but_too_many_refs);
23+ | +++++++++++
3224
33- error[E0277]: expected an `FnOnce(String)` closure, found `for<'a> unsafe fn(&'a str ) -> Option<()> {takes_str_but_unsafe}`
34- --> $DIR/suggest-option-asderef-unfixable.rs:28 :40
25+ error[E0277]: expected an `FnOnce(String)` closure, found `unsafe fn(String ) -> Option<()> {takes_str_but_unsafe}`
26+ --> $DIR/suggest-option-asderef-unfixable.rs:22 :40
3527 |
3628LL | let _ = produces_string().and_then(takes_str_but_unsafe);
3729 | -------- ^^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
3830 | |
3931 | required by a bound introduced by this call
4032 |
41- = help: the trait `FnOnce(String)` is not implemented for fn item `for<'a> unsafe fn(&'a str ) -> Option<()> {takes_str_but_unsafe}`
33+ = help: the trait `FnOnce(String)` is not implemented for fn item `unsafe fn(String ) -> Option<()> {takes_str_but_unsafe}`
4234 = note: unsafe function cannot be called generically without an unsafe block
4335note: required by a bound in `Option::<T>::and_then`
4436 --> $SRC_DIR/core/src/option.rs:LL:COL
4537
4638error[E0593]: function is expected to take 1 argument, but it takes 0 arguments
47- --> $DIR/suggest-option-asderef-unfixable.rs:30 :40
39+ --> $DIR/suggest-option-asderef-unfixable.rs:24 :40
4840 |
4941LL | fn no_args() -> Option<()> {
5042 | -------------------------- takes 0 arguments
@@ -58,26 +50,26 @@ note: required by a bound in `Option::<T>::and_then`
5850 --> $SRC_DIR/core/src/option.rs:LL:COL
5951
6052error[E0631]: type mismatch in function arguments
61- --> $DIR/suggest-option-asderef-unfixable.rs:32 :45
53+ --> $DIR/suggest-option-asderef-unfixable.rs:26 :45
6254 |
63- LL | fn takes_str_but_too_many_refs(_: && str) -> Option<()> {
64- | ------------------------------------------------------ found signature defined here
55+ LL | fn takes_str_but_too_many_refs(_: &str) -> Option<()> {
56+ | ----------------------------------------------------- found signature defined here
6557...
6658LL | let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs);
6759 | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this
6860 | |
6961 | required by a bound introduced by this call
7062 |
7163 = note: expected function signature `fn(TypeWithoutDeref) -> _`
72- found function signature `fn(&& str) -> _`
64+ found function signature `fn(&str) -> _`
7365note: required by a bound in `Option::<T>::and_then`
7466 --> $SRC_DIR/core/src/option.rs:LL:COL
7567help: consider wrapping the function in a closure
7668 |
77- LL | let _ = Some(TypeWithoutDeref).and_then(|arg0: TypeWithoutDeref| takes_str_but_too_many_refs(/* && str */));
78- | ++++++++++++++++++++++++ +++++++++++++
69+ LL | let _ = Some(TypeWithoutDeref).and_then(|arg0: TypeWithoutDeref| takes_str_but_too_many_refs(/* &str */));
70+ | ++++++++++++++++++++++++ ++++++++++++
7971
80- error: aborting due to 5 previous errors
72+ error: aborting due to 4 previous errors
8173
8274Some errors have detailed explanations: E0277, E0593, E0631.
8375For more information about an error, try `rustc --explain E0277`.
0 commit comments