mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-29 18:23:49 +00:00
Don't make "fake" match variables mutable
This commit is contained in:
parent
26e73dabeb
commit
173c33019e
@ -1213,11 +1213,17 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
||||
let locals = if has_guard.0 && tcx.all_pat_vars_are_implicit_refs_within_guards() {
|
||||
let mut vals_for_guard = Vec::with_capacity(num_patterns);
|
||||
for _ in 0..num_patterns {
|
||||
let val_for_guard_idx = self.local_decls.push(local.clone());
|
||||
let val_for_guard_idx = self.local_decls.push(LocalDecl {
|
||||
// This variable isn't mutated but has a name, so has to be
|
||||
// immutable to avoid the unused mut lint.
|
||||
mutability: Mutability::Not,
|
||||
..local.clone()
|
||||
});
|
||||
vals_for_guard.push(val_for_guard_idx);
|
||||
}
|
||||
let ref_for_guard = self.local_decls.push(LocalDecl::<'tcx> {
|
||||
mutability,
|
||||
// See previous comment.
|
||||
mutability: Mutability::Not,
|
||||
ty: tcx.mk_imm_ref(tcx.types.re_empty, var_ty),
|
||||
name: Some(name),
|
||||
source_info,
|
||||
|
@ -55,10 +55,19 @@ fn parse_dot_or_call_expr_with(mut attrs: Vec<u32>) {
|
||||
);
|
||||
}
|
||||
|
||||
// Found when trying to bootstrap rustc
|
||||
fn if_guard(x: Result<i32, i32>) {
|
||||
match x {
|
||||
Ok(mut r) | Err(mut r) if true => r = 1,
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
ref_argument(0);
|
||||
mutable_upvar();
|
||||
generator_mutable_upvar();
|
||||
ref_closure_argument();
|
||||
parse_dot_or_call_expr_with(Vec::new());
|
||||
if_guard(Ok(0));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user