1
Fork 0

path -> Path

This commit is contained in:
John Clements 2013-03-26 17:00:35 -07:00
parent 5d01f649b4
commit 48e7bda826
21 changed files with 92 additions and 92 deletions

View file

@ -77,7 +77,7 @@ fn inject_libcore_ref(sess: Session,
fold_mod: |module, fld| { fold_mod: |module, fld| {
let n2 = sess.next_node_id(); let n2 = sess.next_node_id();
let prelude_path = @ast::path { let prelude_path = @ast::Path {
span: dummy_sp(), span: dummy_sp(),
global: false, global: false,
idents: ~[ idents: ~[

View file

@ -336,16 +336,16 @@ fn nospan<T:Copy>(t: T) -> codemap::spanned<T> {
codemap::spanned { node: t, span: dummy_sp() } codemap::spanned { node: t, span: dummy_sp() }
} }
fn path_node(+ids: ~[ast::ident]) -> @ast::path { fn path_node(+ids: ~[ast::ident]) -> @ast::Path {
@ast::path { span: dummy_sp(), @ast::Path { span: dummy_sp(),
global: false, global: false,
idents: ids, idents: ids,
rp: None, rp: None,
types: ~[] } types: ~[] }
} }
fn path_node_global(+ids: ~[ast::ident]) -> @ast::path { fn path_node_global(+ids: ~[ast::ident]) -> @ast::Path {
@ast::path { span: dummy_sp(), @ast::Path { span: dummy_sp(),
global: true, global: true,
idents: ids, idents: ids,
rp: None, rp: None,

View file

@ -137,7 +137,7 @@ pub fn parse_arg_data(data: @~[u8], crate_num: int, pos: uint, tcx: ty::ctxt,
parse_arg(st, conv) parse_arg(st, conv)
} }
fn parse_path(st: @mut PState) -> @ast::path { fn parse_path(st: @mut PState) -> @ast::Path {
let mut idents: ~[ast::ident] = ~[]; let mut idents: ~[ast::ident] = ~[];
fn is_last(c: char) -> bool { return c == '(' || c == ':'; } fn is_last(c: char) -> bool { return c == '(' || c == ':'; }
idents.push(parse_ident_(st, is_last)); idents.push(parse_ident_(st, is_last));
@ -146,7 +146,7 @@ fn parse_path(st: @mut PState) -> @ast::path {
':' => { next(st); next(st); } ':' => { next(st); next(st); }
c => { c => {
if c == '(' { if c == '(' {
return @ast::path { span: dummy_sp(), return @ast::Path { span: dummy_sp(),
global: false, global: false,
idents: idents, idents: idents,
rp: None, rp: None,

View file

@ -72,7 +72,7 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool {
} }
pub fn pat_bindings(dm: resolve::DefMap, pat: @pat, pub fn pat_bindings(dm: resolve::DefMap, pat: @pat,
it: &fn(binding_mode, node_id, span, @path)) { it: &fn(binding_mode, node_id, span, @Path)) {
do walk_pat(pat) |p| { do walk_pat(pat) |p| {
match p.node { match p.node {
pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => { pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => {

View file

@ -26,7 +26,7 @@ use syntax::ast::{decl_item, def, def_fn, def_id, def_static_method};
use syntax::ast::{def_variant, expr_field, expr_method_call, expr_path}; use syntax::ast::{def_variant, expr_field, expr_method_call, expr_path};
use syntax::ast::{expr_struct, expr_unary, ident, inherited, item_enum}; use syntax::ast::{expr_struct, expr_unary, ident, inherited, item_enum};
use syntax::ast::{item_foreign_mod, item_fn, item_impl, item_struct}; use syntax::ast::{item_foreign_mod, item_fn, item_impl, item_struct};
use syntax::ast::{item_trait, local_crate, node_id, pat_struct, path}; use syntax::ast::{item_trait, local_crate, node_id, pat_struct, Path};
use syntax::ast::{private, provided, public, required, stmt_decl, visibility}; use syntax::ast::{private, provided, public, required, stmt_decl, visibility};
use syntax::ast; use syntax::ast;
use syntax::ast_map::{node_foreign_item, node_item, node_method}; use syntax::ast_map::{node_foreign_item, node_item, node_method};
@ -276,7 +276,7 @@ pub fn check_crate(tcx: ty::ctxt,
}; };
// Checks that a private path is in scope. // Checks that a private path is in scope.
let check_path: @fn(span: span, def: def, path: @path) = let check_path: @fn(span: span, def: def, path: @Path) =
|span, def, path| { |span, def, path| {
debug!("checking path"); debug!("checking path");
match def { match def {

View file

@ -48,7 +48,7 @@ use syntax::ast::{item_const, item_enum, item_fn, item_foreign_mod};
use syntax::ast::{item_impl, item_mac, item_mod, item_trait, item_ty, le}; use syntax::ast::{item_impl, item_mac, item_mod, item_trait, item_ty, le};
use syntax::ast::{local, local_crate, lt, method, mode, mul}; use syntax::ast::{local, local_crate, lt, method, mode, mul};
use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident}; use syntax::ast::{named_field, ne, neg, node_id, pat, pat_enum, pat_ident};
use syntax::ast::{path, pat_lit, pat_range, pat_struct}; use syntax::ast::{Path, pat_lit, pat_range, pat_struct};
use syntax::ast::{prim_ty, private, provided}; use syntax::ast::{prim_ty, private, provided};
use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl}; use syntax::ast::{public, required, rem, self_ty_, shl, shr, stmt_decl};
use syntax::ast::{struct_dtor, struct_field, struct_variant_kind}; use syntax::ast::{struct_dtor, struct_field, struct_variant_kind};
@ -4368,7 +4368,7 @@ pub impl Resolver {
/// If `check_ribs` is true, checks the local definitions first; i.e. /// If `check_ribs` is true, checks the local definitions first; i.e.
/// doesn't skip straight to the containing module. /// doesn't skip straight to the containing module.
fn resolve_path(@mut self, fn resolve_path(@mut self,
path: @path, path: @Path,
namespace: Namespace, namespace: Namespace,
check_ribs: bool, check_ribs: bool,
visitor: ResolveVisitor) visitor: ResolveVisitor)
@ -4493,7 +4493,7 @@ pub impl Resolver {
return NoNameDefinition; return NoNameDefinition;
} }
fn intern_module_part_of_path(@mut self, path: @path) -> ~[ident] { fn intern_module_part_of_path(@mut self, path: @Path) -> ~[ident] {
let mut module_path_idents = ~[]; let mut module_path_idents = ~[];
for path.idents.eachi |index, ident| { for path.idents.eachi |index, ident| {
if index == path.idents.len() - 1 { if index == path.idents.len() - 1 {
@ -4507,7 +4507,7 @@ pub impl Resolver {
} }
fn resolve_module_relative_path(@mut self, fn resolve_module_relative_path(@mut self,
path: @path, path: @Path,
+xray: XrayFlag, +xray: XrayFlag,
namespace: Namespace) namespace: Namespace)
-> Option<def> { -> Option<def> {
@ -4553,7 +4553,7 @@ pub impl Resolver {
/// Invariant: This must be called only during main resolution, not during /// Invariant: This must be called only during main resolution, not during
/// import resolution. /// import resolution.
fn resolve_crate_relative_path(@mut self, fn resolve_crate_relative_path(@mut self,
path: @path, path: @Path,
+xray: XrayFlag, +xray: XrayFlag,
namespace: Namespace) namespace: Namespace)
-> Option<def> { -> Option<def> {

View file

@ -136,7 +136,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + Durable>(
def_id: ast::def_id, def_id: ast::def_id,
decl_generics: &ty::Generics, decl_generics: &ty::Generics,
self_ty: Option<ty::t>, self_ty: Option<ty::t>,
path: @ast::path) -> ty::substs path: @ast::Path) -> ty::substs
{ {
/*! /*!
* *
@ -188,7 +188,7 @@ pub fn ast_path_to_substs_and_ty<AC:AstConv,RS:region_scope + Copy + Durable>(
self: &AC, self: &AC,
rscope: &RS, rscope: &RS,
did: ast::def_id, did: ast::def_id,
path: @ast::path) -> ty_param_substs_and_ty path: @ast::Path) -> ty_param_substs_and_ty
{ {
let tcx = self.tcx(); let tcx = self.tcx();
let ty::ty_param_bounds_and_ty { let ty::ty_param_bounds_and_ty {
@ -206,7 +206,7 @@ pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Copy + Durable>(
rscope: &RS, rscope: &RS,
trait_def_id: ast::def_id, trait_def_id: ast::def_id,
self_ty: Option<ty::t>, self_ty: Option<ty::t>,
path: @ast::path) -> @ty::TraitRef path: @ast::Path) -> @ty::TraitRef
{ {
let trait_def = let trait_def =
self.get_trait_def(trait_def_id); self.get_trait_def(trait_def_id);
@ -229,7 +229,7 @@ pub fn ast_path_to_ty<AC:AstConv,RS:region_scope + Copy + Durable>(
self: &AC, self: &AC,
rscope: &RS, rscope: &RS,
did: ast::def_id, did: ast::def_id,
path: @ast::path) path: @ast::Path)
-> ty_param_substs_and_ty -> ty_param_substs_and_ty
{ {
// Look up the polytype of the item and then substitute the provided types // Look up the polytype of the item and then substitute the provided types
@ -318,7 +318,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + Durable>(
} }
fn check_path_args(tcx: ty::ctxt, fn check_path_args(tcx: ty::ctxt,
path: @ast::path, path: @ast::Path,
flags: uint) { flags: uint) {
if (flags & NO_TPS) != 0u { if (flags & NO_TPS) != 0u {
if path.types.len() > 0u { if path.types.len() > 0u {

View file

@ -99,7 +99,7 @@ pub struct pat_ctxt {
block_region: ty::Region, // Region for the block of the arm block_region: ty::Region, // Region for the block of the arm
} }
pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path, pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::Path,
subpats: &Option<~[@ast::pat]>, expected: ty::t) { subpats: &Option<~[@ast::pat]>, expected: ty::t) {
// Typecheck the path. // Typecheck the path.
@ -234,7 +234,7 @@ pub fn check_pat_variant(pcx: pat_ctxt, pat: @ast::pat, path: @ast::path,
/// `etc` is true if the pattern said '...' and false otherwise. /// `etc` is true if the pattern said '...' and false otherwise.
pub fn check_struct_pat_fields(pcx: pat_ctxt, pub fn check_struct_pat_fields(pcx: pat_ctxt,
span: span, span: span,
path: @ast::path, path: @ast::Path,
fields: &[ast::field_pat], fields: &[ast::field_pat],
class_fields: ~[ty::field_ty], class_fields: ~[ty::field_ty],
class_id: ast::def_id, class_id: ast::def_id,
@ -285,7 +285,7 @@ pub fn check_struct_pat_fields(pcx: pat_ctxt,
} }
pub fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span, pub fn check_struct_pat(pcx: pat_ctxt, pat_id: ast::node_id, span: span,
expected: ty::t, path: @ast::path, expected: ty::t, path: @ast::Path,
fields: &[ast::field_pat], etc: bool, fields: &[ast::field_pat], etc: bool,
class_id: ast::def_id, substitutions: &ty::substs) { class_id: ast::def_id, substitutions: &ty::substs) {
let fcx = pcx.fcx; let fcx = pcx.fcx;
@ -326,7 +326,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: pat_ctxt,
pat_id: ast::node_id, pat_id: ast::node_id,
span: span, span: span,
expected: ty::t, expected: ty::t,
path: @ast::path, path: @ast::Path,
fields: &[ast::field_pat], fields: &[ast::field_pat],
etc: bool, etc: bool,
enum_id: ast::def_id, enum_id: ast::def_id,

View file

@ -3211,7 +3211,7 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
// Instantiates the given path, which must refer to an item with the given // Instantiates the given path, which must refer to an item with the given
// number of type parameters and type. // number of type parameters and type.
pub fn instantiate_path(fcx: @mut FnCtxt, pub fn instantiate_path(fcx: @mut FnCtxt,
pth: @ast::path, pth: @ast::Path,
tpt: ty_param_bounds_and_ty, tpt: ty_param_bounds_and_ty,
span: span, span: span,
node_id: ast::node_id, node_id: ast::node_id,

View file

@ -113,7 +113,7 @@ pub struct Lifetime {
#[auto_encode] #[auto_encode]
#[auto_decode] #[auto_decode]
#[deriving(Eq)] #[deriving(Eq)]
pub struct path { pub struct Path {
span: span, span: span,
global: bool, global: bool,
idents: ~[ident], idents: ~[ident],
@ -301,10 +301,10 @@ pub enum pat_ {
// which it is. The resolver determines this, and // which it is. The resolver determines this, and
// records this pattern's node_id in an auxiliary // records this pattern's node_id in an auxiliary
// set (of "pat_idents that refer to nullary enums") // set (of "pat_idents that refer to nullary enums")
pat_ident(binding_mode, @path, Option<@pat>), pat_ident(binding_mode, @Path, Option<@pat>),
pat_enum(@path, Option<~[@pat]>), /* "none" means a * pattern where pat_enum(@Path, Option<~[@pat]>), /* "none" means a * pattern where
* we don't bind the fields to names */ * we don't bind the fields to names */
pat_struct(@path, ~[field_pat], bool), pat_struct(@Path, ~[field_pat], bool),
pat_tup(~[@pat]), pat_tup(~[@pat]),
pat_box(@pat), pat_box(@pat),
pat_uniq(@pat), pat_uniq(@pat),
@ -567,7 +567,7 @@ pub enum expr_ {
expr_assign_op(binop, @expr, @expr), expr_assign_op(binop, @expr, @expr),
expr_field(@expr, ident, ~[@Ty]), expr_field(@expr, ident, ~[@Ty]),
expr_index(@expr, @expr), expr_index(@expr, @expr),
expr_path(@path), expr_path(@Path),
expr_addr_of(mutability, @expr), expr_addr_of(mutability, @expr),
expr_break(Option<ident>), expr_break(Option<ident>),
expr_again(Option<ident>), expr_again(Option<ident>),
@ -579,7 +579,7 @@ pub enum expr_ {
expr_mac(mac), expr_mac(mac),
// A struct literal expression. // A struct literal expression.
expr_struct(@path, ~[field], Option<@expr>), expr_struct(@Path, ~[field], Option<@expr>),
// A vector literal constructed from one repeated element. // A vector literal constructed from one repeated element.
expr_repeat(@expr /* element */, @expr /* count */, mutability), expr_repeat(@expr /* element */, @expr /* count */, mutability),
@ -697,7 +697,7 @@ pub type mac = spanned<mac_>;
#[auto_decode] #[auto_decode]
#[deriving(Eq)] #[deriving(Eq)]
pub enum mac_ { pub enum mac_ {
mac_invoc_tt(@path,~[token_tree]), // new macro-invocation mac_invoc_tt(@Path,~[token_tree]), // new macro-invocation
} }
pub type lit = spanned<lit_>; pub type lit = spanned<lit_>;
@ -894,7 +894,7 @@ pub enum ty_ {
ty_closure(@TyClosure), ty_closure(@TyClosure),
ty_bare_fn(@TyBareFn), ty_bare_fn(@TyBareFn),
ty_tup(~[@Ty]), ty_tup(~[@Ty]),
ty_path(@path, node_id), ty_path(@Path, node_id),
ty_mac(mac), ty_mac(mac),
// ty_infer means the type should be inferred instead of it having been // ty_infer means the type should be inferred instead of it having been
// specified. This should only appear at the "top level" of a type and not // specified. This should only appear at the "top level" of a type and not
@ -1118,13 +1118,13 @@ pub enum view_path_ {
// or just // or just
// //
// foo::bar::baz (with 'baz =' implicitly on the left) // foo::bar::baz (with 'baz =' implicitly on the left)
view_path_simple(ident, @path, namespace, node_id), view_path_simple(ident, @Path, namespace, node_id),
// foo::bar::* // foo::bar::*
view_path_glob(@path, node_id), view_path_glob(@Path, node_id),
// foo::bar::{a,b,c} // foo::bar::{a,b,c}
view_path_list(@path, ~[path_list_ident], node_id) view_path_list(@Path, ~[path_list_ident], node_id)
} }
#[auto_encode] #[auto_encode]
@ -1177,7 +1177,7 @@ pub struct attribute_ {
#[auto_decode] #[auto_decode]
#[deriving(Eq)] #[deriving(Eq)]
pub struct trait_ref { pub struct trait_ref {
path: @path, path: @Path,
ref_id: node_id, ref_id: node_id,
} }

View file

@ -30,7 +30,7 @@ pub fn path_name_i(idents: &[ident], intr: @token::ident_interner) -> ~str {
} }
pub fn path_to_ident(p: @path) -> ident { copy *p.idents.last() } pub fn path_to_ident(p: @Path) -> ident { copy *p.idents.last() }
pub fn local_def(id: node_id) -> def_id { pub fn local_def(id: node_id) -> def_id {
ast::def_id { crate: local_crate, node: id } ast::def_id { crate: local_crate, node: id }
@ -223,8 +223,8 @@ pub fn default_block(
} }
} }
pub fn ident_to_path(s: span, +i: ident) -> @path { pub fn ident_to_path(s: span, +i: ident) -> @Path {
@ast::path { span: s, @ast::Path { span: s,
global: false, global: false,
idents: ~[i], idents: ~[i],
rp: None, rp: None,

View file

@ -224,7 +224,7 @@ priv impl @ext_ctxt {
&self, &self,
_span: span, _span: span,
ident: ast::ident, ident: ast::ident,
path: @ast::path, path: @ast::Path,
bounds: @OptVec<ast::TyParamBound> bounds: @OptVec<ast::TyParamBound>
) -> ast::TyParam { ) -> ast::TyParam {
let bound = ast::TraitTyParamBound(@ast::trait_ref { let bound = ast::TraitTyParamBound(@ast::trait_ref {
@ -248,8 +248,8 @@ priv impl @ext_ctxt {
} }
} }
fn path(&self, span: span, +strs: ~[ast::ident]) -> @ast::path { fn path(&self, span: span, +strs: ~[ast::ident]) -> @ast::Path {
@ast::path { @ast::Path {
span: span, span: span,
global: false, global: false,
idents: strs, idents: strs,
@ -258,8 +258,8 @@ priv impl @ext_ctxt {
} }
} }
fn path_global(&self, span: span, +strs: ~[ast::ident]) -> @ast::path { fn path_global(&self, span: span, +strs: ~[ast::ident]) -> @ast::Path {
@ast::path { @ast::Path {
span: span, span: span,
global: true, global: true,
idents: strs, idents: strs,
@ -273,8 +273,8 @@ priv impl @ext_ctxt {
span: span, span: span,
+strs: ~[ast::ident], +strs: ~[ast::ident],
+tps: ~[@ast::Ty] +tps: ~[@ast::Ty]
) -> @ast::path { ) -> @ast::Path {
@ast::path { @ast::Path {
span: span, span: span,
global: false, global: false,
idents: strs, idents: strs,
@ -288,8 +288,8 @@ priv impl @ext_ctxt {
span: span, span: span,
+strs: ~[ast::ident], +strs: ~[ast::ident],
+tps: ~[@ast::Ty] +tps: ~[@ast::Ty]
) -> @ast::path { ) -> @ast::Path {
@ast::path { @ast::Path {
span: span, span: span,
global: true, global: true,
idents: strs, idents: strs,
@ -439,7 +439,7 @@ fn mk_impl(
span: span, span: span,
ident: ast::ident, ident: ast::ident,
ty_param: ast::TyParam, ty_param: ast::TyParam,
path: @ast::path, path: @ast::Path,
generics: &ast::Generics, generics: &ast::Generics,
f: &fn(@ast::Ty) -> @ast::method f: &fn(@ast::Ty) -> @ast::method
) -> @ast::item { ) -> @ast::item {

View file

@ -63,8 +63,8 @@ pub fn mk_unary(cx: @ext_ctxt, sp: span, op: ast::unop, e: @ast::expr)
cx.next_id(); // see ast_util::op_expr_callee_id cx.next_id(); // see ast_util::op_expr_callee_id
mk_expr(cx, sp, ast::expr_unary(op, e)) mk_expr(cx, sp, ast::expr_unary(op, e))
} }
pub fn mk_raw_path(sp: span, +idents: ~[ast::ident]) -> @ast::path { pub fn mk_raw_path(sp: span, +idents: ~[ast::ident]) -> @ast::Path {
let p = @ast::path { span: sp, let p = @ast::Path { span: sp,
global: false, global: false,
idents: idents, idents: idents,
rp: None, rp: None,
@ -74,15 +74,15 @@ pub fn mk_raw_path(sp: span, +idents: ~[ast::ident]) -> @ast::path {
pub fn mk_raw_path_(sp: span, pub fn mk_raw_path_(sp: span,
+idents: ~[ast::ident], +idents: ~[ast::ident],
+types: ~[@ast::Ty]) +types: ~[@ast::Ty])
-> @ast::path { -> @ast::Path {
@ast::path { span: sp, @ast::Path { span: sp,
global: false, global: false,
idents: idents, idents: idents,
rp: None, rp: None,
types: types } types: types }
} }
pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::path { pub fn mk_raw_path_global(sp: span, +idents: ~[ast::ident]) -> @ast::Path {
@ast::path { span: sp, @ast::Path { span: sp,
global: true, global: true,
idents: idents, idents: idents,
rp: None, rp: None,
@ -295,7 +295,7 @@ pub fn mk_pat_ident_with_binding_mode(cx: @ext_ctxt,
} }
pub fn mk_pat_enum(cx: @ext_ctxt, pub fn mk_pat_enum(cx: @ext_ctxt,
span: span, span: span,
path: @ast::path, path: @ast::Path,
+subpats: ~[@ast::pat]) +subpats: ~[@ast::pat])
-> @ast::pat { -> @ast::pat {
let pat = ast::pat_enum(path, Some(subpats)); let pat = ast::pat_enum(path, Some(subpats));
@ -303,7 +303,7 @@ pub fn mk_pat_enum(cx: @ext_ctxt,
} }
pub fn mk_pat_struct(cx: @ext_ctxt, pub fn mk_pat_struct(cx: @ext_ctxt,
span: span, span: span,
path: @ast::path, path: @ast::Path,
+field_pats: ~[ast::field_pat]) +field_pats: ~[ast::field_pat])
-> @ast::pat { -> @ast::pat {
let pat = ast::pat_struct(path, field_pats, false); let pat = ast::pat_struct(path, field_pats, false);

View file

@ -41,7 +41,7 @@ pub fn expand_syntax_ext(cx: @ext_ctxt, sp: span, tts: &[ast::token_tree])
id: cx.next_id(), id: cx.next_id(),
callee_id: cx.next_id(), callee_id: cx.next_id(),
node: ast::expr_path( node: ast::expr_path(
@ast::path { @ast::Path {
span: sp, span: sp,
global: false, global: false,
idents: ~[res], idents: ~[res],

View file

@ -185,7 +185,7 @@ pub fn create_derived_impl(cx: @ext_ctxt,
}); });
// Create the reference to the trait. // Create the reference to the trait.
let trait_path = ast::path { let trait_path = ast::Path {
span: span, span: span,
global: true, global: true,
idents: trait_path.map(|x| *x), idents: trait_path.map(|x| *x),

View file

@ -34,16 +34,16 @@ mod syntax {
pub use parse; pub use parse;
} }
pub fn path(+ids: ~[ident], span: span) -> @ast::path { pub fn path(+ids: ~[ident], span: span) -> @ast::Path {
@ast::path { span: span, @ast::Path { span: span,
global: false, global: false,
idents: ids, idents: ids,
rp: None, rp: None,
types: ~[] } types: ~[] }
} }
pub fn path_global(+ids: ~[ident], span: span) -> @ast::path { pub fn path_global(+ids: ~[ident], span: span) -> @ast::Path {
@ast::path { span: span, @ast::Path { span: span,
global: true, global: true,
idents: ids, idents: ids,
rp: None, rp: None,
@ -51,20 +51,20 @@ pub fn path_global(+ids: ~[ident], span: span) -> @ast::path {
} }
pub trait append_types { pub trait append_types {
fn add_ty(&self, ty: @ast::Ty) -> @ast::path; fn add_ty(&self, ty: @ast::Ty) -> @ast::Path;
fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::path; fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::Path;
} }
impl append_types for @ast::path { impl append_types for @ast::Path {
fn add_ty(&self, ty: @ast::Ty) -> @ast::path { fn add_ty(&self, ty: @ast::Ty) -> @ast::Path {
@ast::path { @ast::Path {
types: vec::append_one(copy self.types, ty), types: vec::append_one(copy self.types, ty),
.. copy **self .. copy **self
} }
} }
fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::path { fn add_tys(&self, +tys: ~[@ast::Ty]) -> @ast::Path {
@ast::path { @ast::Path {
types: vec::append(copy self.types, tys), types: vec::append(copy self.types, tys),
.. copy **self .. copy **self
} }
@ -108,7 +108,7 @@ pub trait ext_ctxt_ast_builder {
span: span, span: span,
+struct_def: ast::struct_def) -> @ast::item; +struct_def: ast::struct_def) -> @ast::item;
fn struct_expr(&self, fn struct_expr(&self,
path: @ast::path, path: @ast::Path,
+fields: ~[ast::field]) -> @ast::expr; +fields: ~[ast::field]) -> @ast::expr;
fn variant(&self, fn variant(&self,
name: ident, name: ident,
@ -118,7 +118,7 @@ pub trait ext_ctxt_ast_builder {
name: ident, name: ident,
span: span, span: span,
+items: ~[@ast::item]) -> @ast::item; +items: ~[@ast::item]) -> @ast::item;
fn ty_path_ast_builder(&self, path: @ast::path) -> @ast::Ty; fn ty_path_ast_builder(&self, path: @ast::Path) -> @ast::Ty;
fn item_ty_poly(&self, fn item_ty_poly(&self,
name: ident, name: ident,
span: span, span: span,
@ -328,7 +328,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
self.item(name, span, ast::item_struct(@struct_def, generics)) self.item(name, span, ast::item_struct(@struct_def, generics))
} }
fn struct_expr(&self, path: @ast::path, fn struct_expr(&self, path: @ast::Path,
+fields: ~[ast::field]) -> @ast::expr { +fields: ~[ast::field]) -> @ast::expr {
@ast::expr { @ast::expr {
id: self.next_id(), id: self.next_id(),
@ -397,7 +397,7 @@ impl ext_ctxt_ast_builder for @ext_ctxt {
) )
} }
fn ty_path_ast_builder(&self, path: @ast::path) -> @ast::Ty { fn ty_path_ast_builder(&self, path: @ast::Path) -> @ast::Ty {
@ast::Ty { @ast::Ty {
id: self.next_id(), id: self.next_id(),
node: ast::ty_path(path, self.next_id()), node: ast::ty_path(path, self.next_id()),

View file

@ -36,7 +36,7 @@ pub trait ast_fold {
fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod; fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod;
fn fold_variant(@self, &variant) -> variant; fn fold_variant(@self, &variant) -> variant;
fn fold_ident(@self, ident) -> ident; fn fold_ident(@self, ident) -> ident;
fn fold_path(@self, @path) -> @path; fn fold_path(@self, @Path) -> @Path;
fn fold_local(@self, @local) -> @local; fn fold_local(@self, @local) -> @local;
fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr]; fn map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr];
fn new_id(@self, node_id) -> node_id; fn new_id(@self, node_id) -> node_id;
@ -65,7 +65,7 @@ pub struct AstFoldFns {
fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod, fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod,
fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span), fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span),
fold_ident: @fn(ident, @ast_fold) -> ident, fold_ident: @fn(ident, @ast_fold) -> ident,
fold_path: @fn(@path, @ast_fold) -> path, fold_path: @fn(@Path, @ast_fold) -> Path,
fold_local: @fn(&local_, span, @ast_fold) -> (local_, span), fold_local: @fn(&local_, span, @ast_fold) -> (local_, span),
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr], map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
new_id: @fn(node_id) -> node_id, new_id: @fn(node_id) -> node_id,
@ -702,8 +702,8 @@ fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident {
/* FIXME (#2543) */ copy i /* FIXME (#2543) */ copy i
} }
fn noop_fold_path(p: @path, fld: @ast_fold) -> path { fn noop_fold_path(p: @Path, fld: @ast_fold) -> Path {
ast::path { ast::Path {
span: fld.new_span(p.span), span: fld.new_span(p.span),
global: p.global, global: p.global,
idents: p.idents.map(|x| fld.fold_ident(*x)), idents: p.idents.map(|x| fld.fold_ident(*x)),
@ -851,7 +851,7 @@ impl ast_fold for AstFoldFns {
fn fold_ident(@self, x: ident) -> ident { fn fold_ident(@self, x: ident) -> ident {
(self.fold_ident)(x, self as @ast_fold) (self.fold_ident)(x, self as @ast_fold)
} }
fn fold_path(@self, x: @path) -> @path { fn fold_path(@self, x: @Path) -> @Path {
@(self.fold_path)(x, self as @ast_fold) @(self.fold_path)(x, self as @ast_fold)
} }
fn fold_local(@self, x: @local) -> @local { fn fold_local(@self, x: @local) -> @local {

View file

@ -897,7 +897,7 @@ pub impl Parser {
// parse a path that doesn't have type parameters attached // parse a path that doesn't have type parameters attached
fn parse_path_without_tps(&self) fn parse_path_without_tps(&self)
-> @ast::path { -> @ast::Path {
maybe_whole!(self, nt_path); maybe_whole!(self, nt_path);
let lo = self.span.lo; let lo = self.span.lo;
let global = self.eat(&token::MOD_SEP); let global = self.eat(&token::MOD_SEP);
@ -917,7 +917,7 @@ pub impl Parser {
break; break;
} }
} }
@ast::path { span: mk_sp(lo, self.last_span.hi), @ast::Path { span: mk_sp(lo, self.last_span.hi),
global: global, global: global,
idents: ids, idents: ids,
rp: None, rp: None,
@ -927,7 +927,7 @@ pub impl Parser {
// parse a path optionally with type parameters. If 'colons' // parse a path optionally with type parameters. If 'colons'
// is true, then type parameters must be preceded by colons, // is true, then type parameters must be preceded by colons,
// as in a::t::<t1,t2> // as in a::t::<t1,t2>
fn parse_path_with_tps(&self, colons: bool) -> @ast::path { fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
debug!("parse_path_with_tps(colons=%b)", colons); debug!("parse_path_with_tps(colons=%b)", colons);
maybe_whole!(self, nt_path); maybe_whole!(self, nt_path);
@ -982,7 +982,7 @@ pub impl Parser {
} }
}; };
@ast::path { span: mk_sp(lo, hi), @ast::Path { span: mk_sp(lo, hi),
rp: rp, rp: rp,
types: tps, types: tps,
.. copy *path } .. copy *path }
@ -4215,7 +4215,7 @@ pub impl Parser {
let id = self.parse_ident(); let id = self.parse_ident();
path.push(id); path.push(id);
} }
let path = @ast::path { span: mk_sp(lo, self.span.hi), let path = @ast::Path { span: mk_sp(lo, self.span.hi),
global: false, global: false,
idents: path, idents: path,
rp: None, rp: None,
@ -4244,7 +4244,7 @@ pub impl Parser {
seq_sep_trailing_allowed(token::COMMA), seq_sep_trailing_allowed(token::COMMA),
|p| p.parse_path_list_ident() |p| p.parse_path_list_ident()
); );
let path = @ast::path { span: mk_sp(lo, self.span.hi), let path = @ast::Path { span: mk_sp(lo, self.span.hi),
global: false, global: false,
idents: path, idents: path,
rp: None, rp: None,
@ -4256,7 +4256,7 @@ pub impl Parser {
// foo::bar::* // foo::bar::*
token::BINOP(token::STAR) => { token::BINOP(token::STAR) => {
self.bump(); self.bump();
let path = @ast::path { span: mk_sp(lo, self.span.hi), let path = @ast::Path { span: mk_sp(lo, self.span.hi),
global: false, global: false,
idents: path, idents: path,
rp: None, rp: None,
@ -4272,7 +4272,7 @@ pub impl Parser {
_ => () _ => ()
} }
let last = path[vec::len(path) - 1u]; let last = path[vec::len(path) - 1u];
let path = @ast::path { span: mk_sp(lo, self.span.hi), let path = @ast::Path { span: mk_sp(lo, self.span.hi),
global: false, global: false,
idents: path, idents: path,
rp: None, rp: None,

View file

@ -113,7 +113,7 @@ pub enum nonterminal {
nt_expr(@ast::expr), nt_expr(@ast::expr),
nt_ty( @ast::Ty), nt_ty( @ast::Ty),
nt_ident(ast::ident, bool), nt_ident(ast::ident, bool),
nt_path(@ast::path), nt_path(@ast::Path),
nt_tt( @ast::token_tree), //needs @ed to break a circularity nt_tt( @ast::token_tree), //needs @ed to break a circularity
nt_matchers(~[ast::matcher]) nt_matchers(~[ast::matcher])
} }

View file

@ -178,7 +178,7 @@ pub fn generics_to_str(generics: &ast::Generics,
to_str(generics, print_generics, intr) to_str(generics, print_generics, intr)
} }
pub fn path_to_str(&&p: @ast::path, intr: @ident_interner) -> ~str { pub fn path_to_str(&&p: @ast::Path, intr: @ident_interner) -> ~str {
to_str(p, |a,b| print_path(a, b, false), intr) to_str(p, |a,b| print_path(a, b, false), intr)
} }
@ -1486,7 +1486,7 @@ pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) {
print_expr(s, coll); print_expr(s, coll);
} }
pub fn print_path(s: @ps, &&path: @ast::path, colons_before_params: bool) { pub fn print_path(s: @ps, &&path: @ast::Path, colons_before_params: bool) {
maybe_print_comment(s, path.span.lo); maybe_print_comment(s, path.span.lo);
if path.global { word(s.s, ~"::"); } if path.global { word(s.s, ~"::"); }
let mut first = true; let mut first = true;

View file

@ -265,7 +265,7 @@ pub fn visit_ty<E>(t: @Ty, e: E, v: vt<E>) {
} }
} }
pub fn visit_path<E>(p: @path, e: E, v: vt<E>) { pub fn visit_path<E>(p: @Path, e: E, v: vt<E>) {
for p.types.each |tp| { (v.visit_ty)(*tp, e, v); } for p.types.each |tp| { (v.visit_ty)(*tp, e, v); }
} }