@@ -91,47 +91,50 @@ pub fn main() {
9191 #[ cfg( any( classic2024, structural2024) ) ] let _: u32 = x;
9292 }
9393
94- // Tests for eat-inner rulesets matching on the outer reference if matching on the inner
95- // reference causes a mutability mismatch, i.e. `Deref(EatInner, FallbackToOuter)`:
94+ // Tests for eat-inner and eat-both rulesets matching on the outer reference if matching on the
95+ // inner reference causes a mutability mismatch. i.e. tests for "fallback-to-outer" deref rules.
9696 let [ & mut x] = & mut [ & 0 ] ;
97- //[stable2021,classic2021,structural2021 ]~^ mismatched types
98- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
99- // TODO: on ` structural2021` `x` should have type `u32`
97+ //[stable2021,classic2021]~^ mismatched types
98+ //[stable2021,classic2021]~| types differ in mutability
99+ # [ cfg ( structural2021) ] let _ : u32 = x ;
100100 #[ cfg( any( classic2024, structural2024) ) ] let _: & u32 = x;
101101
102102 let [ & mut ref x] = & mut [ & 0 ] ;
103- //[stable2021,classic2021,structural2021 ]~^ mismatched types
104- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
105- // TODO: on ` structural2021` `x` should have type ` &u32`
103+ //[stable2021,classic2021]~^ mismatched types
104+ //[stable2021,classic2021]~| types differ in mutability
105+ # [ cfg ( structural2021) ] let _ : & u32 = x ;
106106 #[ cfg( any( classic2024, structural2024) ) ] let _: & & u32 = x;
107107
108- let [ & mut ref mut x] = & mut [ & 0 ] ;
109- //[stable2021,classic2021,structural2021]~^ mismatched types
110- //[stable2021,classic2021,structural2021]~| types differ in mutability
111- // TODO: this should be a mut borrow behind shared borrow error on `structural2021`
112- #[ cfg( any( classic2024, structural2024) ) ] let _: & mut & u32 = x;
108+ fn borrowck_error_on_structural2021 ( ) {
109+ let [ & mut ref mut x] = & mut [ & 0 ] ;
110+ //[stable2021,classic2021]~^ mismatched types
111+ //[stable2021,classic2021]~| types differ in mutability
112+ //[structural2021]~^^^ cannot borrow data in a `&` reference as mutable
113+ #[ cfg( any( classic2024, structural2024) ) ] let _: & mut & u32 = x;
114+ }
115+ borrowck_error_on_structural2021 ( ) ;
113116
114117 let [ & mut mut x] = & mut [ & 0 ] ;
115- //[stable2021,classic2021,structural2021 ]~^ mismatched types
116- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
117- // TODO: on ` structural2021` `x` should have type `u32`
118+ //[stable2021,classic2021]~^ mismatched types
119+ //[stable2021,classic2021]~| types differ in mutability
120+ # [ cfg ( structural2021) ] let _ : u32 = x ;
118121 #[ cfg( any( classic2024, structural2024) ) ] let _: & u32 = x;
119122
120123 let [ & mut & x] = & mut [ & 0 ] ;
121124 //[stable2021,classic2021,structural2021]~^ mismatched types
122- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
123- // TODO: [structural2021]~| expected integer, found `&_`
125+ //[stable2021,classic2021]~| types differ in mutability
126+ //[structural2021]~| expected integer, found `&_`
124127 #[ cfg( any( classic2024, structural2024) ) ] let _: u32 = x;
125128
126129 let [ & mut & ref x] = & mut [ & 0 ] ;
127130 //[stable2021,classic2021,structural2021]~^ mismatched types
128- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
129- // TODO: [structural2021]~| expected integer, found `&_`
131+ //[stable2021,classic2021]~| types differ in mutability
132+ //[structural2021]~| expected integer, found `&_`
130133 #[ cfg( any( classic2024, structural2024) ) ] let _: & u32 = x;
131134
132135 let [ & mut & ( mut x) ] = & mut [ & 0 ] ;
133136 //[stable2021,classic2021,structural2021]~^ mismatched types
134- //[stable2021,classic2021,structural2021 ]~| types differ in mutability
135- // TODO: [structural2021]~| expected integer, found `&_`
137+ //[stable2021,classic2021]~| types differ in mutability
138+ //[structural2021]~| expected integer, found `&_`
136139 #[ cfg( any( classic2024, structural2024) ) ] let _: u32 = x;
137140}
0 commit comments