about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-19 13:22:10 +0000
committerbors <bors@rust-lang.org>2014-12-19 13:22:10 +0000
commitbd90b936d73c0ea2c261cd8e7b9c43764cb2da05 (patch)
tree1e06eeba880be012ebfa11ab64911625c17c972e /src/libsyntax
parent0efafac398ff7f28c5f0fe756c15b9008b3e0534 (diff)
parentebf1e4f23adba8fc2a4441b8c2a7473c3a7c9d65 (diff)
downloadrust-bd90b936d73c0ea2c261cd8e7b9c43764cb2da05.tar.gz
rust-bd90b936d73c0ea2c261cd8e7b9c43764cb2da05.zip
auto merge of #19884 : nikomatsakis/rust/issue-19730-perfect-forwarding, r=pnkfelix
Rewrite how the HRTB algorithm matches impls against obligations. Instead of impls providing higher-ranked trait-references, impls now once again only have early-bound regions. The skolemization checks are thus moved out into trait matching itself. This allows to implement "perfect forwarding" impls like those described in #19730. This PR builds on a previous PR that was already reviewed by @pnkfelix.

r? @pnkfelix 

Fixes #19730 
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/visit.rs19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs
index 95d7906b443..5a1a186c74c 100644
--- a/src/libsyntax/visit.rs
+++ b/src/libsyntax/visit.rs
@@ -105,8 +105,11 @@ pub trait Visitor<'v> {
             None => ()
         }
     }
+    fn visit_lifetime_bound(&mut self, lifetime: &'v Lifetime) {
+        walk_lifetime_bound(self, lifetime)
+    }
     fn visit_lifetime_ref(&mut self, lifetime: &'v Lifetime) {
-        self.visit_name(lifetime.span, lifetime.name)
+        walk_lifetime_ref(self, lifetime)
     }
     fn visit_lifetime_def(&mut self, lifetime: &'v LifetimeDef) {
         walk_lifetime_def(self, lifetime)
@@ -214,10 +217,20 @@ pub fn walk_lifetime_def<'v, V: Visitor<'v>>(visitor: &mut V,
                                               lifetime_def: &'v LifetimeDef) {
     visitor.visit_name(lifetime_def.lifetime.span, lifetime_def.lifetime.name);
     for bound in lifetime_def.bounds.iter() {
-        visitor.visit_lifetime_ref(bound);
+        visitor.visit_lifetime_bound(bound);
     }
 }
 
+pub fn walk_lifetime_bound<'v, V: Visitor<'v>>(visitor: &mut V,
+                                               lifetime_ref: &'v Lifetime) {
+    visitor.visit_lifetime_ref(lifetime_ref)
+}
+
+pub fn walk_lifetime_ref<'v, V: Visitor<'v>>(visitor: &mut V,
+                                             lifetime_ref: &'v Lifetime) {
+    visitor.visit_name(lifetime_ref.span, lifetime_ref.name)
+}
+
 pub fn walk_explicit_self<'v, V: Visitor<'v>>(visitor: &mut V,
                                               explicit_self: &'v ExplicitSelf) {
     match explicit_self.node {
@@ -550,7 +563,7 @@ pub fn walk_ty_param_bound<'v, V: Visitor<'v>>(visitor: &mut V,
             visitor.visit_poly_trait_ref(typ);
         }
         RegionTyParamBound(ref lifetime) => {
-            visitor.visit_lifetime_ref(lifetime);
+            visitor.visit_lifetime_bound(lifetime);
         }
     }
 }