summary refs log tree commit diff
path: root/src/libsyntax/ast.rs
diff options
context:
space:
mode:
authorEduard Burtescu <edy.burt@gmail.com>2016-03-29 12:12:01 +0300
committerEduard Burtescu <edy.burt@gmail.com>2016-04-06 09:04:15 +0300
commit7bebe80bc28ff818c7990061275fa0ad6c8b3686 (patch)
tree55cbc78dd15233353b37d8242e5ba6434b20be2e /src/libsyntax/ast.rs
parentef4c7241f82c08848938b8b2dafed01535559ec0 (diff)
downloadrust-7bebe80bc28ff818c7990061275fa0ad6c8b3686.tar.gz
rust-7bebe80bc28ff818c7990061275fa0ad6c8b3686.zip
syntax: dismantle ast_util.
Diffstat (limited to 'src/libsyntax/ast.rs')
-rw-r--r--src/libsyntax/ast.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs
index a441f2990cd..370dd0dad72 100644
--- a/src/libsyntax/ast.rs
+++ b/src/libsyntax/ast.rs
@@ -205,6 +205,23 @@ impl fmt::Display for Path {
     }
 }
 
+impl Path {
+    // convert a span and an identifier to the corresponding
+    // 1-segment path
+    pub fn from_ident(s: Span, identifier: Ident) -> Path {
+        Path {
+            span: s,
+            global: false,
+            segments: vec!(
+                PathSegment {
+                    identifier: identifier,
+                    parameters: PathParameters::none()
+                }
+            ),
+        }
+    }
+}
+
 /// A segment of a path: an identifier, an optional lifetime, and a set of
 /// types.
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug)]