Skip to content

Commit

Permalink
Evaluate place expression in PlaceMention.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Apr 21, 2023
1 parent 84bab31 commit cb3e0fb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions tests/ui/option_if_let_else.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn else_if_option(string: Option<&str>) -> Option<(bool, &str)> {
fn unop_bad(string: &Option<&str>, mut num: Option<i32>) {
let _ = string.map_or(0, |s| s.len());
let _ = num.as_ref().map_or(&0, |s| s);
let _ = num.as_mut().map_or(&mut 0, |s| {
let _ = num.as_mut().map_or(&0, |s| {
*s += 1;
s
});
Expand All @@ -34,7 +34,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option<i32>) {
s += 1;
s
});
let _ = num.as_mut().map_or(&mut 0, |s| {
let _ = num.as_mut().map_or(&0, |s| {
*s += 1;
s
});
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/option_if_let_else.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option<i32>) {
*s += 1;
s
} else {
&mut 0
&0
};
let _ = if let Some(ref s) = num { s } else { &0 };
let _ = if let Some(mut s) = num {
Expand All @@ -46,7 +46,7 @@ fn unop_bad(string: &Option<&str>, mut num: Option<i32>) {
*s += 1;
s
} else {
&mut 0
&0
};
}

Expand Down
8 changes: 4 additions & 4 deletions tests/ui/option_if_let_else.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ LL | let _ = if let Some(s) = &mut num {
LL | | *s += 1;
LL | | s
LL | | } else {
LL | | &mut 0
LL | | &0
LL | | };
| |_____^
|
help: try
|
LL ~ let _ = num.as_mut().map_or(&mut 0, |s| {
LL ~ let _ = num.as_mut().map_or(&0, |s| {
LL + *s += 1;
LL + s
LL ~ });
Expand Down Expand Up @@ -76,13 +76,13 @@ LL | let _ = if let Some(ref mut s) = num {
LL | | *s += 1;
LL | | s
LL | | } else {
LL | | &mut 0
LL | | &0
LL | | };
| |_____^
|
help: try
|
LL ~ let _ = num.as_mut().map_or(&mut 0, |s| {
LL ~ let _ = num.as_mut().map_or(&0, |s| {
LL + *s += 1;
LL + s
LL ~ });
Expand Down

0 comments on commit cb3e0fb

Please sign in to comment.