@@ -135,7 +135,7 @@ fn check_closure_captures(#[rust_analyzer::rust_fixture] ra_fixture: &str, expec
135135fn deref_in_let ( ) {
136136 check_closure_captures (
137137 r#"
138- //- minicore:copy
138+ //- minicore:copy, fn
139139fn main() {
140140 let a = &mut true;
141141 let closure = || { let b = *a; };
@@ -149,7 +149,7 @@ fn main() {
149149fn deref_then_ref_pattern ( ) {
150150 check_closure_captures (
151151 r#"
152- //- minicore:copy
152+ //- minicore:copy, fn
153153fn main() {
154154 let a = &mut true;
155155 let closure = || { let &mut ref b = a; };
@@ -159,7 +159,7 @@ fn main() {
159159 ) ;
160160 check_closure_captures (
161161 r#"
162- //- minicore:copy
162+ //- minicore:copy, fn
163163fn main() {
164164 let a = &mut true;
165165 let closure = || { let &mut ref mut b = a; };
@@ -173,7 +173,7 @@ fn main() {
173173fn unique_borrow ( ) {
174174 check_closure_captures (
175175 r#"
176- //- minicore:copy
176+ //- minicore:copy, fn
177177fn main() {
178178 let a = &mut true;
179179 let closure = || { *a = false; };
@@ -187,7 +187,7 @@ fn main() {
187187fn deref_ref_mut ( ) {
188188 check_closure_captures (
189189 r#"
190- //- minicore:copy
190+ //- minicore:copy, fn
191191fn main() {
192192 let a = &mut true;
193193 let closure = || { let ref mut b = *a; };
@@ -201,7 +201,7 @@ fn main() {
201201fn let_else_not_consuming ( ) {
202202 check_closure_captures (
203203 r#"
204- //- minicore:copy
204+ //- minicore:copy, fn
205205fn main() {
206206 let a = &mut true;
207207 let closure = || { let _ = *a else { return; }; };
@@ -215,7 +215,7 @@ fn main() {
215215fn consume ( ) {
216216 check_closure_captures (
217217 r#"
218- //- minicore:copy
218+ //- minicore:copy, fn
219219struct NonCopy;
220220fn main() {
221221 let a = NonCopy;
@@ -230,7 +230,7 @@ fn main() {
230230fn ref_to_upvar ( ) {
231231 check_closure_captures (
232232 r#"
233- //- minicore:copy
233+ //- minicore:copy, fn
234234struct NonCopy;
235235fn main() {
236236 let mut a = NonCopy;
@@ -248,7 +248,7 @@ fn main() {
248248fn field ( ) {
249249 check_closure_captures (
250250 r#"
251- //- minicore:copy
251+ //- minicore:copy, fn
252252struct Foo { a: i32, b: i32 }
253253fn main() {
254254 let a = Foo { a: 0, b: 0 };
@@ -263,7 +263,7 @@ fn main() {
263263fn fields_different_mode ( ) {
264264 check_closure_captures (
265265 r#"
266- //- minicore:copy
266+ //- minicore:copy, fn
267267struct NonCopy;
268268struct Foo { a: i32, b: i32, c: NonCopy, d: bool }
269269fn main() {
@@ -286,7 +286,7 @@ fn main() {
286286fn autoref ( ) {
287287 check_closure_captures (
288288 r#"
289- //- minicore:copy
289+ //- minicore:copy, fn
290290struct Foo;
291291impl Foo {
292292 fn imm(&self) {}
@@ -308,7 +308,7 @@ fn main() {
308308fn captures_priority ( ) {
309309 check_closure_captures (
310310 r#"
311- //- minicore:copy
311+ //- minicore:copy, fn
312312struct NonCopy;
313313fn main() {
314314 let mut a = &mut true;
@@ -336,7 +336,7 @@ fn main() {
336336fn let_underscore ( ) {
337337 check_closure_captures (
338338 r#"
339- //- minicore:copy
339+ //- minicore:copy, fn
340340fn main() {
341341 let mut a = true;
342342 let closure = || { let _ = a; };
@@ -350,7 +350,7 @@ fn main() {
350350fn match_wildcard ( ) {
351351 check_closure_captures (
352352 r#"
353- //- minicore:copy
353+ //- minicore:copy, fn
354354struct NonCopy;
355355fn main() {
356356 let mut a = NonCopy;
@@ -375,7 +375,7 @@ fn main() {
375375fn multiple_bindings ( ) {
376376 check_closure_captures (
377377 r#"
378- //- minicore:copy
378+ //- minicore:copy, fn
379379fn main() {
380380 let mut a = false;
381381 let mut closure = || { let (b | b) = a; };
@@ -389,7 +389,7 @@ fn main() {
389389fn multiple_usages ( ) {
390390 check_closure_captures (
391391 r#"
392- //- minicore:copy
392+ //- minicore:copy, fn
393393fn main() {
394394 let mut a = false;
395395 let mut closure = || {
@@ -410,7 +410,7 @@ fn main() {
410410fn ref_then_deref ( ) {
411411 check_closure_captures (
412412 r#"
413- //- minicore:copy
413+ //- minicore:copy, fn
414414fn main() {
415415 let mut a = false;
416416 let mut closure = || { let b = *&mut a; };
@@ -424,7 +424,7 @@ fn main() {
424424fn ref_of_ref ( ) {
425425 check_closure_captures (
426426 r#"
427- //- minicore:copy
427+ //- minicore:copy, fn
428428fn main() {
429429 let mut a = &false;
430430 let closure = || { let b = &a; };
@@ -446,7 +446,7 @@ fn main() {
446446fn multiple_capture_usages ( ) {
447447 check_closure_captures (
448448 r#"
449- //- minicore:copy
449+ //- minicore:copy, fn
450450struct A { a: i32, b: bool }
451451fn main() {
452452 let mut a = A { a: 123, b: false };
@@ -465,7 +465,7 @@ fn main() {
465465fn let_binding_is_a_ref_capture_in_ref_binding ( ) {
466466 check_closure_captures (
467467 r#"
468- //- minicore:copy
468+ //- minicore:copy, fn
469469struct S;
470470fn main() {
471471 let mut s = S;
@@ -489,7 +489,7 @@ fn main() {
489489fn let_binding_is_a_value_capture_in_binding ( ) {
490490 check_closure_captures (
491491 r#"
492- //- minicore:copy, option
492+ //- minicore:copy, fn, option
493493struct Box(i32);
494494fn main() {
495495 let b = Some(Box(0));
@@ -508,7 +508,7 @@ fn main() {
508508fn alias_needs_to_be_normalized ( ) {
509509 check_closure_captures (
510510 r#"
511- //- minicore:copy
511+ //- minicore:copy, fn
512512trait Trait {
513513 type Associated;
514514}
@@ -528,3 +528,41 @@ fn main() {
528528 expect ! [ "220..257;174..175;245..250 ByRef(Shared) c.b.x &'? i32" ] ,
529529 ) ;
530530}
531+
532+ #[ test]
533+ fn nested_ref_captures_from_outer ( ) {
534+ check_closure_captures (
535+ r#"
536+ //- minicore:copy, fn
537+ fn f() {
538+ let a = 1;
539+ let a_closure = || {
540+ let b_closure = || {
541+ { a };
542+ };
543+ };
544+ }
545+ "# ,
546+ expect ! [ [ r#"
547+ 44..113;17..18;92..93 ByRef(Shared) a &'? i32
548+ 73..106;17..18;92..93 ByRef(Shared) a &'? i32"# ] ] ,
549+ ) ;
550+ }
551+
552+ #[ test]
553+ fn nested_ref_captures ( ) {
554+ check_closure_captures (
555+ r#"
556+ //- minicore:copy, fn
557+ fn f() {
558+ let a_closure = || {
559+ let b = 2;
560+ let b_closure = || {
561+ { b };
562+ };
563+ };
564+ }
565+ "# ,
566+ expect ! [ "77..110;46..47;96..97 ByRef(Shared) b &'? i32" ] ,
567+ ) ;
568+ }
0 commit comments