diff --git a/external-crates/move/move-compiler/src/cfgir/borrows/mod.rs b/external-crates/move/move-compiler/src/cfgir/borrows/mod.rs index fa9f20fd6acdd..e5483d41515d4 100644 --- a/external-crates/move/move-compiler/src/cfgir/borrows/mod.rs +++ b/external-crates/move/move-compiler/src/cfgir/borrows/mod.rs @@ -127,7 +127,7 @@ fn unused_mut_borrows(compilation_env: &mut CompilationEnv, mutably_used: RefExp } = info; if *is_mut && !*used_mutably { let msg = "Mutable reference is never used mutably, \ - consider switching to an imutable reference '&' instead"; + consider switching to an immutable reference '&' instead"; let mut diag = diag!(UnusedItem::MutReference, (*loc, msg)); let display_param = param_name .as_ref() diff --git a/external-crates/move/move-compiler/src/cfgir/borrows/state.rs b/external-crates/move/move-compiler/src/cfgir/borrows/state.rs index 271561f6180d7..7cbe183f877c0 100644 --- a/external-crates/move/move-compiler/src/cfgir/borrows/state.rs +++ b/external-crates/move/move-compiler/src/cfgir/borrows/state.rs @@ -219,11 +219,9 @@ impl BorrowState { assert_eq!(exps.len(), 1); let infos: &mut BTreeMap = &mut RefCell::borrow_mut(&self.mutably_used); - for e in exps { - let info = infos.get_mut(e).unwrap(); - assert!(info.param_name.is_none()); - info.param_name = Some(name) - } + let info = infos.get_mut(exps.first().unwrap()).unwrap(); + assert!(info.param_name.is_none()); + info.param_name = Some(name) } fn mark_mutably_used(&mut self, id: RefID) { diff --git a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_branches.unused.exp b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_branches.unused.exp index 423ea16a3d780..dfa964a9bc8f2 100644 --- a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_branches.unused.exp +++ b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_branches.unused.exp @@ -2,7 +2,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_branches.move:3:43 │ 3 │ public fun both_unused(cond: bool, x: &mut u64) { - │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ │ │ For parameters, this can be silenced by prefixing the name with an underscore, e.g. '_x' │ @@ -12,7 +12,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_branches.move:5:31 │ 5 │ if (cond) copy x else &mut i; - │ ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -20,7 +20,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_branches.move:11:31 │ 11 │ if (cond) copy x else &mut i; - │ ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_field_invalid.unused.exp b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_field_invalid.unused.exp index a1317281578b1..b9f57922e41a1 100644 --- a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_field_invalid.unused.exp +++ b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_field_invalid.unused.exp @@ -2,7 +2,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_field_invalid.move:9:23 │ 9 │ let param_f = &mut param.f; - │ ^^^^^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -10,7 +10,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_field_invalid.move:10:19 │ 10 │ let r_f = &mut r.f; - │ ^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -18,7 +18,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_field_invalid.move:11:9 │ 11 │ &mut S { f: 0 }.f; - │ ^^^^^^^^^^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^^^^^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_immutable_usage.unused.exp b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_immutable_usage.unused.exp index 7c0c2d60f6f16..222fc1dc9f7b8 100644 --- a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_immutable_usage.unused.exp +++ b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_immutable_usage.unused.exp @@ -2,7 +2,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_immutable_usage.move:5:25 │ 5 │ public fun param(x: &mut S): &S { - │ - ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ - ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ │ │ For parameters, this can be silenced by prefixing the name with an underscore, e.g. '_x' │ @@ -12,7 +12,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_immutable_usage.move:17:17 │ 17 │ let x = &mut s; - │ ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') diff --git a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_simple_invalid.unused.exp b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_simple_invalid.unused.exp index 50ad4606e7512..54ec56381c297 100644 --- a/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_simple_invalid.unused.exp +++ b/external-crates/move/move-compiler/tests/move_check/borrows/unused_mut_ref_simple_invalid.unused.exp @@ -2,7 +2,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_simple_invalid.move:3:26 │ 3 │ public fun unused(x: &mut u64) { - │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ │ │ For parameters, this can be silenced by prefixing the name with an underscore, e.g. '_x' │ @@ -12,7 +12,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_simple_invalid.move:5:17 │ 5 │ let r = &mut i; - │ ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -20,7 +20,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_simple_invalid.move:7:9 │ 7 │ &mut 0; - │ ^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ ^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ = This warning can be suppressed with '#[allow(unused_mut_ref)]' applied to the 'module' or module member ('const', 'fun', or 'struct') @@ -28,7 +28,7 @@ warning[W09013]: unused mutable reference '&mut' ┌─ tests/move_check/borrows/unused_mut_ref_simple_invalid.move:13:23 │ 13 │ public fun ret(x: &mut u64): &u64 { - │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an imutable reference '&' instead + │ - ^^^^^^^^ Mutable reference is never used mutably, consider switching to an immutable reference '&' instead │ │ │ For parameters, this can be silenced by prefixing the name with an underscore, e.g. '_x' │