Skip to content

Commit 4ecb4f0

Browse files
author
Ariel Ben-Yehuda
committed
---
yaml --- r: 219679 b: refs/heads/snap-stage3 c: a5e21da h: refs/heads/master i: 219677: 3d7ac97 219675: d39b323 219671: ab6b7b7 219663: cd476ef 219647: 544304f v: v3
1 parent 10ea9d6 commit 4ecb4f0

File tree

4 files changed

+41
-32
lines changed

4 files changed

+41
-32
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: c044791d80ea0dc5c4b57b6030a67b69f8510239
3-
refs/heads/snap-stage3: 336f81215eb166aad4f8759be0cf284f3321212f
3+
refs/heads/snap-stage3: a5e21daa1909f538ddd696f7baffad4603f38a5d
44
refs/heads/try: b53c0f93eedcdedd4fd89bccc5a3a09d1c5cd23e
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596

branches/snap-stage3/src/librustc/middle/traits/fulfill.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,16 +421,18 @@ fn process_predicate<'a,'tcx>(selcx: &mut SelectionContext<'a,'tcx>,
421421
// regions. If there are, we will call this obligation an
422422
// error. Eventually we should be able to support some
423423
// cases here, I imagine (e.g., `for<'a> int : 'a`).
424-
if selcx.tcx().count_late_bound_regions(binder) != 0 {
425-
errors.push(
426-
FulfillmentError::new(
427-
obligation.clone(),
428-
CodeSelectionError(Unimplemented)));
429-
} else {
430-
let ty::OutlivesPredicate(t_a, r_b) = binder.0;
431-
register_region_obligation(t_a, r_b,
432-
obligation.cause.clone(),
433-
region_obligations);
424+
match selcx.tcx().no_late_bound_regions(binder) {
425+
None => {
426+
errors.push(
427+
FulfillmentError::new(
428+
obligation.clone(),
429+
CodeSelectionError(Unimplemented)))
430+
}
431+
Some(ty::OutlivesPredicate(t_a, r_b)) => {
432+
register_region_obligation(t_a, r_b,
433+
obligation.cause.clone(),
434+
region_obligations);
435+
}
434436
}
435437
true
436438
}
@@ -501,5 +503,3 @@ impl<'tcx> FulfilledPredicates<'tcx> {
501503
!self.set.insert(p.clone())
502504
}
503505
}
504-
505-

branches/snap-stage3/src/librustc/middle/ty.rs

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6853,19 +6853,6 @@ impl<'tcx> ctxt<'tcx> {
68536853
|br| ty::ReFree(ty::FreeRegion{scope: all_outlive_scope, bound_region: br})).0
68546854
}
68556855

6856-
pub fn count_late_bound_regions<T>(&self, value: &Binder<T>) -> usize
6857-
where T : TypeFoldable<'tcx>
6858-
{
6859-
let (_, skol_map) = ty_fold::replace_late_bound_regions(self, value, |_| ty::ReStatic);
6860-
skol_map.len()
6861-
}
6862-
6863-
pub fn binds_late_bound_regions<T>(&self, value: &Binder<T>) -> bool
6864-
where T : TypeFoldable<'tcx>
6865-
{
6866-
self.count_late_bound_regions(value) > 0
6867-
}
6868-
68696856
/// Flattens two binding levels into one. So `for<'a> for<'b> Foo`
68706857
/// becomes `for<'a,'b> Foo`.
68716858
pub fn flatten_late_bound_regions<T>(&self, bound2_value: &Binder<Binder<T>>)
@@ -6890,9 +6877,9 @@ impl<'tcx> ctxt<'tcx> {
68906877
}
68916878

68926879
pub fn no_late_bound_regions<T>(&self, value: &Binder<T>) -> Option<T>
6893-
where T : TypeFoldable<'tcx>
6880+
where T : TypeFoldable<'tcx> + RegionEscape
68946881
{
6895-
if self.binds_late_bound_regions(value) {
6882+
if value.0.has_escaping_regions() {
68966883
None
68976884
} else {
68986885
Some(value.0.clone())
@@ -7052,6 +7039,19 @@ impl<'tcx> RegionEscape for Substs<'tcx> {
70527039
}
70537040
}
70547041

7042+
impl<T:RegionEscape> RegionEscape for Vec<T> {
7043+
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7044+
self.iter().any(|t| t.has_regions_escaping_depth(depth))
7045+
}
7046+
}
7047+
7048+
impl<'tcx> RegionEscape for FnSig<'tcx> {
7049+
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7050+
self.inputs.has_regions_escaping_depth(depth) ||
7051+
self.output.has_regions_escaping_depth(depth)
7052+
}
7053+
}
7054+
70557055
impl<'tcx,T:RegionEscape> RegionEscape for VecPerParamSpace<T> {
70567056
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
70577057
self.iter_enumerated().any(|(space, _, t)| {
@@ -7124,6 +7124,15 @@ impl<'tcx,T:RegionEscape> RegionEscape for Binder<T> {
71247124
}
71257125
}
71267126

7127+
impl<'tcx> RegionEscape for FnOutput<'tcx> {
7128+
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
7129+
match *self {
7130+
FnConverging(t) => t.has_regions_escaping_depth(depth),
7131+
FnDiverging => false
7132+
}
7133+
}
7134+
}
7135+
71277136
impl<'tcx> RegionEscape for EquatePredicate<'tcx> {
71287137
fn has_regions_escaping_depth(&self, depth: u32) -> bool {
71297138
self.0.has_regions_escaping_depth(depth) || self.1.has_regions_escaping_depth(depth)

branches/snap-stage3/src/librustc_typeck/astconv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ pub trait AstConv<'tcx> {
125125
item_name: ast::Name)
126126
-> Ty<'tcx>
127127
{
128-
if self.tcx().binds_late_bound_regions(&poly_trait_ref) {
128+
if let Some(trait_ref) = self.tcx().no_late_bound_regions(&poly_trait_ref) {
129+
self.projected_ty(span, trait_ref, item_name)
130+
} else {
131+
// no late-bound regions, we can just ignore the binder
129132
span_err!(self.tcx().sess, span, E0212,
130133
"cannot extract an associated type from a higher-ranked trait bound \
131134
in this context");
132135
self.tcx().types.err
133-
} else {
134-
// no late-bound regions, we can just ignore the binder
135-
self.projected_ty(span, poly_trait_ref.0.clone(), item_name)
136136
}
137137
}
138138

0 commit comments

Comments
 (0)