Always reborrow reference receiver in methods

This commit is contained in:
hkalbasi 2023-04-07 00:32:28 +03:30
parent ea22d245b6
commit 7ba93cb8cf
3 changed files with 39 additions and 2 deletions

View file

@ -315,6 +315,8 @@ fn main() {
(&Struct).consume();
//^^^^^^^*
(&Struct).by_ref();
//^^^^^^^&
//^^^^^^^*
(&mut Struct).consume();
//^^^^^^^^^^^*
@ -322,6 +324,8 @@ fn main() {
//^^^^^^^^^^^&
//^^^^^^^^^^^*
(&mut Struct).by_ref_mut();
//^^^^^^^^^^^&mut $
//^^^^^^^^^^^*
// Check that block-like expressions don't duplicate hints
let _: &mut [u32] = (&mut []);
@ -414,6 +418,10 @@ fn main() {
//^^^^^^^)
//^^^^^^^.*
(&Struct).by_ref();
//^^^^^^^(
//^^^^^^^)
//^^^^^^^.*
//^^^^^^^.&
(&mut Struct).consume();
//^^^^^^^^^^^(
@ -425,6 +433,10 @@ fn main() {
//^^^^^^^^^^^.*
//^^^^^^^^^^^.&
(&mut Struct).by_ref_mut();
//^^^^^^^^^^^(
//^^^^^^^^^^^)
//^^^^^^^^^^^.*
//^^^^^^^^^^^.&mut
// Check that block-like expressions don't duplicate hints
let _: &mut [u32] = (&mut []);