From 604af3f6c0be6ea428a55cfcb303fa1cd1c7958d Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 11 Aug 2014 09:32:26 -0700 Subject: librustc: Implement simple `where` clauses. These `where` clauses are accepted everywhere generics are currently accepted and desugar during type collection to the type parameter bounds we have today. A new keyword, `where`, has been added. Therefore, this is a breaking change. Change uses of `where` to other identifiers. [breaking-change] --- src/libsyntax/ast_map/mod.rs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/libsyntax/ast_map') diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index 78afa8441c5..5fccf6cc3f0 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -431,11 +431,14 @@ impl Map { /// the iterator will produce node id's for items with paths /// such as `foo::bar::quux`, `bar::quux`, `other::bar::quux`, and /// any other such items it can find in the map. - pub fn nodes_matching_suffix<'a, S:Str>(&'a self, parts: &'a [S]) -> NodesMatchingSuffix<'a,S> { - NodesMatchingSuffix { map: self, - item_name: parts.last().unwrap(), - where: parts.slice_to(parts.len() - 1), - idx: 0 } + pub fn nodes_matching_suffix<'a, S:Str>(&'a self, parts: &'a [S]) + -> NodesMatchingSuffix<'a,S> { + NodesMatchingSuffix { + map: self, + item_name: parts.last().unwrap(), + in_which: parts.slice_to(parts.len() - 1), + idx: 0, + } } pub fn opt_span(&self, id: NodeId) -> Option { @@ -478,20 +481,20 @@ impl Map { pub struct NodesMatchingSuffix<'a, S> { map: &'a Map, item_name: &'a S, - where: &'a [S], + in_which: &'a [S], idx: NodeId, } impl<'a,S:Str> NodesMatchingSuffix<'a,S> { /// Returns true only if some suffix of the module path for parent - /// matches `self.where`. + /// matches `self.in_which`. /// - /// In other words: let `[x_0,x_1,...,x_k]` be `self.where`; + /// In other words: let `[x_0,x_1,...,x_k]` be `self.in_which`; /// returns true if parent's path ends with the suffix /// `x_0::x_1::...::x_k`. fn suffix_matches(&self, parent: NodeId) -> bool { let mut cursor = parent; - for part in self.where.iter().rev() { + for part in self.in_which.iter().rev() { let (mod_id, mod_name) = match find_first_mod_parent(self.map, cursor) { None => return false, Some((node_id, name)) => (node_id, name), -- cgit 1.4.1-3-g733a5