From d8cf9aa6931e33a3bdbe21c41e84a27a03406d1f Mon Sep 17 00:00:00 2001 From: Slanterns Date: Sat, 8 Aug 2020 20:26:56 +0800 Subject: [PATCH] Use `&` instead of `let ref` in E0502 `ref` on an entire `let` pattern is discouraged, take a reference with `&` instead. --- src/librustc_error_codes/error_codes/E0502.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_error_codes/error_codes/E0502.md b/src/librustc_error_codes/error_codes/E0502.md index b90c59f580737..dc3ffdfddd9de 100644 --- a/src/librustc_error_codes/error_codes/E0502.md +++ b/src/librustc_error_codes/error_codes/E0502.md @@ -5,7 +5,7 @@ Erroneous code example: ```compile_fail,E0502 fn bar(x: &mut i32) {} fn foo(a: &mut i32) { - let ref y = a; // a is borrowed as immutable. + let y = &a; // a is borrowed as immutable. bar(a); // error: cannot borrow `*a` as mutable because `a` is also borrowed // as immutable println!("{}", y); @@ -19,7 +19,7 @@ variable before trying to access it mutably: fn bar(x: &mut i32) {} fn foo(a: &mut i32) { bar(a); - let ref y = a; // ok! + let y = &a; // ok! println!("{}", y); } ```