diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2017-03-08 20:30:06 +0300 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2017-03-10 08:21:45 -0800 |
| commit | 32575a0487a2086ca7b15a0ca2565efc60bdc0c3 (patch) | |
| tree | 3b1694a1dfda636e7809ac8157e6e07e57c253a2 /src/libsyntax/ext | |
| parent | f573db4f80c75f156df8a743f456bf087ec81dc2 (diff) | |
| download | rust-32575a0487a2086ca7b15a0ca2565efc60bdc0c3.tar.gz rust-32575a0487a2086ca7b15a0ca2565efc60bdc0c3.zip | |
Give spans to individual path segments in AST
Diffstat (limited to 'src/libsyntax/ext')
| -rw-r--r-- | src/libsyntax/ext/build.rs | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index f8d4eff80b2..e0fb46ff5eb 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -38,11 +38,11 @@ pub trait AstBuilder { fn qpath(&self, self_type: P<ast::Ty>, trait_path: ast::Path, - ident: ast::Ident) + ident: ast::SpannedIdent) -> (ast::QSelf, ast::Path); fn qpath_all(&self, self_type: P<ast::Ty>, trait_path: ast::Path, - ident: ast::Ident, + ident: ast::SpannedIdent, lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, bindings: Vec<ast::TypeBinding>) @@ -323,7 +323,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { segments.push(ast::PathSegment::crate_root()); } - segments.extend(idents.into_iter().map(Into::into)); + segments.extend(idents.into_iter().map(|i| ast::PathSegment::from_ident(i, sp))); let parameters = if lifetimes.is_empty() && types.is_empty() && bindings.is_empty() { None } else { @@ -333,7 +333,11 @@ impl<'a> AstBuilder for ExtCtxt<'a> { bindings: bindings, }))) }; - segments.push(ast::PathSegment { identifier: last_identifier, parameters: parameters }); + segments.push(ast::PathSegment { + identifier: last_identifier, + span: sp, + parameters: parameters + }); ast::Path { span: sp, segments: segments, @@ -346,7 +350,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn qpath(&self, self_type: P<ast::Ty>, trait_path: ast::Path, - ident: ast::Ident) + ident: ast::SpannedIdent) -> (ast::QSelf, ast::Path) { self.qpath_all(self_type, trait_path, ident, vec![], vec![], vec![]) } @@ -357,7 +361,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { fn qpath_all(&self, self_type: P<ast::Ty>, trait_path: ast::Path, - ident: ast::Ident, + ident: ast::SpannedIdent, lifetimes: Vec<ast::Lifetime>, types: Vec<P<ast::Ty>>, bindings: Vec<ast::TypeBinding>) @@ -369,7 +373,8 @@ impl<'a> AstBuilder for ExtCtxt<'a> { bindings: bindings, }; path.segments.push(ast::PathSegment { - identifier: ident, + identifier: ident.node, + span: ident.span, parameters: Some(P(ast::PathParameters::AngleBracketed(parameters))), }); |
