File: suggest-option-asderef-unfixable.stderr

package info (click to toggle)
rustc 1.85.0%2Bdfsg3-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental, sid, trixie
  • size: 893,396 kB
  • sloc: xml: 158,127; python: 35,830; javascript: 19,497; cpp: 19,002; sh: 17,245; ansic: 13,127; asm: 4,376; makefile: 1,051; perl: 29; lisp: 29; ruby: 19; sql: 11
file content (83 lines) | stat: -rw-r--r-- 4,453 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
error[E0631]: type mismatch in function arguments
  --> $DIR/suggest-option-asderef-unfixable.rs:24:40
   |
LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> {
   | ------------------------------------------------------ found signature defined here
...
LL |     let _ = produces_string().and_then(takes_str_but_too_many_refs);
   |                               -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this
   |                               |
   |                               required by a bound introduced by this call
   |
   = note: expected function signature `fn(String) -> _`
              found function signature `fn(&&str) -> _`
note: required by a bound in `Option::<T>::and_then`
  --> $SRC_DIR/core/src/option.rs:LL:COL
help: consider wrapping the function in a closure
   |
LL |     let _ = produces_string().and_then(|arg0: String| takes_str_but_too_many_refs(/* &&str */));
   |                                        ++++++++++++++                            +++++++++++++

error[E0277]: expected a `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
  --> $DIR/suggest-option-asderef-unfixable.rs:26:40
   |
LL |     let _ = produces_string().and_then(takes_str_but_wrong_abi);
   |                               -------- ^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(String)` closure, found `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
   |                               |
   |                               required by a bound introduced by this call
   |
   = help: the trait `FnOnce(String)` is not implemented for fn item `for<'a> extern "C" fn(&'a str) -> Option<()> {takes_str_but_wrong_abi}`
note: required by a bound in `Option::<T>::and_then`
  --> $SRC_DIR/core/src/option.rs:LL:COL

error[E0277]: expected a `FnOnce(String)` closure, found `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}`
  --> $DIR/suggest-option-asderef-unfixable.rs:28:40
   |
LL |     let _ = produces_string().and_then(takes_str_but_unsafe);
   |                               -------- ^^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }`
   |                               |
   |                               required by a bound introduced by this call
   |
   = help: the trait `FnOnce(String)` is not implemented for fn item `for<'a> unsafe fn(&'a str) -> Option<()> {takes_str_but_unsafe}`
   = note: unsafe function cannot be called generically without an unsafe block
note: required by a bound in `Option::<T>::and_then`
  --> $SRC_DIR/core/src/option.rs:LL:COL

error[E0593]: function is expected to take 1 argument, but it takes 0 arguments
  --> $DIR/suggest-option-asderef-unfixable.rs:30:40
   |
LL | fn no_args() -> Option<()> {
   | -------------------------- takes 0 arguments
...
LL |     let _ = produces_string().and_then(no_args);
   |                               -------- ^^^^^^^ expected function that takes 1 argument
   |                               |
   |                               required by a bound introduced by this call
   |
note: required by a bound in `Option::<T>::and_then`
  --> $SRC_DIR/core/src/option.rs:LL:COL

error[E0631]: type mismatch in function arguments
  --> $DIR/suggest-option-asderef-unfixable.rs:32:45
   |
LL | fn takes_str_but_too_many_refs(_: &&str) -> Option<()> {
   | ------------------------------------------------------ found signature defined here
...
LL |     let _ = Some(TypeWithoutDeref).and_then(takes_str_but_too_many_refs);
   |                                    -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected due to this
   |                                    |
   |                                    required by a bound introduced by this call
   |
   = note: expected function signature `fn(TypeWithoutDeref) -> _`
              found function signature `fn(&&str) -> _`
note: required by a bound in `Option::<T>::and_then`
  --> $SRC_DIR/core/src/option.rs:LL:COL
help: consider wrapping the function in a closure
   |
LL |     let _ = Some(TypeWithoutDeref).and_then(|arg0: TypeWithoutDeref| takes_str_but_too_many_refs(/* &&str */));
   |                                             ++++++++++++++++++++++++                            +++++++++++++

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0277, E0593, E0631.
For more information about an error, try `rustc --explain E0277`.