File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
tests/ui/closures/2229_closure_analysis Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 44//@ check-pass
55#![ allow( unused_assignments) ]
66
7+ // Reading the length as part of a pattern captures the pointee.
78fn f ( ) {
89 let mut x: & mut [ u8 ] = & mut [ 1 , 2 , 3 ] ;
910 let c = || {
@@ -16,6 +17,7 @@ fn f() {
1617 c ( ) ;
1718}
1819
20+ // Plain old deref as part of pattern behaves similarly
1921fn g ( ) {
2022 let mut x: & mut bool = & mut false ;
2123 let mut t = true ;
@@ -29,6 +31,23 @@ fn g() {
2931 c ( ) ;
3032}
3133
34+ // Like f, but the lifetime implications are expressed in terms of
35+ // returning a closure.
36+ fn f2 < ' l : ' s , ' s > ( x : & ' s mut & ' l [ u8 ] ) -> impl Fn ( ) + ' l {
37+ || match * x {
38+ & [ ] => ( ) ,
39+ _ => ( ) ,
40+ }
41+ }
42+
43+ // Related testcase that was already accepted before
44+ fn f3 < ' l : ' s , ' s > ( x : & ' s mut & ' l [ u8 ] ) -> impl Fn ( ) + ' l {
45+ || match * * x {
46+ [ ] => ( ) ,
47+ _ => ( ) ,
48+ }
49+ }
50+
3251fn main ( ) {
3352 f ( ) ;
3453 g ( ) ;
You can’t perform that action at this time.
0 commit comments