Skip to content

Commit

Permalink
Fixed nits
Browse files Browse the repository at this point in the history
  • Loading branch information
tnowacki committed Oct 26, 2023
1 parent adc3e97 commit 857ac59
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
8 changes: 3 additions & 5 deletions external-crates/move/move-compiler/src/cfgir/borrows/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,9 @@ impl BorrowState {
assert_eq!(exps.len(), 1);
let infos: &mut BTreeMap<ExpBasedID, RefExpInfo> =
&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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -12,15 +12,15 @@ 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')

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')

Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ 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')

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')

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')

Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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')

Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -12,23 +12,23 @@ 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')

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')

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'
Expand Down

0 comments on commit 857ac59

Please sign in to comment.