Skip to content

Commit b1cee11

Browse files
committed
code review fixes
1 parent fe9c68a commit b1cee11

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

src/librustc/infer/error_reporting/anon_anon_conflict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
6565
(self.find_arg_with_anonymous_region(sup, sup),
6666
self.find_arg_with_anonymous_region(sub, sub)) {
6767

68-
let ((anon_arg_sup, _, _, is_first_sup), (anon_arg_sub, _, _, is_first_sub)) =
69-
(sup_arg, sub_arg);
68+
let (anon_arg_sup, is_first_sup, anon_arg_sub, is_first_sub) =
69+
(sup_arg.arg, sup_arg.is_first, sub_arg.arg, sub_arg.is_first);
7070
if self.is_self_anon(is_first_sup, scope_def_id_sup) ||
7171
self.is_self_anon(is_first_sub, scope_def_id_sub) {
7272
return false;

src/librustc/infer/error_reporting/named_anon_conflict.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
3030
// only introduced anonymous regions in parameters) as well as a
3131
// version new_ty of its type where the anonymous region is replaced
3232
// with the named one.
33-
let (named, (arg, new_ty, br, is_first), (scope_def_id, _)) = if
33+
let (named, anon_arg_info, (scope_def_id, _)) = if
3434
sub.is_named_region() && self.is_suitable_anonymous_region(sup, false).is_some() {
3535
(sub,
3636
self.find_arg_with_anonymous_region(sup, sub).unwrap(),
@@ -44,6 +44,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
4444
return false; // inapplicable
4545
};
4646

47+
let (arg, new_ty, br, is_first) = (anon_arg_info.arg,
48+
anon_arg_info.arg_ty,
49+
anon_arg_info.bound_region,
50+
anon_arg_info.is_first);
4751
if self.is_return_type_anon(scope_def_id, br) || self.is_self_anon(is_first, scope_def_id) {
4852
return false;
4953
} else {

src/librustc/infer/error_reporting/util.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@ use ty::{self, Region};
1616
use hir::def_id::DefId;
1717
use 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+
1933
impl<'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

Comments
 (0)