Skip to content

Commit d8cf9aa

Browse files
authored
Use & instead of let ref in E0502
`ref` on an entire `let` pattern is discouraged, take a reference with `&` instead.
1 parent c92fc8d commit d8cf9aa

File tree

1 file changed

+2
-2
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+2
-2
lines changed

src/librustc_error_codes/error_codes/E0502.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Erroneous code example:
55
```compile_fail,E0502
66
fn bar(x: &mut i32) {}
77
fn foo(a: &mut i32) {
8-
let ref y = a; // a is borrowed as immutable.
8+
let y = &a; // a is borrowed as immutable.
99
bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed
1010
// as immutable
1111
println!("{}", y);
@@ -19,7 +19,7 @@ variable before trying to access it mutably:
1919
fn bar(x: &mut i32) {}
2020
fn foo(a: &mut i32) {
2121
bar(a);
22-
let ref y = a; // ok!
22+
let y = &a; // ok!
2323
println!("{}", y);
2424
}
2525
```

0 commit comments

Comments
 (0)