@@ -16,6 +16,20 @@ use ty::{self, Region};
1616use hir:: def_id:: DefId ;
1717use hir:: map as hir_map;
1818
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+
1933impl < ' a , ' gcx , ' tcx > InferCtxt < ' a , ' gcx , ' tcx > {
2034 // This method walks the Type of the function body arguments using
2135 // `fold_regions()` function and returns the
@@ -28,11 +42,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
2842 // i32, which is the type of y but with the anonymous region replaced
2943 // with 'a, the corresponding bound region and is_first which is true if
3044 // 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 > {
3649
3750 if let ty:: ReFree ( ref free_region) = * anon_region {
3851
@@ -57,7 +70,12 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
5770 } ) ;
5871 if found_anon_region {
5972 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+ } )
6179 } else {
6280 None
6381 }
0 commit comments