]> git.lizzy.rs Git - rust.git/commitdiff
code review fixes
authorgaurikholkar <f2013002@goa.bits-pilani.ac.in>
Thu, 17 Aug 2017 16:45:18 +0000 (22:15 +0530)
committergaurikholkar <f2013002@goa.bits-pilani.ac.in>
Thu, 17 Aug 2017 16:45:18 +0000 (22:15 +0530)
src/librustc/infer/error_reporting/anon_anon_conflict.rs
src/librustc/infer/error_reporting/named_anon_conflict.rs
src/librustc/infer/error_reporting/util.rs

index 3821bf766b960e3339287b9a178d969309cf3182..c5e26f431207a15e50981b16e9c20d51c5cdb1cf 100644 (file)
@@ -65,8 +65,8 @@ pub fn try_report_anon_anon_conflict(&self, error: &RegionResolutionError<'tcx>)
             (self.find_arg_with_anonymous_region(sup, sup),
              self.find_arg_with_anonymous_region(sub, sub)) {
 
-            let ((anon_arg_sup, _, _, is_first_sup), (anon_arg_sub, _, _, is_first_sub)) =
-                (sup_arg, sub_arg);
+            let (anon_arg_sup, is_first_sup, anon_arg_sub, is_first_sub) =
+                (sup_arg.arg, sup_arg.is_first, sub_arg.arg, sub_arg.is_first);
             if self.is_self_anon(is_first_sup, scope_def_id_sup) ||
                self.is_self_anon(is_first_sub, scope_def_id_sub) {
                 return false;
index f46855502ea41849c5930bdfbfe296b9ec2704b9..005eb900c11832ca4a6f97dd827e85c270b02daf 100644 (file)
@@ -30,7 +30,7 @@ pub fn try_report_named_anon_conflict(&self, error: &RegionResolutionError<'tcx>
         // only introduced anonymous regions in parameters) as well as a
         // version new_ty of its type where the anonymous region is replaced
         // with the named one.
-        let (named, (arg, new_ty, br, is_first), (scope_def_id, _)) = if
+        let (named, anon_arg_info, (scope_def_id, _)) = if
             sub.is_named_region() && self.is_suitable_anonymous_region(sup, false).is_some() {
             (sub,
              self.find_arg_with_anonymous_region(sup, sub).unwrap(),
@@ -44,6 +44,10 @@ pub fn try_report_named_anon_conflict(&self, error: &RegionResolutionError<'tcx>
             return false; // inapplicable
         };
 
+        let (arg, new_ty, br, is_first) = (anon_arg_info.arg,
+                                           anon_arg_info.arg_ty,
+                                           anon_arg_info.bound_region,
+                                           anon_arg_info.is_first);
         if self.is_return_type_anon(scope_def_id, br) || self.is_self_anon(is_first, scope_def_id) {
             return false;
         } else {
index 21a6e8e050a13ea624934e2633b794859af7ae7e..902e388ca7bf314784a0651eaa58c43aeae9180f 100644 (file)
 use hir::def_id::DefId;
 use hir::map as hir_map;
 
+// The struct contains the information about the anonymous region
+// we are searching for.
+pub struct AnonymousArgInfo<'tcx> {
+    // the argument corresponding to the anonymous region
+    pub arg: &'tcx hir::Arg,
+    // the type corresponding to the anonymopus region argument
+    pub arg_ty: ty::Ty<'tcx>,
+    // the ty::BoundRegion corresponding to the anonymous region
+    pub bound_region: ty::BoundRegion,
+    // corresponds to id the argument is the first parameter
+    // in the declaration
+    pub is_first: bool,
+}
+
 impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
     // This method walks the Type of the function body arguments using
     // `fold_regions()` function and returns the
@@ -28,11 +42,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
     // i32, which is the type of y but with the anonymous region replaced
     // with 'a, the corresponding bound region and is_first which is true if
     // the hir::Arg is the first argument in the function declaration.
-    pub fn find_arg_with_anonymous_region
-        (&self,
-         anon_region: Region<'tcx>,
-         replace_region: Region<'tcx>)
-         -> Option<(&hir::Arg, ty::Ty<'tcx>, ty::BoundRegion, bool)> {
+    pub fn find_arg_with_anonymous_region(&self,
+                                          anon_region: Region<'tcx>,
+                                          replace_region: Region<'tcx>)
+                                          -> Option<AnonymousArgInfo> {
 
         if let ty::ReFree(ref free_region) = *anon_region {
 
@@ -57,7 +70,12 @@ pub fn find_arg_with_anonymous_region
                                     });
                                 if found_anon_region {
                                     let is_first = index == 0;
-                                    Some((arg, new_arg_ty, free_region.bound_region, is_first))
+                                    Some(AnonymousArgInfo {
+                                             arg: arg,
+                                             arg_ty: new_arg_ty,
+                                             bound_region: free_region.bound_region,
+                                             is_first: is_first,
+                                         })
                                 } else {
                                     None
                                 }