De-managed ast::Path

This commit is contained in:
James Miller 2013-07-05 22:15:21 +12:00 committed by James Miller
parent a69eb95233
commit cd1b6c8979
32 changed files with 206 additions and 198 deletions

View file

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

View file

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

View file

@ -1014,7 +1014,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
encode_name(ecx, ebml_w, item.ident);
encode_attributes(ebml_w, item.attrs);
match ty.node {
ast::ty_path(path, bounds, _) if path.idents.len() == 1 => {
ast::ty_path(ref path, bounds, _) if path.idents.len() == 1 => {
assert!(bounds.is_none());
encode_impl_type_basename(ecx, ebml_w,
ast_util::path_to_ident(path));

View file

@ -112,7 +112,7 @@ pub fn check_expr(sess: Session,
"` in a constant expression");
}
}
expr_path(pth) => {
expr_path(ref pth) => {
// NB: In the future you might wish to relax this slightly
// to handle on-demand instantiation of functions via
// foo::<bar> in a const. Currently that is only done on

View file

@ -71,10 +71,10 @@ pub fn pat_is_binding_or_wild(dm: resolve::DefMap, pat: @pat) -> bool {
}
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)) {
for walk_pat(pat) |p| {
match p.node {
pat_ident(binding_mode, pth, _) if pat_is_binding(dm, p) => {
pat_ident(binding_mode, ref pth, _) if pat_is_binding(dm, p) => {
it(binding_mode, p.id, p.span, pth);
}
_ => {}

View file

@ -276,7 +276,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
};
// 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| {
debug!("checking path");
match def {
@ -449,7 +449,7 @@ pub fn check_crate<'mm>(tcx: ty::ctxt,
_ => {}
}
}
expr_path(path) => {
expr_path(ref path) => {
check_path(expr.span, tcx.def_map.get_copy(&expr.id), path);
}
expr_struct(_, ref fields, _) => {

View file

@ -784,7 +784,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
// then check whether it is region-parameterized and consider
// that as a direct dependency.
match ty.node {
ast::ty_path(path, _bounds, id) => {
ast::ty_path(ref path, _bounds, id) => {
match cx.def_map.find(&id) {
Some(&ast::def_ty(did)) |
Some(&ast::def_trait(did)) |
@ -820,7 +820,7 @@ fn determine_rp_in_ty(ty: @ast::Ty,
visit_mt(mt, (cx, visitor));
}
ast::ty_path(path, _bounds, _) => {
ast::ty_path(ref path, _bounds, _) => {
// type parameters are---for now, anyway---always invariant
do cx.with_ambient_variance(rv_invariant) {
for path.types.iter().advance |tp| {

View file

@ -1245,7 +1245,7 @@ impl Resolver {
// Create the module and add all methods.
match *ty {
Ty {
node: ty_path(path, _, _),
node: ty_path(ref path, _, _),
_
} if path.idents.len() == 1 => {
let name = path_to_ident(path);
@ -1446,7 +1446,7 @@ impl Resolver {
let mut module_path = ~[];
match view_path.node {
view_path_simple(_, full_path, _) => {
view_path_simple(_, ref full_path, _) => {
let path_len = full_path.idents.len();
assert!(path_len != 0);
@ -1457,8 +1457,8 @@ impl Resolver {
}
}
view_path_glob(module_ident_path, _) |
view_path_list(module_ident_path, _, _) => {
view_path_glob(ref module_ident_path, _) |
view_path_list(ref module_ident_path, _, _) => {
for module_ident_path.idents.iter().advance |ident| {
module_path.push(*ident);
}
@ -1468,7 +1468,7 @@ impl Resolver {
// Build up the import directives.
let module_ = self.get_module_from_parent(parent);
match view_path.node {
view_path_simple(binding, full_path, id) => {
view_path_simple(binding, ref full_path, id) => {
let source_ident = *full_path.idents.last();
let subclass = @SingleImport(binding,
source_ident);
@ -3561,7 +3561,7 @@ impl Resolver {
// Resolve derived traits.
for traits.iter().advance |trt| {
self.resolve_trait_reference(*trt, visitor, TraitDerivation);
self.resolve_trait_reference(trt, visitor, TraitDerivation);
}
for (*methods).iter().advance |method| {
@ -4117,7 +4117,7 @@ impl Resolver {
// Like path expressions, the interpretation of path types depends
// on whether the path has multiple elements in it or not.
ty_path(path, bounds, path_id) => {
ty_path(ref path, bounds, path_id) => {
// This is a path in the type namespace. Walk through scopes
// scopes looking for it.
let mut result_def = None;
@ -4211,7 +4211,7 @@ impl Resolver {
let pat_id = pattern.id;
for walk_pat(pattern) |pattern| {
match pattern.node {
pat_ident(binding_mode, path, _)
pat_ident(binding_mode, ref path, _)
if !path.global && path.idents.len() == 1 => {
// The meaning of pat_ident with no type parameters
@ -4338,7 +4338,7 @@ impl Resolver {
}
}
pat_ident(binding_mode, path, _) => {
pat_ident(binding_mode, ref path, _) => {
// This must be an enum variant, struct, or constant.
match self.resolve_path(path, ValueNS, false, visitor) {
Some(def @ def_variant(*)) |
@ -4371,7 +4371,7 @@ impl Resolver {
}
}
pat_enum(path, _) => {
pat_enum(ref path, _) => {
// This must be an enum variant, struct or const.
match self.resolve_path(path, ValueNS, false, visitor) {
Some(def @ def_fn(*)) |
@ -4409,7 +4409,7 @@ impl Resolver {
self.resolve_expr(last_expr, visitor);
}
pat_struct(path, _, _) => {
pat_struct(ref path, _, _) => {
match self.resolve_path(path, TypeNS, false, visitor) {
Some(def_ty(class_id))
if self.structs.contains(&class_id) => {
@ -4484,7 +4484,7 @@ impl Resolver {
/// If `check_ribs` is true, checks the local definitions first; i.e.
/// doesn't skip straight to the containing module.
pub fn resolve_path(@mut self,
path: @Path,
path: &Path,
namespace: Namespace,
check_ribs: bool,
visitor: ResolveVisitor)
@ -4610,7 +4610,7 @@ impl Resolver {
return NoNameDefinition;
}
pub fn intern_module_part_of_path(@mut self, path: @Path) -> ~[ident] {
pub fn intern_module_part_of_path(@mut self, path: &Path) -> ~[ident] {
let mut module_path_idents = ~[];
for path.idents.iter().enumerate().advance |(index, ident)| {
if index == path.idents.len() - 1 {
@ -4624,7 +4624,7 @@ impl Resolver {
}
pub fn resolve_module_relative_path(@mut self,
path: @Path,
path: &Path,
xray: XrayFlag,
namespace: Namespace)
-> Option<def> {
@ -4690,7 +4690,7 @@ impl Resolver {
/// Invariant: This must be called only during main resolution, not during
/// import resolution.
pub fn resolve_crate_relative_path(@mut self,
path: @Path,
path: &Path,
xray: XrayFlag,
namespace: Namespace)
-> Option<def> {
@ -4916,7 +4916,7 @@ impl Resolver {
// The interpretation of paths depends on whether the path has
// multiple elements in it or not.
expr_path(path) => {
expr_path(ref path) => {
// This is a local path in the value namespace. Walk through
// scopes looking for it.
@ -4985,7 +4985,7 @@ impl Resolver {
visitor);
}
expr_struct(path, _, _) => {
expr_struct(ref path, _, _) => {
// Resolve the path to the structure it goes to.
match self.resolve_path(path, TypeNS, false, visitor) {
Some(def_ty(class_id)) | Some(def_struct(class_id))

View file

@ -385,7 +385,7 @@ pub fn expand_nested_bindings<'r>(bcx: block,
do m.map |br| {
match br.pats[col].node {
ast::pat_ident(_, path, Some(inner)) => {
ast::pat_ident(_, ref path, Some(inner)) => {
let pats = vec::append(
br.pats.slice(0u, col).to_owned(),
vec::append(~[inner],
@ -441,7 +441,7 @@ pub fn enter_match<'r>(bcx: block,
let this = br.pats[col];
match this.node {
ast::pat_ident(_, path, None) => {
ast::pat_ident(_, ref path, None) => {
if pat_is_binding(dm, this) {
let binding_info =
br.data.bindings_map.get(

View file

@ -1399,7 +1399,7 @@ pub fn alloc_local(cx: block, local: &ast::local) -> block {
let _icx = push_ctxt("alloc_local");
let t = node_id_type(cx, local.node.id);
let simple_name = match local.node.pat.node {
ast::pat_ident(_, pth, None) => Some(path_to_ident(pth)),
ast::pat_ident(_, ref pth, None) => Some(path_to_ident(pth)),
_ => None
};
let val = alloc_ty(cx, t);

View file

@ -525,7 +525,7 @@ fn const_expr_unadjusted(cx: @mut CrateContext, e: &ast::expr) -> ValueRef {
_ => cx.sess.span_bug(e.span, "bad const-slice expr")
}
}
ast::expr_path(pth) => {
ast::expr_path(ref pth) => {
assert_eq!(pth.types.len(), 0);
let tcx = cx.tcx;
match tcx.def_map.find(&e.id) {

View file

@ -133,7 +133,7 @@ pub fn create_local_var(bcx: block, local: @ast::local) -> DIVariable {
let cx = bcx.ccx();
let ident = match local.node.pat.node {
ast::pat_ident(_, pth, _) => ast_util::path_to_ident(pth),
ast::pat_ident(_, ref pth, _) => ast_util::path_to_ident(pth),
// FIXME this should be handled (#2533)
_ => {
bcx.sess().span_note(local.span, "debuginfo for pattern bindings NYI");
@ -204,7 +204,7 @@ pub fn create_arg(bcx: block, arg: ast::arg, span: span) -> Option<DIVariable> {
let context = create_function(fcx);
match arg.pat.node {
ast::pat_ident(_, path, _) => {
ast::pat_ident(_, ref path, _) => {
// XXX: This is wrong; it should work for multiple bindings.
let ident = path.idents.last();
let name: &str = cx.sess.str_of(*ident);

View file

@ -136,7 +136,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Copy + 'static>(
def_id: ast::def_id,
decl_generics: &ty::Generics,
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 + 'static>(
this: &AC,
rscope: &RS,
did: ast::def_id,
path: @ast::Path) -> ty_param_substs_and_ty
path: &ast::Path) -> ty_param_substs_and_ty
{
let tcx = this.tcx();
let ty::ty_param_bounds_and_ty {
@ -206,7 +206,7 @@ pub fn ast_path_to_trait_ref<AC:AstConv,RS:region_scope + Copy + 'static>(
rscope: &RS,
trait_def_id: ast::def_id,
self_ty: Option<ty::t>,
path: @ast::Path) -> @ty::TraitRef
path: &ast::Path) -> @ty::TraitRef
{
let trait_def =
this.get_trait_def(trait_def_id);
@ -228,7 +228,7 @@ pub fn ast_path_to_ty<AC:AstConv,RS:region_scope + Copy + 'static>(
this: &AC,
rscope: &RS,
did: ast::def_id,
path: @ast::Path)
path: &ast::Path)
-> ty_param_substs_and_ty
{
// Look up the polytype of the item and then substitute the provided types
@ -276,7 +276,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
}
return ty::mk_evec(tcx, mt, vst);
}
ast::ty_path(path, bounds, id) => {
ast::ty_path(ref path, bounds, id) => {
// Note that the "bounds must be empty if path is not a trait"
// restriction is enforced in the below case for ty_path, which
// will run after this as long as the path isn't a trait.
@ -321,7 +321,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
}
fn check_path_args(tcx: ty::ctxt,
path: @ast::Path,
path: &ast::Path,
flags: uint) {
if (flags & NO_TPS) != 0u {
if path.types.len() > 0u {
@ -405,7 +405,7 @@ pub fn ast_ty_to_ty<AC:AstConv, RS:region_scope + Copy + 'static>(
ast_ty.span);
ty::mk_closure(tcx, fn_decl)
}
ast::ty_path(path, bounds, id) => {
ast::ty_path(ref path, bounds, id) => {
let a_def = match tcx.def_map.find(&id) {
None => tcx.sess.span_fatal(
ast_ty.span, fmt!("unbound path %s",

View file

@ -105,7 +105,7 @@ pub struct pat_ctxt {
map: PatIdMap,
}
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) {
// Typecheck the path.
@ -271,7 +271,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.
pub fn check_struct_pat_fields(pcx: &pat_ctxt,
span: span,
path: @ast::Path,
path: &ast::Path,
fields: &[ast::field_pat],
class_fields: ~[ty::field_ty],
class_id: ast::def_id,
@ -322,7 +322,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,
expected: ty::t, path: @ast::Path,
expected: ty::t, path: &ast::Path,
fields: &[ast::field_pat], etc: bool,
class_id: ast::def_id, substitutions: &ty::substs) {
let fcx = pcx.fcx;
@ -356,7 +356,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
pat_id: ast::node_id,
span: span,
expected: ty::t,
path: @ast::Path,
path: &ast::Path,
fields: &[ast::field_pat],
etc: bool,
enum_id: ast::def_id,
@ -440,7 +440,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
demand::suptype(fcx, pat.span, expected, const_tpt.ty);
fcx.write_ty(pat.id, const_tpt.ty);
}
ast::pat_ident(bm, name, sub) if pat_is_binding(tcx.def_map, pat) => {
ast::pat_ident(bm, ref name, sub) if pat_is_binding(tcx.def_map, pat) => {
let typ = fcx.local_ty(pat.span, pat.id);
match bm {
@ -476,13 +476,13 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
_ => ()
}
}
ast::pat_ident(_, path, _) => {
ast::pat_ident(_, ref path, _) => {
check_pat_variant(pcx, pat, path, &Some(~[]), expected);
}
ast::pat_enum(path, ref subpats) => {
ast::pat_enum(ref path, ref subpats) => {
check_pat_variant(pcx, pat, path, subpats, expected);
}
ast::pat_struct(path, ref fields, etc) => {
ast::pat_struct(ref path, ref fields, etc) => {
// Grab the class data that we care about.
let structure = structure_of(fcx, pat.span, expected);
let mut error_happened = false;

View file

@ -489,7 +489,7 @@ pub fn check_fn(ccx: @mut CrateCtxt,
// Add pattern bindings.
let visit_pat: @fn(@ast::pat, ((), visit::vt<()>)) = |p, (e, v)| {
match p.node {
ast::pat_ident(_, path, _)
ast::pat_ident(_, ref path, _)
if pat_util::pat_is_binding(fcx.ccx.tcx.def_map, p) => {
assign(p.id, None);
debug!("Pattern binding %s is assigned to %s",
@ -2437,7 +2437,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
};
fcx.write_ty(id, oprnd_t);
}
ast::expr_path(pth) => {
ast::expr_path(ref pth) => {
let defn = lookup_def(fcx, pth.span, id);
let tpt = ty_param_bounds_and_ty_for_def(fcx, expr.span, defn);
@ -2775,7 +2775,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
fcx.write_ty(id, typ);
}
}
ast::expr_struct(path, ref fields, base_expr) => {
ast::expr_struct(ref path, ref fields, base_expr) => {
// Resolve the path.
match tcx.def_map.find(&id) {
Some(&ast::def_struct(type_def_id)) => {
@ -3286,7 +3286,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
// number of type parameters and type.
pub fn instantiate_path(fcx: @mut FnCtxt,
pth: @ast::Path,
pth: &ast::Path,
tpt: ty_param_bounds_and_ty,
span: span,
node_id: ast::node_id) {

View file

@ -671,7 +671,7 @@ pub fn check_methods_against_trait(ccx: &CrateCtxt,
impl_m.span,
fmt!("method `%s` is not a member of trait `%s`",
tcx.sess.str_of(impl_m.mty.ident),
path_to_str(a_trait_ty.path, tcx.sess.intr())));
path_to_str(&a_trait_ty.path, tcx.sess.intr())));
}
}
}
@ -966,7 +966,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt,
ast::def_trait(trait_did) => {
let trait_ref =
astconv::ast_path_to_trait_ref(
ccx, &rscope, trait_did, Some(self_ty), ast_trait_ref.path);
ccx, &rscope, trait_did, Some(self_ty), &ast_trait_ref.path);
ccx.tcx.trait_refs.insert(
ast_trait_ref.ref_id, trait_ref);
return trait_ref;
@ -975,7 +975,7 @@ pub fn instantiate_trait_ref(ccx: &CrateCtxt,
ccx.tcx.sess.span_fatal(
ast_trait_ref.path.span,
fmt!("%s is not a trait",
path_to_str(ast_trait_ref.path,
path_to_str(&ast_trait_ref.path,
ccx.tcx.sess.intr())));
}
}

View file

@ -255,10 +255,10 @@ pub enum pat_ {
// which it is. The resolver determines this, and
// records this pattern's node_id in an auxiliary
// set (of "pat_idents that refer to nullary enums")
pat_ident(binding_mode, @Path, Option<@pat>),
pat_enum(@Path, Option<~[@pat]>), /* "none" means a * pattern where
pat_ident(binding_mode, Path, Option<@pat>),
pat_enum(Path, Option<~[@pat]>), /* "none" means a * pattern where
* we don't bind the fields to names */
pat_struct(@Path, ~[field_pat], bool),
pat_struct(Path, ~[field_pat], bool),
pat_tup(~[@pat]),
pat_box(@pat),
pat_uniq(@pat),
@ -456,7 +456,7 @@ pub enum expr_ {
expr_assign_op(node_id, binop, @expr, @expr),
expr_field(@expr, ident, ~[@Ty]),
expr_index(node_id, @expr, @expr),
expr_path(@Path),
expr_path(Path),
/// The special identifier `self`.
expr_self,
@ -471,7 +471,7 @@ pub enum expr_ {
expr_mac(mac),
// A struct literal expression.
expr_struct(@Path, ~[field], Option<@expr>),
expr_struct(Path, ~[field], Option<@expr>),
// A vector literal constructed from one repeated element.
expr_repeat(@expr /* element */, @expr /* count */, mutability),
@ -583,7 +583,7 @@ pub type mac = spanned<mac_>;
#[deriving(Eq, Encodable, Decodable,IterBytes)]
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_>;
@ -734,7 +734,7 @@ pub enum ty_ {
ty_closure(@TyClosure),
ty_bare_fn(@TyBareFn),
ty_tup(~[@Ty]),
ty_path(@Path, @Option<OptVec<TyParamBound>>, node_id), // for #7264; see above
ty_path(Path, @Option<OptVec<TyParamBound>>, node_id), // for #7264; see above
ty_mac(mac),
// 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
@ -890,13 +890,13 @@ pub enum view_path_ {
// or just
//
// foo::bar::baz (with 'baz =' implicitly on the left)
view_path_simple(ident, @Path, node_id),
view_path_simple(ident, Path, node_id),
// foo::bar::*
view_path_glob(@Path, node_id),
view_path_glob(Path, node_id),
// foo::bar::{a,b,c}
view_path_list(@Path, ~[path_list_ident], node_id)
view_path_list(Path, ~[path_list_ident], node_id)
}
#[deriving(Eq, Encodable, Decodable,IterBytes)]
@ -939,7 +939,7 @@ pub struct attribute_ {
*/
#[deriving(Eq, Encodable, Decodable,IterBytes)]
pub struct trait_ref {
path: @Path,
path: Path,
ref_id: node_id,
}

View file

@ -196,7 +196,7 @@ pub fn map_block(b: &blk, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
pub fn map_pat(pat: @pat, (cx,v): (@mut Ctx, visit::vt<@mut Ctx>)) {
match pat.node {
pat_ident(_, path, _) => {
pat_ident(_, ref path, _) => {
// Note: this is at least *potentially* a pattern...
cx.map.insert(pat.id, node_local(ast_util::path_to_ident(path)));
}

View file

@ -27,7 +27,7 @@ pub fn path_name_i(idents: &[ident]) -> ~str {
idents.map(|i| token::interner_get(i.name)).connect("::")
}
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 {
ast::def_id { crate: local_crate, node: id }
@ -212,8 +212,8 @@ pub fn default_block(
}
}
pub fn ident_to_path(s: span, i: ident) -> @Path {
@ast::Path { span: s,
pub fn ident_to_path(s: span, i: ident) -> Path {
ast::Path { span: s,
global: false,
idents: ~[i],
rp: None,

View file

@ -326,7 +326,7 @@ pub fn expr_to_ident(cx: @ExtCtxt,
expr: @ast::expr,
err_msg: &str) -> ast::ident {
match expr.node {
ast::expr_path(p) => {
ast::expr_path(ref p) => {
if p.types.len() > 0u || p.idents.len() != 1u {
cx.span_fatal(expr.span, err_msg);
}

View file

@ -32,21 +32,21 @@ mod syntax {
pub trait AstBuilder {
// paths
fn path(&self, span: span, strs: ~[ast::ident]) -> @ast::Path;
fn path_ident(&self, span: span, id: ast::ident) -> @ast::Path;
fn path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::Path;
fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path;
fn path_ident(&self, span: span, id: ast::ident) -> ast::Path;
fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path;
fn path_all(&self, sp: span,
global: bool,
idents: ~[ast::ident],
rp: Option<@ast::Lifetime>,
types: ~[@ast::Ty])
-> @ast::Path;
-> ast::Path;
// types
fn ty_mt(&self, ty: @ast::Ty, mutbl: ast::mutability) -> ast::mt;
fn ty(&self, span: span, ty: ast::ty_) -> @ast::Ty;
fn ty_path(&self, @ast::Path, @Option<OptVec<ast::TyParamBound>>) -> @ast::Ty;
fn ty_path(&self, ast::Path, @Option<OptVec<ast::TyParamBound>>) -> @ast::Ty;
fn ty_ident(&self, span: span, idents: ast::ident) -> @ast::Ty;
fn ty_rptr(&self, span: span,
@ -68,8 +68,8 @@ pub trait AstBuilder {
fn typaram(&self, id: ast::ident, bounds: @OptVec<ast::TyParamBound>) -> ast::TyParam;
fn trait_ref(&self, path: @ast::Path) -> @ast::trait_ref;
fn typarambound(&self, path: @ast::Path) -> ast::TyParamBound;
fn trait_ref(&self, path: ast::Path) -> @ast::trait_ref;
fn typarambound(&self, path: ast::Path) -> ast::TyParamBound;
fn lifetime(&self, span: span, ident: ast::ident) -> ast::Lifetime;
// statements
@ -86,7 +86,7 @@ pub trait AstBuilder {
// expressions
fn expr(&self, span: span, node: ast::expr_) -> @ast::expr;
fn expr_path(&self, path: @ast::Path) -> @ast::expr;
fn expr_path(&self, path: ast::Path) -> @ast::expr;
fn expr_ident(&self, span: span, id: ast::ident) -> @ast::expr;
fn expr_self(&self, span: span) -> @ast::expr;
@ -110,7 +110,7 @@ pub trait AstBuilder {
fn expr_blk(&self, b: ast::blk) -> @ast::expr;
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field;
fn expr_struct(&self, span: span, path: @ast::Path, fields: ~[ast::field]) -> @ast::expr;
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr;
fn expr_struct_ident(&self, span: span, id: ast::ident, fields: ~[ast::field]) -> @ast::expr;
fn expr_lit(&self, sp: span, lit: ast::lit_) -> @ast::expr;
@ -138,9 +138,9 @@ pub trait AstBuilder {
span: span,
ident: ast::ident,
bm: ast::binding_mode) -> @ast::pat;
fn pat_enum(&self, span: span, path: @ast::Path, subpats: ~[@ast::pat]) -> @ast::pat;
fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat;
fn pat_struct(&self, span: span,
path: @ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat;
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat;
fn arm(&self, span: span, pats: ~[@ast::pat], expr: @ast::expr) -> ast::arm;
fn arm_unreachable(&self, span: span) -> ast::arm;
@ -226,13 +226,13 @@ pub trait AstBuilder {
}
impl AstBuilder for @ExtCtxt {
fn path(&self, span: span, strs: ~[ast::ident]) -> @ast::Path {
fn path(&self, span: span, strs: ~[ast::ident]) -> ast::Path {
self.path_all(span, false, strs, None, ~[])
}
fn path_ident(&self, span: span, id: ast::ident) -> @ast::Path {
fn path_ident(&self, span: span, id: ast::ident) -> ast::Path {
self.path(span, ~[id])
}
fn path_global(&self, span: span, strs: ~[ast::ident]) -> @ast::Path {
fn path_global(&self, span: span, strs: ~[ast::ident]) -> ast::Path {
self.path_all(span, true, strs, None, ~[])
}
fn path_all(&self, sp: span,
@ -240,8 +240,8 @@ impl AstBuilder for @ExtCtxt {
idents: ~[ast::ident],
rp: Option<@ast::Lifetime>,
types: ~[@ast::Ty])
-> @ast::Path {
@ast::Path {
-> ast::Path {
ast::Path {
span: sp,
global: global,
idents: idents,
@ -265,7 +265,7 @@ impl AstBuilder for @ExtCtxt {
}
}
fn ty_path(&self, path: @ast::Path, bounds: @Option<OptVec<ast::TyParamBound>>)
fn ty_path(&self, path: ast::Path, bounds: @Option<OptVec<ast::TyParamBound>>)
-> @ast::Ty {
self.ty(path.span,
ast::ty_path(path, bounds, self.next_id()))
@ -358,14 +358,14 @@ impl AstBuilder for @ExtCtxt {
}
}
fn trait_ref(&self, path: @ast::Path) -> @ast::trait_ref {
fn trait_ref(&self, path: ast::Path) -> @ast::trait_ref {
@ast::trait_ref {
path: path,
ref_id: self.next_id()
}
}
fn typarambound(&self, path: @ast::Path) -> ast::TyParamBound {
fn typarambound(&self, path: ast::Path) -> ast::TyParamBound {
ast::TraitTyParamBound(self.trait_ref(path))
}
@ -421,7 +421,7 @@ impl AstBuilder for @ExtCtxt {
}
}
fn expr_path(&self, path: @ast::Path) -> @ast::expr {
fn expr_path(&self, path: ast::Path) -> @ast::expr {
self.expr(path.span, ast::expr_path(path))
}
@ -487,7 +487,7 @@ impl AstBuilder for @ExtCtxt {
fn field_imm(&self, span: span, name: ident, e: @ast::expr) -> ast::field {
respan(span, ast::field_ { ident: name, expr: e })
}
fn expr_struct(&self, span: span, path: @ast::Path, fields: ~[ast::field]) -> @ast::expr {
fn expr_struct(&self, span: span, path: ast::Path, fields: ~[ast::field]) -> @ast::expr {
self.expr(span, ast::expr_struct(path, fields, None))
}
fn expr_struct_ident(&self, span: span,
@ -570,12 +570,12 @@ impl AstBuilder for @ExtCtxt {
let pat = ast::pat_ident(bm, path, None);
self.pat(span, pat)
}
fn pat_enum(&self, span: span, path: @ast::Path, subpats: ~[@ast::pat]) -> @ast::pat {
fn pat_enum(&self, span: span, path: ast::Path, subpats: ~[@ast::pat]) -> @ast::pat {
let pat = ast::pat_enum(path, Some(subpats));
self.pat(span, pat)
}
fn pat_struct(&self, span: span,
path: @ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat {
path: ast::Path, field_pats: ~[ast::field_pat]) -> @ast::pat {
let pat = ast::pat_struct(path, field_pats, false);
self.pat(span, pat)
}

View file

@ -36,7 +36,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
let e = @ast::expr {
id: cx.next_id(),
node: ast::expr_path(
@ast::Path {
ast::Path {
span: sp,
global: false,
idents: ~[res],

View file

@ -335,7 +335,7 @@ impl<'self> TraitDef<'self> {
cx.typarambound(p.to_path(cx, span, type_ident, generics))
});
// require the current trait
bounds.push(cx.typarambound(trait_path));
bounds.push(cx.typarambound(copy trait_path));
trait_generics.ty_params.push(cx.typaram(ty_param.ident, @bounds));
}
@ -890,7 +890,7 @@ fn summarise_struct(cx: @ExtCtxt, span: span,
pub fn create_subpatterns(cx: @ExtCtxt,
span: span,
field_paths: ~[@ast::Path],
field_paths: ~[ast::Path],
mutbl: ast::mutability)
-> ~[@ast::pat] {
do field_paths.map |&path| {
@ -941,7 +941,7 @@ fn create_struct_pattern(cx: @ExtCtxt,
};
let path = cx.path_ident(span,
cx.ident_of(fmt!("%s_%u", prefix, i)));
paths.push(path);
paths.push(copy path);
ident_expr.push((opt_id, cx.expr_path(path)));
}
@ -987,7 +987,7 @@ fn create_enum_variant_pattern(cx: @ExtCtxt,
let path = cx.path_ident(span,
cx.ident_of(fmt!("%s_%u", prefix, i)));
paths.push(path);
paths.push(copy path);
ident_expr.push((None, cx.expr_path(path)));
}

View file

@ -70,7 +70,7 @@ impl<'self> Path<'self> {
span: span,
self_ty: ident,
self_generics: &Generics)
-> @ast::Path {
-> ast::Path {
let idents = self.path.map(|s| cx.ident_of(*s) );
let lt = mk_lifetime(cx, span, &self.lifetime);
let tys = self.params.map(|t| t.to_ty(cx, span, self_ty, self_generics));
@ -162,7 +162,7 @@ impl<'self> Ty<'self> {
span: span,
self_ty: ident,
self_generics: &Generics)
-> @ast::Path {
-> ast::Path {
match *self {
Self => {
let self_params = do self_generics.ty_params.map |ty_param| {

View file

@ -40,7 +40,7 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
expr_mac(ref mac) => {
match (*mac).node {
// Token-tree macros:
mac_invoc_tt(pth, ref tts) => {
mac_invoc_tt(ref pth, ref tts) => {
if (pth.idents.len() > 1u) {
cx.span_fatal(
pth.span,
@ -208,7 +208,7 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
fld: @ast_fold)
-> Option<@ast::item> {
let (pth, tts) = match it.node {
item_mac(codemap::spanned { node: mac_invoc_tt(pth, ref tts), _}) => {
item_mac(codemap::spanned { node: mac_invoc_tt(ref pth, ref tts), _}) => {
(pth, copy *tts)
}
_ => cx.span_bug(it.span, "invalid item macro invocation")
@ -298,7 +298,7 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
let (mac, pth, tts, semi) = match *s {
stmt_mac(ref mac, semi) => {
match mac.node {
mac_invoc_tt(pth, ref tts) => {
mac_invoc_tt(ref pth, ref tts) => {
(copy *mac, pth, copy *tts, semi)
}
}
@ -372,10 +372,10 @@ pub fn new_name_finder() -> @Visitor<@mut ~[ast::ident]> {
(ident_accum, v): (@mut ~[ast::ident], visit::vt<@mut ~[ast::ident]>)| {
match *p {
// we found a pat_ident!
ast::pat{id:_, node: ast::pat_ident(_,path,ref inner), span:_} => {
ast::pat{id:_, node: ast::pat_ident(_,ref path,ref inner), span:_} => {
match path {
// a path of length one:
@ast::Path{global: false,idents: [id], span:_,rp:_,types:_} =>
&ast::Path{global: false,idents: [id], span:_,rp:_,types:_} =>
ident_accum.push(id),
// I believe these must be enums...
_ => ()

View file

@ -25,16 +25,16 @@ mod syntax {
pub use parse;
}
pub fn path(ids: ~[ident], span: span) -> @ast::Path {
@ast::Path { span: span,
pub fn path(ids: ~[ident], span: span) -> ast::Path {
ast::Path { span: span,
global: false,
idents: ids,
rp: None,
types: ~[] }
}
pub fn path_global(ids: ~[ident], span: span) -> @ast::Path {
@ast::Path { span: span,
pub fn path_global(ids: ~[ident], span: span) -> ast::Path {
ast::Path { span: span,
global: true,
idents: ids,
rp: None,
@ -42,22 +42,22 @@ pub fn path_global(ids: ~[ident], span: span) -> @ast::Path {
}
pub trait append_types {
fn add_ty(&self, ty: @ast::Ty) -> @ast::Path;
fn add_tys(&self, tys: ~[@ast::Ty]) -> @ast::Path;
fn add_ty(&self, ty: @ast::Ty) -> ast::Path;
fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path;
}
impl append_types for @ast::Path {
fn add_ty(&self, ty: @ast::Ty) -> @ast::Path {
@ast::Path {
impl append_types for ast::Path {
fn add_ty(&self, ty: @ast::Ty) -> ast::Path {
ast::Path {
types: vec::append_one(copy self.types, ty),
.. copy **self
.. copy *self
}
}
fn add_tys(&self, tys: ~[@ast::Ty]) -> @ast::Path {
@ast::Path {
fn add_tys(&self, tys: ~[@ast::Ty]) -> ast::Path {
ast::Path {
types: vec::append(copy self.types, tys),
.. copy **self
.. copy *self
}
}
}

View file

@ -33,7 +33,7 @@ pub trait ast_fold {
fn fold_foreign_mod(@self, &foreign_mod) -> foreign_mod;
fn fold_variant(@self, &variant) -> variant;
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 map_exprs(@self, @fn(@expr) -> @expr, &[@expr]) -> ~[@expr];
fn new_id(@self, node_id) -> node_id;
@ -62,7 +62,7 @@ pub struct AstFoldFns {
fold_foreign_mod: @fn(&foreign_mod, @ast_fold) -> foreign_mod,
fold_variant: @fn(&variant_, span, @ast_fold) -> (variant_, span),
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),
map_exprs: @fn(@fn(@expr) -> @expr, &[@expr]) -> ~[@expr],
new_id: @fn(node_id) -> node_id,
@ -117,7 +117,7 @@ fn fold_arg_(a: arg, fld: @ast_fold) -> arg {
fn fold_mac_(m: &mac, fld: @ast_fold) -> mac {
spanned {
node: match m.node {
mac_invoc_tt(p,ref tts) =>
mac_invoc_tt(ref p,ref tts) =>
mac_invoc_tt(fld.fold_path(p),
fold_tts(*tts,fld))
},
@ -337,7 +337,7 @@ fn fold_struct_def(struct_def: @ast::struct_def, fld: @ast_fold)
fn fold_trait_ref(p: @trait_ref, fld: @ast_fold) -> @trait_ref {
@ast::trait_ref {
path: fld.fold_path(p.path),
path: fld.fold_path(&p.path),
ref_id: fld.new_id(p.ref_id),
}
}
@ -419,7 +419,7 @@ fn noop_fold_arm(a: &arm, fld: @ast_fold) -> arm {
pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
match *p {
pat_wild => pat_wild,
pat_ident(binding_mode, pth, ref sub) => {
pat_ident(binding_mode, ref pth, ref sub) => {
pat_ident(
binding_mode,
fld.fold_path(pth),
@ -427,13 +427,13 @@ pub fn noop_fold_pat(p: &pat_, fld: @ast_fold) -> pat_ {
)
}
pat_lit(e) => pat_lit(fld.fold_expr(e)),
pat_enum(pth, ref pats) => {
pat_enum(ref pth, ref pats) => {
pat_enum(
fld.fold_path(pth),
pats.map(|pats| pats.map(|x| fld.fold_pat(*x)))
)
}
pat_struct(pth, ref fields, etc) => {
pat_struct(ref pth, ref fields, etc) => {
let pth_ = fld.fold_path(pth);
let fs = do fields.map |f| {
ast::field_pat {
@ -596,7 +596,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
fld.fold_expr(er)
)
}
expr_path(pth) => expr_path(fld.fold_path(pth)),
expr_path(ref pth) => expr_path(fld.fold_path(pth)),
expr_self => expr_self,
expr_break(ref opt_ident) => {
expr_break(opt_ident.map(|x| fld.fold_ident(*x)))
@ -621,7 +621,7 @@ pub fn noop_fold_expr(e: &expr_, fld: @ast_fold) -> expr_ {
})
}
expr_mac(ref mac) => expr_mac(fold_mac(mac)),
expr_struct(path, ref fields, maybe_expr) => {
expr_struct(ref path, ref fields, maybe_expr) => {
expr_struct(
fld.fold_path(path),
fields.map(|x| fold_field(*x)),
@ -682,7 +682,7 @@ pub fn noop_fold_ty(t: &ty_, fld: @ast_fold) -> ty_ {
})
}
ty_tup(ref tys) => ty_tup(tys.map(|ty| fld.fold_ty(*ty))),
ty_path(path, bounds, id) =>
ty_path(ref path, bounds, id) =>
ty_path(fld.fold_path(path), @fold_opt_bounds(bounds, fld), fld.new_id(id)),
ty_fixed_length_vec(ref mt, e) => {
ty_fixed_length_vec(
@ -754,7 +754,7 @@ fn noop_fold_ident(i: ident, _fld: @ast_fold) -> ident {
/* 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 {
span: fld.new_span(p.span),
global: p.global,
@ -907,8 +907,8 @@ impl ast_fold for AstFoldFns {
fn fold_ident(@self, x: ident) -> ident {
(self.fold_ident)(x, self as @ast_fold)
}
fn fold_path(@self, x: @Path) -> @Path {
@(self.fold_path)(x, self as @ast_fold)
fn fold_path(@self, x: &Path) -> Path {
(self.fold_path)(x, self as @ast_fold)
}
fn fold_local(@self, x: @local) -> @local {
let (n, s) = (self.fold_local)(&x.node, x.span, self as @ast_fold);

View file

@ -366,7 +366,7 @@ mod test {
#[test] fn path_exprs_1 () {
assert_eq!(string_to_expr(@"a"),
@ast::expr{id:1,
node:ast::expr_path(@ast::Path {span:sp(0,1),
node:ast::expr_path(ast::Path {span:sp(0,1),
global:false,
idents:~[str_to_ident("a")],
rp:None,
@ -378,7 +378,7 @@ mod test {
assert_eq!(string_to_expr(@"::a::b"),
@ast::expr{id:1,
node:ast::expr_path(
@ast::Path {span:sp(0,6),
ast::Path {span:sp(0,6),
global:true,
idents:strs_to_idents(~["a","b"]),
rp:None,
@ -428,7 +428,7 @@ mod test {
node:ast::expr_ret(
Some(@ast::expr{id:1,
node:ast::expr_path(
@ast::Path{span:sp(7,8),
ast::Path{span:sp(7,8),
global:false,
idents:~[str_to_ident("d")],
rp:None,
@ -444,7 +444,7 @@ mod test {
node: ast::stmt_expr(@ast::expr{
id: 1,
node: ast::expr_path(
@ast::Path{
ast::Path{
span:sp(0,1),
global:false,
idents:~[str_to_ident("b")],
@ -465,7 +465,7 @@ mod test {
assert_eq!(parser.parse_pat(),
@ast::pat{id:1, // fixme
node: ast::pat_ident(ast::bind_infer,
@ast::Path{
ast::Path{
span:sp(0,1),
global:false,
idents:~[str_to_ident("b")],
@ -483,7 +483,7 @@ mod test {
ast::arg{
is_mutbl: false,
ty: @ast::Ty{id:3, // fixme
node: ast::ty_path(@ast::Path{
node: ast::ty_path(ast::Path{
span:sp(4,4), // this is bizarre...
// check this in the original parser?
global:false,
@ -494,7 +494,7 @@ mod test {
span:sp(4,7)},
pat: @ast::pat{id:1,
node: ast::pat_ident(ast::bind_infer,
@ast::Path{
ast::Path{
span:sp(0,1),
global:false,
idents:~[str_to_ident("b")],
@ -520,7 +520,7 @@ mod test {
inputs: ~[ast::arg{
is_mutbl: false,
ty: @ast::Ty{id:3, // fixme
node: ast::ty_path(@ast::Path{
node: ast::ty_path(ast::Path{
span:sp(10,13),
global:false,
idents:~[str_to_ident("int")],
@ -531,7 +531,7 @@ mod test {
pat: @ast::pat{id:1, // fixme
node: ast::pat_ident(
ast::bind_infer,
@ast::Path{
ast::Path{
span:sp(6,7),
global:false,
idents:~[str_to_ident("b")],
@ -561,7 +561,7 @@ mod test {
node: ast::stmt_semi(@ast::expr{
id: 6,
node: ast::expr_path(
@ast::Path{
ast::Path{
span:sp(17,18),
global:false,
idents:~[str_to_ident("b")],

View file

@ -130,20 +130,28 @@ The important thing is to make sure that lookahead doesn't balk
at INTERPOLATED tokens */
macro_rules! maybe_whole_expr (
($p:expr) => (
match *($p).token {
INTERPOLATED(token::nt_expr(e)) => {
$p.bump();
return e;
{
// This horrible convolution is brought to you by
// @mut, have a terrible day
let ret = match *($p).token {
INTERPOLATED(token::nt_expr(e)) => {
Some(e)
}
INTERPOLATED(token::nt_path(ref pt)) => {
Some($p.mk_expr(
($p).span.lo,
($p).span.hi,
expr_path(/* bad */ copy *pt)))
}
_ => None
};
match ret {
Some(e) => {
$p.bump();
return e;
}
None => ()
}
INTERPOLATED(token::nt_path(pt)) => {
$p.bump();
return $p.mk_expr(
($p).span.lo,
($p).span.hi,
expr_path(pt)
);
}
_ => ()
}
)
)
@ -1218,10 +1226,10 @@ impl Parser {
}
// parse a path that doesn't have type parameters attached
pub fn parse_path_without_tps(&self) -> @ast::Path {
pub fn parse_path_without_tps(&self) -> ast::Path {
maybe_whole!(self, nt_path);
let (ids,is_global,sp) = self.parse_path();
@ast::Path { span: sp,
ast::Path { span: sp,
global: is_global,
idents: ids,
rp: None,
@ -1229,7 +1237,7 @@ impl Parser {
}
pub fn parse_bounded_path_with_tps(&self, colons: bool,
before_tps: Option<&fn()>) -> @ast::Path {
before_tps: Option<&fn()>) -> ast::Path {
debug!("parse_path_with_tps(colons=%b)", colons);
maybe_whole!(self, nt_path);
@ -1288,22 +1296,22 @@ impl Parser {
}
};
@ast::Path { span: mk_sp(lo, hi),
ast::Path { span: mk_sp(lo, hi),
rp: rp,
types: tps,
.. copy *path }
.. path }
}
// parse a path optionally with type parameters. If 'colons'
// is true, then type parameters must be preceded by colons,
// as in a::t::<t1,t2>
pub fn parse_path_with_tps(&self, colons: bool) -> @ast::Path {
pub fn parse_path_with_tps(&self, colons: bool) -> ast::Path {
self.parse_bounded_path_with_tps(colons, None)
}
// Like the above, but can also parse kind bounds in the case of a
// path to be used as a type that might be a trait.
pub fn parse_type_path(&self) -> (@ast::Path, Option<OptVec<TyParamBound>>) {
pub fn parse_type_path(&self) -> (ast::Path, Option<OptVec<TyParamBound>>) {
let mut bounds = None;
let path = self.parse_bounded_path_with_tps(false, Some(|| {
// Note: this closure might not even get called in the case of a
@ -3557,9 +3565,9 @@ impl Parser {
let opt_trait = if could_be_trait && self.eat_keyword(keywords::For) {
// New-style trait. Reinterpret the type as a trait.
let opt_trait_ref = match ty.node {
ty_path(path, @None, node_id) => {
ty_path(ref path, @None, node_id) => {
Some(@trait_ref {
path: path,
path: /* bad */ copy *path,
ref_id: node_id
})
}
@ -4558,7 +4566,7 @@ impl Parser {
let id = self.parse_ident();
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,
idents: path,
rp: None,
@ -4588,7 +4596,7 @@ impl Parser {
seq_sep_trailing_allowed(token::COMMA),
|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,
idents: path,
rp: None,
@ -4600,7 +4608,7 @@ impl Parser {
// foo::bar::*
token::BINOP(token::STAR) => {
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,
idents: path,
rp: None,
@ -4616,7 +4624,7 @@ impl Parser {
_ => ()
}
let last = path[path.len() - 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,
idents: path,
rp: None,

View file

@ -106,7 +106,7 @@ pub enum nonterminal {
nt_expr(@ast::expr),
nt_ty( @ast::Ty),
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_matchers(~[ast::matcher])
}

View file

@ -179,7 +179,7 @@ pub fn generics_to_str(generics: &ast::Generics,
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)
}
@ -419,7 +419,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
f.purity, f.onceness, &f.decl, None, &f.bounds,
Some(&generics), None);
}
ast::ty_path(path, bounds, _) => print_bounded_path(s, path, bounds),
ast::ty_path(ref path, bounds, _) => print_bounded_path(s, path, bounds),
ast::ty_fixed_length_vec(ref mt, v) => {
word(s.s, "[");
match mt.mutbl {
@ -600,7 +600,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
if i != 0 {
word_space(s, "+");
}
print_path(s, trait_.path, false);
print_path(s, &trait_.path, false);
}
}
word(s.s, " ");
@ -610,7 +610,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
}
bclose(s, item.span);
}
ast::item_mac(codemap::spanned { node: ast::mac_invoc_tt(pth, ref tts),
ast::item_mac(codemap::spanned { node: ast::mac_invoc_tt(ref pth, ref tts),
_}) => {
print_visibility(s, item.vis);
print_path(s, pth, false);
@ -627,7 +627,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
}
fn print_trait_ref(s: @ps, t: &ast::trait_ref) {
print_path(s, t.path, false);
print_path(s, &t.path, false);
}
pub fn print_enum_def(s: @ps, enum_definition: &ast::enum_def,
@ -1005,7 +1005,7 @@ pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk,
pub fn print_mac(s: @ps, m: &ast::mac) {
match m.node {
ast::mac_invoc_tt(pth, ref tts) => {
ast::mac_invoc_tt(ref pth, ref tts) => {
print_path(s, pth, false);
word(s.s, "!");
popen(s);
@ -1134,7 +1134,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
end(s);
}
ast::expr_struct(path, ref fields, wth) => {
ast::expr_struct(ref path, ref fields, wth) => {
print_path(s, path, true);
word(s.s, "{");
commasep_cmnt(s, consistent, (*fields), print_field, get_span);
@ -1359,7 +1359,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
print_expr(s, index);
word(s.s, "]");
}
ast::expr_path(path) => print_path(s, path, true),
ast::expr_path(ref path) => print_path(s, path, true),
ast::expr_self => word(s.s, "self"),
ast::expr_break(opt_ident) => {
word(s.s, "break");
@ -1486,7 +1486,7 @@ pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) {
print_expr(s, coll);
}
fn print_path_(s: @ps, path: @ast::Path, colons_before_params: bool,
fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool,
opt_bounds: &Option<OptVec<ast::TyParamBound>>) {
maybe_print_comment(s, path.span.lo);
if path.global { word(s.s, "::"); }
@ -1518,11 +1518,11 @@ 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) {
pub fn print_path(s: @ps, path: &ast::Path, colons_before_params: bool) {
print_path_(s, path, colons_before_params, &None)
}
pub fn print_bounded_path(s: @ps, path: @ast::Path,
pub fn print_bounded_path(s: @ps, path: &ast::Path,
bounds: &Option<OptVec<ast::TyParamBound>>) {
print_path_(s, path, false, bounds)
}
@ -1543,7 +1543,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
is that it doesn't matter */
match pat.node {
ast::pat_wild => word(s.s, "_"),
ast::pat_ident(binding_mode, path, sub) => {
ast::pat_ident(binding_mode, ref path, sub) => {
if refutable {
match binding_mode {
ast::bind_by_ref(mutbl) => {
@ -1562,7 +1562,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
None => ()
}
}
ast::pat_enum(path, ref args_) => {
ast::pat_enum(ref path, ref args_) => {
print_path(s, path, true);
match *args_ {
None => word(s.s, "(*)"),
@ -1576,7 +1576,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
}
}
}
ast::pat_struct(path, ref fields, etc) => {
ast::pat_struct(ref path, ref fields, etc) => {
print_path(s, path, true);
word(s.s, "{");
fn print_field(s: @ps, f: ast::field_pat, refutable: bool) {
@ -1815,7 +1815,7 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
pub fn print_view_path(s: @ps, vp: @ast::view_path) {
match vp.node {
ast::view_path_simple(ident, path, _) => {
ast::view_path_simple(ident, ref path, _) => {
if path.idents[path.idents.len()-1u] != ident {
print_ident(s, ident);
space(s.s);
@ -1824,12 +1824,12 @@ pub fn print_view_path(s: @ps, vp: @ast::view_path) {
print_path(s, path, false);
}
ast::view_path_glob(path, _) => {
ast::view_path_glob(ref path, _) => {
print_path(s, path, false);
word(s.s, "::*");
}
ast::view_path_list(path, ref idents, _) => {
ast::view_path_list(ref path, ref idents, _) => {
print_path(s, path, false);
word(s.s, "::{");
do commasep(s, inconsistent, (*idents)) |s, w| {
@ -1892,7 +1892,7 @@ pub fn print_arg(s: @ps, input: ast::arg) {
ast::ty_infer => print_irrefutable_pat(s, input.pat),
_ => {
match input.pat.node {
ast::pat_ident(_, path, _) if
ast::pat_ident(_, ref path, _) if
path.idents.len() == 1 &&
path.idents[0] == parse::token::special_idents::invalid => {
// Do nothing.

View file

@ -139,7 +139,7 @@ pub fn visit_local<E: Copy>(loc: &local, (e, v): (E, vt<E>)) {
}
fn visit_trait_ref<E: Copy>(tref: &ast::trait_ref, (e, v): (E, vt<E>)) {
visit_path(tref.path, (e, v));
visit_path(&tref.path, (e, v));
}
pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) {
@ -197,7 +197,7 @@ pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) {
}
item_trait(ref generics, ref traits, ref methods) => {
(v.visit_generics)(generics, (copy e, v));
for traits.iter().advance |p| { visit_path(p.path, (copy e, v)); }
for traits.iter().advance |p| { visit_path(&p.path, (copy e, v)); }
for methods.iter().advance |m| {
(v.visit_trait_method)(m, (copy e, v));
}
@ -252,7 +252,7 @@ pub fn visit_ty<E: Copy>(t: &Ty, (e, v): (E, vt<E>)) {
for f.decl.inputs.iter().advance |a| { (v.visit_ty)(a.ty, (copy e, v)); }
(v.visit_ty)(f.decl.output, (e, v));
},
ty_path(p, bounds, _) => {
ty_path(ref p, bounds, _) => {
visit_path(p, (copy e, v));
do bounds.map |bounds| {
visit_ty_param_bounds(bounds, (copy e, v));
@ -272,7 +272,7 @@ pub fn visit_path<E: Copy>(p: &Path, (e, v): (E, vt<E>)) {
pub fn visit_pat<E: Copy>(p: &pat, (e, v): (E, vt<E>)) {
match p.node {
pat_enum(path, ref children) => {
pat_enum(ref path, ref children) => {
visit_path(path, (copy e, v));
for children.iter().advance |children| {
for children.iter().advance |child| {
@ -280,7 +280,7 @@ pub fn visit_pat<E: Copy>(p: &pat, (e, v): (E, vt<E>)) {
}
}
}
pat_struct(path, ref fields, _) => {
pat_struct(ref path, ref fields, _) => {
visit_path(path, (copy e, v));
for fields.iter().advance |f| {
(v.visit_pat)(f.pat, (copy e, v));
@ -294,7 +294,7 @@ pub fn visit_pat<E: Copy>(p: &pat, (e, v): (E, vt<E>)) {
pat_box(inner) | pat_uniq(inner) | pat_region(inner) => {
(v.visit_pat)(inner, (e, v))
},
pat_ident(_, path, ref inner) => {
pat_ident(_, ref path, ref inner) => {
visit_path(path, (copy e, v));
for inner.iter().advance |subpat| {
(v.visit_pat)(*subpat, (copy e, v))
@ -458,7 +458,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
(v.visit_expr)(element, (copy e, v));
(v.visit_expr)(count, (copy e, v));
}
expr_struct(p, ref flds, base) => {
expr_struct(ref p, ref flds, base) => {
visit_path(p, (copy e, v));
for flds.iter().advance |f| {
(v.visit_expr)(f.node.expr, (copy e, v));
@ -534,7 +534,7 @@ pub fn visit_expr<E: Copy>(ex: @expr, (e, v): (E, vt<E>)) {
(v.visit_expr)(a, (copy e, v));
(v.visit_expr)(b, (copy e, v));
}
expr_path(p) => visit_path(p, (copy e, v)),
expr_path(ref p) => visit_path(p, (copy e, v)),
expr_self => (),
expr_break(_) => (),
expr_again(_) => (),