@@ -16,6 +16,20 @@ use ty::{self, Region};
16
16
use hir:: def_id:: DefId ;
17
17
use hir:: map as hir_map;
18
18
19
+ // The struct contains the information about the anonymous region
20
+ // we are searching for.
21
+ pub struct AnonymousArgInfo < ' tcx > {
22
+ // the argument corresponding to the anonymous region
23
+ pub arg : & ' tcx hir:: Arg ,
24
+ // the type corresponding to the anonymopus region argument
25
+ pub arg_ty : ty:: Ty < ' tcx > ,
26
+ // the ty::BoundRegion corresponding to the anonymous region
27
+ pub bound_region : ty:: BoundRegion ,
28
+ // corresponds to id the argument is the first parameter
29
+ // in the declaration
30
+ pub is_first : bool ,
31
+ }
32
+
19
33
impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
20
34
// This method walks the Type of the function body arguments using
21
35
// `fold_regions()` function and returns the
@@ -28,11 +42,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
28
42
// i32, which is the type of y but with the anonymous region replaced
29
43
// with 'a, the corresponding bound region and is_first which is true if
30
44
// the hir::Arg is the first argument in the function declaration.
31
- pub fn find_arg_with_anonymous_region
32
- ( & self ,
33
- anon_region : Region < ' tcx > ,
34
- replace_region : Region < ' tcx > )
35
- -> Option < ( & hir:: Arg , ty:: Ty < ' tcx > , ty:: BoundRegion , bool ) > {
45
+ pub fn find_arg_with_anonymous_region ( & self ,
46
+ anon_region : Region < ' tcx > ,
47
+ replace_region : Region < ' tcx > )
48
+ -> Option < AnonymousArgInfo > {
36
49
37
50
if let ty:: ReFree ( ref free_region) = * anon_region {
38
51
@@ -57,7 +70,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
57
70
} ) ;
58
71
if found_anon_region {
59
72
let is_first = index == 0 ;
60
- Some ( ( arg, new_arg_ty, free_region. bound_region , is_first) )
73
+ Some ( AnonymousArgInfo {
74
+ arg : arg,
75
+ arg_ty : new_arg_ty,
76
+ bound_region : free_region. bound_region ,
77
+ is_first : is_first,
78
+ } )
61
79
} else {
62
80
None
63
81
}
0 commit comments