mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-13 15:33:53 +00:00
Range PatKind implies discr should be read
This commit is contained in:
parent
eba3228b2a
commit
9829efb892
@ -267,12 +267,15 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PatKind::Lit(_) => {
|
PatKind::Lit(_) | PatKind::Range(..) => {
|
||||||
// If the PatKind is a Lit then we want
|
// If the PatKind is a Lit or a Range then we want
|
||||||
// to borrow discr.
|
// to borrow discr.
|
||||||
needs_to_be_read = true;
|
needs_to_be_read = true;
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {
|
||||||
|
// If the PatKind is Or, Box, Slice or Ref, the decision is made later
|
||||||
|
// as these patterns contains subpatterns
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
14
src/test/ui/closures/2229_closure_analysis/issue-87426.rs
Normal file
14
src/test/ui/closures/2229_closure_analysis/issue-87426.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// run-pass
|
||||||
|
// edition:2021
|
||||||
|
|
||||||
|
pub fn foo() {
|
||||||
|
let ref_x_ck = 123;
|
||||||
|
let _y = || match ref_x_ck {
|
||||||
|
2_000_000..=3_999_999 => { println!("A")}
|
||||||
|
_ => { println!("B")}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
foo();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user