rust/tests/ui/suggestions/mut-ref-reassignment.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

56 lines
2.0 KiB
Plaintext
Raw Normal View History

error[E0308]: mismatched types
--> $DIR/mut-ref-reassignment.rs:2:11
|
LL | fn suggestion(opt: &mut Option<String>) {
| ------------------- expected due to this parameter type
2019-05-23 17:32:01 +00:00
LL | opt = None;
| ^^^^ expected `&mut Option<String>`, found `Option<_>`
|
= note: expected mutable reference `&mut Option<String>`
found enum `Option<_>`
help: consider dereferencing here to assign to the mutably borrowed value
|
2019-05-23 17:32:01 +00:00
LL | *opt = None;
| +
2019-05-23 17:32:01 +00:00
error[E0308]: mismatched types
--> $DIR/mut-ref-reassignment.rs:6:11
|
LL | fn no_suggestion(opt: &mut Result<String, ()>) {
| ----------------------- expected due to this parameter type
2019-05-23 17:32:01 +00:00
LL | opt = None
| ^^^^ expected `&mut Result<String, ()>`, found `Option<_>`
2019-05-23 17:32:01 +00:00
|
2021-01-28 16:01:36 +00:00
= note: expected mutable reference `&mut Result<String, ()>`
found enum `Option<_>`
2019-05-23 17:32:01 +00:00
error[E0308]: mismatched types
--> $DIR/mut-ref-reassignment.rs:10:11
|
LL | fn suggestion2(opt: &mut Option<String>) {
| ------------------- expected due to this parameter type
2019-05-23 17:32:01 +00:00
LL | opt = Some(String::new())
| ^^^^^^^^^^^^^^^^^^^ expected `&mut Option<String>`, found `Option<String>`
2019-05-23 17:32:01 +00:00
|
= note: expected mutable reference `&mut Option<String>`
found enum `Option<String>`
help: consider dereferencing here to assign to the mutably borrowed value
2019-05-23 17:32:01 +00:00
|
LL | *opt = Some(String::new())
| +
2019-05-23 17:32:01 +00:00
error[E0308]: mismatched types
--> $DIR/mut-ref-reassignment.rs:14:11
|
LL | fn no_suggestion2(opt: &mut Option<String>) {
| ------------------- expected due to this parameter type
2019-05-23 17:32:01 +00:00
LL | opt = Some(42)
| ^^^^^^^^ expected `&mut Option<String>`, found `Option<{integer}>`
2019-05-23 17:32:01 +00:00
|
= note: expected mutable reference `&mut Option<String>`
found enum `Option<{integer}>`
2019-05-23 17:32:01 +00:00
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0308`.