forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif-let-rescope-borrowck-suggestions.stderr
90 lines (86 loc) · 3.5 KB
/
if-let-rescope-borrowck-suggestions.stderr
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
84
85
86
87
88
89
90
error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:21:39
|
LL | do_something(if let Some(value) = Droppy.get_ref() { value } else { &0 });
| ^^^^^^ - temporary value is freed at the end of this statement
| |
| creates a temporary value which is freed while still in use
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:21:64
|
LL | do_something(if let Some(value) = Droppy.get_ref() { value } else { &0 });
| ^
help: consider using a `let` binding to create a longer lived value
|
LL ~ let binding = Droppy;
LL ~ do_something(if let Some(value) = binding.get_ref() { value } else { &0 });
|
help: consider rewriting the `if` into `match` which preserves the extended lifetime
|
LL - do_something(if let Some(value) = Droppy.get_ref() { value } else { &0 });
LL + do_something({ match Droppy.get_ref() { Some(value) => { value } _ => { &0 }}});
|
error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:23:39
|
LL | do_something(if let Some(value) = Droppy.get_ref() {
| ^^^^^^ creates a temporary value which is freed while still in use
...
LL | } else if let Some(value) = Droppy.get_ref() {
| - temporary value is freed at the end of this statement
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:26:5
|
LL | } else if let Some(value) = Droppy.get_ref() {
| ^
help: consider using a `let` binding to create a longer lived value
|
LL ~ let binding = Droppy;
LL ~ do_something(if let Some(value) = binding.get_ref() {
|
help: consider rewriting the `if` into `match` which preserves the extended lifetime
|
LL ~ do_something({ match Droppy.get_ref() { Some(value) => {
LL |
LL | value
LL ~ } _ => if let Some(value) = Droppy.get_ref() {
LL |
...
LL | &0
LL ~ }}});
|
error[E0716]: temporary value dropped while borrowed
--> $DIR/if-let-rescope-borrowck-suggestions.rs:26:33
|
LL | } else if let Some(value) = Droppy.get_ref() {
| ^^^^^^ creates a temporary value which is freed while still in use
...
LL | } else {
| - temporary value is freed at the end of this statement
|
note: lifetimes for temporaries generated in `if let`s have been shortened in Edition 2024 so that they are dropped here instead
--> $DIR/if-let-rescope-borrowck-suggestions.rs:29:5
|
LL | } else {
| ^
help: consider using a `let` binding to create a longer lived value
|
LL ~ let binding = Droppy;
LL ~ do_something(if let Some(value) = Droppy.get_ref() {
LL |
LL | value
LL ~ } else if let Some(value) = binding.get_ref() {
|
help: consider rewriting the `if` into `match` which preserves the extended lifetime
|
LL ~ } else { match Droppy.get_ref() { Some(value) => {
LL |
LL | value
LL ~ } _ => {
LL | &0
LL ~ }}});
|
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0716`.