De-share trait_ref
Also, makes the pretty-printer use & instead of @ as much as possible, which will help with later changes, though in the interim has produced some... interesting constructs.
This commit is contained in:
parent
62c83bb17b
commit
97c5a44d3e
@ -98,10 +98,10 @@ fn fold_foreign_mod(
|
||||
fn fold_item_underscore(cx: @Context, item: &ast::item_,
|
||||
fld: @fold::ast_fold) -> ast::item_ {
|
||||
let item = match *item {
|
||||
ast::item_impl(ref a, b, c, ref methods) => {
|
||||
ast::item_impl(ref a, ref b, c, ref methods) => {
|
||||
let methods = methods.iter().filter(|m| method_in_cfg(cx, **m))
|
||||
.transform(|x| *x).collect();
|
||||
ast::item_impl(/*bad*/ copy *a, b, c, methods)
|
||||
ast::item_impl(/*bad*/ copy *a, /*bad*/ copy *b, c, methods)
|
||||
}
|
||||
ast::item_trait(ref a, ref b, ref methods) => {
|
||||
let methods = methods.iter().filter(|m| trait_method_in_cfg(cx, *m) )
|
||||
|
@ -1141,7 +1141,7 @@ fn list_crate_attributes(intr: @ident_interner, md: ebml::Doc, hash: &str,
|
||||
|
||||
let r = get_attributes(md);
|
||||
for r.iter().advance |attr| {
|
||||
out.write_str(fmt!("%s\n", pprust::attribute_to_str(*attr, intr)));
|
||||
out.write_str(fmt!("%s\n", pprust::attribute_to_str(attr, intr)));
|
||||
}
|
||||
|
||||
out.write_str("\n\n");
|
||||
|
@ -1003,7 +1003,7 @@ fn encode_info_for_item(ecx: &EncodeContext,
|
||||
index);
|
||||
}
|
||||
}
|
||||
item_impl(ref generics, opt_trait, ty, ref methods) => {
|
||||
item_impl(ref generics, ref opt_trait, ty, ref methods) => {
|
||||
add_to_index();
|
||||
ebml_w.start_tag(tag_items_data_item);
|
||||
encode_def_id(ebml_w, local_def(item.id));
|
||||
|
@ -117,7 +117,7 @@ fn check_item(item: @item, (cx, visitor): (Context, visit::vt<Context>)) {
|
||||
// If this is a destructor, check kinds.
|
||||
if !attrs_contains_name(item.attrs, "unsafe_destructor") {
|
||||
match item.node {
|
||||
item_impl(_, Some(trait_ref), self_type, _) => {
|
||||
item_impl(_, Some(ref trait_ref), self_type, _) => {
|
||||
match cx.tcx.def_map.find(&trait_ref.ref_id) {
|
||||
None => cx.tcx.sess.bug("trait ref not in def map!"),
|
||||
Some(&trait_def) => {
|
||||
|
@ -141,7 +141,7 @@ impl ReachableContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
item_impl(ref generics, trait_ref, _, ref methods) => {
|
||||
item_impl(ref generics, ref trait_ref, _, ref methods) => {
|
||||
// XXX(pcwalton): We conservatively assume any methods
|
||||
// on a trait implementation are reachable, when this
|
||||
// is not the case. We could be more precise by only
|
||||
|
@ -3533,7 +3533,7 @@ impl Resolver {
|
||||
}
|
||||
|
||||
item_impl(ref generics,
|
||||
implemented_traits,
|
||||
ref implemented_traits,
|
||||
self_type,
|
||||
ref methods) => {
|
||||
self.resolve_implementation(item.id,
|
||||
@ -3811,7 +3811,7 @@ impl Resolver {
|
||||
type_parameter_bound: &TyParamBound,
|
||||
visitor: ResolveVisitor) {
|
||||
match *type_parameter_bound {
|
||||
TraitTyParamBound(tref) => {
|
||||
TraitTyParamBound(ref tref) => {
|
||||
self.resolve_trait_reference(tref, visitor, TraitBoundingTypeParameter)
|
||||
}
|
||||
RegionTyParamBound => {}
|
||||
@ -3913,7 +3913,7 @@ impl Resolver {
|
||||
pub fn resolve_implementation(@mut self,
|
||||
id: node_id,
|
||||
generics: &Generics,
|
||||
opt_trait_reference: Option<@trait_ref>,
|
||||
opt_trait_reference: &Option<trait_ref>,
|
||||
self_type: @Ty,
|
||||
methods: &[@method],
|
||||
visitor: ResolveVisitor) {
|
||||
@ -3929,7 +3929,7 @@ impl Resolver {
|
||||
// Resolve the trait reference, if necessary.
|
||||
let original_trait_refs;
|
||||
match opt_trait_reference {
|
||||
Some(trait_reference) => {
|
||||
&Some(ref trait_reference) => {
|
||||
self.resolve_trait_reference(trait_reference, visitor, TraitImplementation);
|
||||
|
||||
// Record the current set of trait references.
|
||||
@ -3944,7 +3944,7 @@ impl Resolver {
|
||||
&mut self.current_trait_refs,
|
||||
Some(new_trait_refs)));
|
||||
}
|
||||
None => {
|
||||
&None => {
|
||||
original_trait_refs = None;
|
||||
}
|
||||
}
|
||||
|
@ -3624,12 +3624,12 @@ pub fn impl_trait_ref(cx: ctxt, id: ast::def_id) -> Option<@TraitRef> {
|
||||
debug!("(impl_trait_ref) searching for trait impl %?", id);
|
||||
match cx.items.find(&id.node) {
|
||||
Some(&ast_map::node_item(@ast::item {
|
||||
node: ast::item_impl(_, opt_trait, _, _),
|
||||
node: ast::item_impl(_, ref opt_trait, _, _),
|
||||
_},
|
||||
_)) => {
|
||||
match opt_trait {
|
||||
Some(t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)),
|
||||
None => None
|
||||
&Some(ref t) => Some(ty::node_id_to_trait_ref(cx, t.ref_id)),
|
||||
&None => None
|
||||
}
|
||||
}
|
||||
_ => None
|
||||
|
@ -764,7 +764,7 @@ fn conv_builtin_bounds(tcx: ty::ctxt, ast_bounds: &Option<OptVec<ast::TyParamBou
|
||||
let mut builtin_bounds = ty::EmptyBuiltinBounds();
|
||||
for bound_vec.iter().advance |ast_bound| {
|
||||
match *ast_bound {
|
||||
ast::TraitTyParamBound(b) => {
|
||||
ast::TraitTyParamBound(ref b) => {
|
||||
match lookup_def_tcx(tcx, b.path.span, b.ref_id) {
|
||||
ast::def_trait(trait_did) => {
|
||||
if try_add_builtin_trait(tcx,
|
||||
|
@ -207,9 +207,11 @@ impl CoherenceChecker {
|
||||
// self.crate_context.tcx.sess.str_of(item.ident));
|
||||
|
||||
match item.node {
|
||||
item_impl(_, opt_trait, _, _) => {
|
||||
self.check_implementation(item,
|
||||
opt_trait.iter().transform(|&x| x).collect());
|
||||
item_impl(_, ref opt_trait, _, _) => {
|
||||
let opt_trait : ~[trait_ref] = opt_trait.iter()
|
||||
.transform(|&x| x)
|
||||
.collect();
|
||||
self.check_implementation(item, opt_trait);
|
||||
}
|
||||
_ => {
|
||||
// Nothing to do.
|
||||
@ -238,7 +240,7 @@ impl CoherenceChecker {
|
||||
|
||||
pub fn check_implementation(&self,
|
||||
item: @item,
|
||||
associated_traits: ~[@trait_ref]) {
|
||||
associated_traits: &[trait_ref]) {
|
||||
let tcx = self.crate_context.tcx;
|
||||
let self_type = ty::lookup_item_type(tcx, local_def(item.id));
|
||||
|
||||
@ -646,7 +648,7 @@ impl CoherenceChecker {
|
||||
a trait or new type instead");
|
||||
}
|
||||
}
|
||||
item_impl(_, Some(trait_ref), _, _) => {
|
||||
item_impl(_, Some(ref trait_ref), _, _) => {
|
||||
// `for_ty` is `Type` in `impl Trait for Type`
|
||||
let for_ty =
|
||||
ty::node_id_to_type(self.crate_context.tcx,
|
||||
@ -678,7 +680,7 @@ impl CoherenceChecker {
|
||||
})));
|
||||
}
|
||||
|
||||
pub fn trait_ref_to_trait_def_id(&self, trait_ref: @trait_ref) -> def_id {
|
||||
pub fn trait_ref_to_trait_def_id(&self, trait_ref: &trait_ref) -> def_id {
|
||||
let def_map = self.crate_context.tcx.def_map;
|
||||
let trait_def = def_map.get_copy(&trait_ref.ref_id);
|
||||
let trait_id = def_id_of_def(trait_def);
|
||||
@ -805,7 +807,7 @@ impl CoherenceChecker {
|
||||
// Check that we have implementations of every trait method
|
||||
for trait_refs.iter().advance |trait_ref| {
|
||||
let trait_did =
|
||||
self.trait_ref_to_trait_def_id(*trait_ref);
|
||||
self.trait_ref_to_trait_def_id(trait_ref);
|
||||
self.please_check_that_trait_methods_are_implemented(
|
||||
&mut methods,
|
||||
trait_did,
|
||||
@ -817,7 +819,7 @@ impl CoherenceChecker {
|
||||
// if a method of that name is not inherent to the
|
||||
// impl, use the provided definition in the trait.
|
||||
for trait_refs.iter().advance |trait_ref| {
|
||||
let trait_did = self.trait_ref_to_trait_def_id(*trait_ref);
|
||||
let trait_did = self.trait_ref_to_trait_def_id(trait_ref);
|
||||
self.add_provided_methods_to_impl(
|
||||
&mut methods,
|
||||
&trait_did,
|
||||
|
@ -378,7 +378,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
|
||||
id: ast::node_id,
|
||||
sp: codemap::span,
|
||||
rp: Option<ty::region_variance>,
|
||||
ast_trait_refs: &[@ast::trait_ref],
|
||||
ast_trait_refs: &[ast::trait_ref],
|
||||
generics: &ast::Generics)
|
||||
{
|
||||
let tcx = ccx.tcx;
|
||||
@ -386,7 +386,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
|
||||
|
||||
let self_ty = ty::mk_self(ccx.tcx, local_def(id));
|
||||
let mut ty_trait_refs: ~[@ty::TraitRef] = ~[];
|
||||
for ast_trait_refs.iter().advance |&ast_trait_ref| {
|
||||
for ast_trait_refs.iter().advance |ast_trait_ref| {
|
||||
let trait_ref = instantiate_trait_ref(ccx, ast_trait_ref, rp,
|
||||
generics, self_ty);
|
||||
|
||||
@ -441,7 +441,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
|
||||
fmt!("method `%s` has a `%s` declaration in the impl, \
|
||||
but not in the trait",
|
||||
tcx.sess.str_of(trait_m.ident),
|
||||
explicit_self_to_str(impl_m.explicit_self, tcx.sess.intr())));
|
||||
explicit_self_to_str(&impl_m.explicit_self, tcx.sess.intr())));
|
||||
return;
|
||||
}
|
||||
(_, &ast::sty_static) => {
|
||||
@ -450,7 +450,7 @@ pub fn compare_impl_method(tcx: ty::ctxt,
|
||||
fmt!("method `%s` has a `%s` declaration in the trait, \
|
||||
but not in the impl",
|
||||
tcx.sess.str_of(trait_m.ident),
|
||||
explicit_self_to_str(trait_m.explicit_self, tcx.sess.intr())));
|
||||
explicit_self_to_str(&trait_m.explicit_self, tcx.sess.intr())));
|
||||
return;
|
||||
}
|
||||
_ => {
|
||||
@ -813,7 +813,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
|
||||
generics,
|
||||
rp);
|
||||
}
|
||||
ast::item_impl(ref generics, opt_trait_ref, selfty, ref ms) => {
|
||||
ast::item_impl(ref generics, ref opt_trait_ref, selfty, ref ms) => {
|
||||
let i_ty_generics = ty_generics(ccx, rp, generics, 0);
|
||||
let region_parameterization =
|
||||
RegionParameterization::from_variance_and_generics(rp, generics);
|
||||
@ -839,7 +839,7 @@ pub fn convert(ccx: &CrateCtxt, it: &ast::item) {
|
||||
&i_ty_generics, generics,
|
||||
parent_visibility);
|
||||
for opt_trait_ref.iter().advance |t| {
|
||||
check_methods_against_trait(ccx, generics, rp, selfty, *t, cms);
|
||||
check_methods_against_trait(ccx, generics, rp, selfty, t, cms);
|
||||
}
|
||||
}
|
||||
ast::item_trait(ref generics, ref supertraits, ref trait_methods) => {
|
||||
@ -1184,7 +1184,7 @@ pub fn ty_generics(ccx: &CrateCtxt,
|
||||
};
|
||||
for ast_bounds.iter().advance |ast_bound| {
|
||||
match *ast_bound {
|
||||
TraitTyParamBound(b) => {
|
||||
TraitTyParamBound(ref b) => {
|
||||
let ty = ty::mk_param(ccx.tcx, param_ty.idx, param_ty.def_id);
|
||||
let trait_ref = instantiate_trait_ref(ccx, b, rp, generics, ty);
|
||||
if !astconv::try_add_builtin_trait(
|
||||
|
@ -132,7 +132,7 @@ pub static crate_node_id: node_id = 0;
|
||||
// the "special" built-in traits (see middle::lang_items) and
|
||||
// detects Copy, Send, Send, and Freeze.
|
||||
pub enum TyParamBound {
|
||||
TraitTyParamBound(@trait_ref),
|
||||
TraitTyParamBound(trait_ref),
|
||||
RegionTyParamBound
|
||||
}
|
||||
|
||||
@ -1002,9 +1002,9 @@ pub enum item_ {
|
||||
item_ty(@Ty, Generics),
|
||||
item_enum(enum_def, Generics),
|
||||
item_struct(@struct_def, Generics),
|
||||
item_trait(Generics, ~[@trait_ref], ~[trait_method]),
|
||||
item_trait(Generics, ~[trait_ref], ~[trait_method]),
|
||||
item_impl(Generics,
|
||||
Option<@trait_ref>, // (optional) trait this impl implements
|
||||
Option<trait_ref>, // (optional) trait this impl implements
|
||||
@Ty, // self
|
||||
~[@method]),
|
||||
// a macro invocation (which includes macro definition)
|
||||
|
@ -580,7 +580,7 @@ pub fn view_path_id(p: &view_path) -> node_id {
|
||||
|
||||
/// Returns true if the given struct def is tuple-like; i.e. that its fields
|
||||
/// are unnamed.
|
||||
pub fn struct_def_is_tuple_like(struct_def: @ast::struct_def) -> bool {
|
||||
pub fn struct_def_is_tuple_like(struct_def: &ast::struct_def) -> bool {
|
||||
struct_def.ctor_id.is_some()
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ 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 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;
|
||||
|
||||
@ -358,8 +358,8 @@ impl AstBuilder for @ExtCtxt {
|
||||
}
|
||||
}
|
||||
|
||||
fn trait_ref(&self, path: ast::Path) -> @ast::trait_ref {
|
||||
@ast::trait_ref {
|
||||
fn trait_ref(&self, path: ast::Path) -> ast::trait_ref {
|
||||
ast::trait_ref {
|
||||
path: path,
|
||||
ref_id: self.next_id()
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ pub fn expand_syntax_ext(cx: @ExtCtxt,
|
||||
cx.print_backtrace();
|
||||
io::stdout().write_line(
|
||||
print::pprust::tt_to_str(
|
||||
ast::tt_delim(vec::to_owned(tt)),
|
||||
&ast::tt_delim(vec::to_owned(tt)),
|
||||
get_ident_interner()));
|
||||
|
||||
//trivial expression
|
||||
|
@ -82,7 +82,7 @@ pub fn add_new_extension(cx: @ExtCtxt,
|
||||
io::println(fmt!("%s! { %s }",
|
||||
cx.str_of(name),
|
||||
print::pprust::tt_to_str(
|
||||
ast::tt_delim(vec::to_owned(arg)),
|
||||
&ast::tt_delim(vec::to_owned(arg)),
|
||||
get_ident_interner())));
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ pub fn fold_fn_decl(decl: &ast::fn_decl, fld: @ast_fold) -> ast::fn_decl {
|
||||
|
||||
fn fold_ty_param_bound(tpb: &TyParamBound, fld: @ast_fold) -> TyParamBound {
|
||||
match *tpb {
|
||||
TraitTyParamBound(ty) => TraitTyParamBound(fold_trait_ref(ty, fld)),
|
||||
TraitTyParamBound(ref ty) => TraitTyParamBound(fold_trait_ref(ty, fld)),
|
||||
RegionTyParamBound => RegionTyParamBound
|
||||
}
|
||||
}
|
||||
@ -296,10 +296,10 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
|
||||
let struct_def = fold_struct_def(*struct_def, fld);
|
||||
item_struct(struct_def, /* FIXME (#2543) */ copy *generics)
|
||||
}
|
||||
item_impl(ref generics, ifce, ty, ref methods) => {
|
||||
item_impl(ref generics, ref ifce, ty, ref methods) => {
|
||||
item_impl(
|
||||
fold_generics(generics, fld),
|
||||
ifce.map(|p| fold_trait_ref(*p, fld)),
|
||||
ifce.map(|p| fold_trait_ref(p, fld)),
|
||||
fld.fold_ty(ty),
|
||||
methods.map(|x| fld.fold_method(*x))
|
||||
)
|
||||
@ -313,7 +313,7 @@ pub fn noop_fold_item_underscore(i: &item_, fld: @ast_fold) -> item_ {
|
||||
};
|
||||
item_trait(
|
||||
fold_generics(generics, fld),
|
||||
traits.map(|p| fold_trait_ref(*p, fld)),
|
||||
traits.map(|p| fold_trait_ref(p, fld)),
|
||||
methods
|
||||
)
|
||||
}
|
||||
@ -335,8 +335,8 @@ 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 {
|
||||
fn fold_trait_ref(p: &trait_ref, fld: @ast_fold) -> trait_ref {
|
||||
ast::trait_ref {
|
||||
path: fld.fold_path(&p.path),
|
||||
ref_id: fld.new_id(p.ref_id),
|
||||
}
|
||||
|
@ -3566,7 +3566,7 @@ impl Parser {
|
||||
// New-style trait. Reinterpret the type as a trait.
|
||||
let opt_trait_ref = match ty.node {
|
||||
ty_path(ref path, @None, node_id) => {
|
||||
Some(@trait_ref {
|
||||
Some(trait_ref {
|
||||
path: /* bad */ copy *path,
|
||||
ref_id: node_id
|
||||
})
|
||||
@ -3608,15 +3608,15 @@ impl Parser {
|
||||
}
|
||||
|
||||
// parse a::B<~str,int>
|
||||
fn parse_trait_ref(&self) -> @trait_ref {
|
||||
@ast::trait_ref {
|
||||
fn parse_trait_ref(&self) -> trait_ref {
|
||||
ast::trait_ref {
|
||||
path: self.parse_path_with_tps(false),
|
||||
ref_id: self.get_id(),
|
||||
}
|
||||
}
|
||||
|
||||
// parse B + C<~str,int> + D
|
||||
fn parse_trait_ref_list(&self, ket: &token::Token) -> ~[@trait_ref] {
|
||||
fn parse_trait_ref_list(&self, ket: &token::Token) -> ~[trait_ref] {
|
||||
self.parse_seq_to_before_end(
|
||||
ket,
|
||||
seq_sep_trailing_disallowed(token::BINOP(token::PLUS)),
|
||||
|
@ -34,9 +34,9 @@ use std::uint;
|
||||
// The @ps is stored here to prevent recursive type.
|
||||
pub enum ann_node<'self> {
|
||||
node_block(@ps, &'self ast::blk),
|
||||
node_item(@ps, @ast::item),
|
||||
node_expr(@ps, @ast::expr),
|
||||
node_pat(@ps, @ast::pat),
|
||||
node_item(@ps, &'self ast::item),
|
||||
node_expr(@ps, &'self ast::expr),
|
||||
node_pat(@ps, &'self ast::pat),
|
||||
}
|
||||
pub struct pp_ann {
|
||||
pre: @fn(ann_node),
|
||||
@ -106,7 +106,7 @@ pub static default_columns: uint = 78u;
|
||||
pub fn print_crate(cm: @CodeMap,
|
||||
intr: @ident_interner,
|
||||
span_diagnostic: @diagnostic::span_handler,
|
||||
crate: @ast::crate,
|
||||
crate: &ast::crate,
|
||||
filename: @str,
|
||||
in: @io::Reader,
|
||||
out: @io::Writer,
|
||||
@ -136,21 +136,21 @@ pub fn print_crate(cm: @CodeMap,
|
||||
print_crate_(s, crate);
|
||||
}
|
||||
|
||||
pub fn print_crate_(s: @ps, crate: @ast::crate) {
|
||||
pub fn print_crate_(s: @ps, crate: &ast::crate) {
|
||||
print_mod(s, &crate.node.module, crate.node.attrs);
|
||||
print_remaining_comments(s);
|
||||
eof(s.s);
|
||||
}
|
||||
|
||||
pub fn ty_to_str(ty: @ast::Ty, intr: @ident_interner) -> ~str {
|
||||
pub fn ty_to_str(ty: &ast::Ty, intr: @ident_interner) -> ~str {
|
||||
to_str(ty, print_type, intr)
|
||||
}
|
||||
|
||||
pub fn pat_to_str(pat: @ast::pat, intr: @ident_interner) -> ~str {
|
||||
pub fn pat_to_str(pat: &ast::pat, intr: @ident_interner) -> ~str {
|
||||
to_str(pat, print_irrefutable_pat, intr)
|
||||
}
|
||||
|
||||
pub fn expr_to_str(e: @ast::expr, intr: @ident_interner) -> ~str {
|
||||
pub fn expr_to_str(e: &ast::expr, intr: @ident_interner) -> ~str {
|
||||
to_str(e, print_expr, intr)
|
||||
}
|
||||
|
||||
@ -158,19 +158,19 @@ pub fn lifetime_to_str(e: &ast::Lifetime, intr: @ident_interner) -> ~str {
|
||||
to_str(e, print_lifetime, intr)
|
||||
}
|
||||
|
||||
pub fn tt_to_str(tt: ast::token_tree, intr: @ident_interner) -> ~str {
|
||||
to_str(&tt, print_tt, intr)
|
||||
pub fn tt_to_str(tt: &ast::token_tree, intr: @ident_interner) -> ~str {
|
||||
to_str(tt, print_tt, intr)
|
||||
}
|
||||
|
||||
pub fn tts_to_str(tts: &[ast::token_tree], intr: @ident_interner) -> ~str {
|
||||
to_str(tts, print_tts, intr)
|
||||
to_str(&tts, print_tts, intr)
|
||||
}
|
||||
|
||||
pub fn stmt_to_str(s: &ast::stmt, intr: @ident_interner) -> ~str {
|
||||
to_str(s, print_stmt, intr)
|
||||
}
|
||||
|
||||
pub fn item_to_str(i: @ast::item, intr: @ident_interner) -> ~str {
|
||||
pub fn item_to_str(i: &ast::item, intr: @ident_interner) -> ~str {
|
||||
to_str(i, print_item, intr)
|
||||
}
|
||||
|
||||
@ -208,11 +208,11 @@ pub fn block_to_str(blk: &ast::blk, intr: @ident_interner) -> ~str {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn meta_item_to_str(mi: @ast::meta_item, intr: @ident_interner) -> ~str {
|
||||
pub fn meta_item_to_str(mi: &ast::meta_item, intr: @ident_interner) -> ~str {
|
||||
to_str(mi, print_meta_item, intr)
|
||||
}
|
||||
|
||||
pub fn attribute_to_str(attr: ast::attribute, intr: @ident_interner) -> ~str {
|
||||
pub fn attribute_to_str(attr: &ast::attribute, intr: @ident_interner) -> ~str {
|
||||
to_str(attr, print_attribute, intr)
|
||||
}
|
||||
|
||||
@ -314,30 +314,30 @@ pub fn synth_comment(s: @ps, text: ~str) {
|
||||
word(s.s, "*/");
|
||||
}
|
||||
|
||||
pub fn commasep<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
|
||||
pub fn commasep<T>(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T)) {
|
||||
box(s, 0u, b);
|
||||
let mut first = true;
|
||||
for elts.iter().advance |elt| {
|
||||
if first { first = false; } else { word_space(s, ","); }
|
||||
op(s, copy *elt);
|
||||
op(s, elt);
|
||||
}
|
||||
end(s);
|
||||
}
|
||||
|
||||
|
||||
pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
|
||||
get_span: &fn(IN) -> codemap::span) {
|
||||
pub fn commasep_cmnt<T>(s: @ps, b: breaks, elts: &[T], op: &fn(@ps, &T),
|
||||
get_span: &fn(&T) -> codemap::span) {
|
||||
box(s, 0u, b);
|
||||
let len = elts.len();
|
||||
let mut i = 0u;
|
||||
for elts.iter().advance |elt| {
|
||||
maybe_print_comment(s, get_span(copy *elt).hi);
|
||||
op(s, copy *elt);
|
||||
maybe_print_comment(s, get_span(elt).hi);
|
||||
op(s, elt);
|
||||
i += 1u;
|
||||
if i < len {
|
||||
word(s.s, ",");
|
||||
maybe_print_trailing_comment(s, get_span(copy *elt),
|
||||
Some(get_span(copy elts[i]).hi));
|
||||
maybe_print_trailing_comment(s, get_span(elt),
|
||||
Some(get_span(&elts[i]).hi));
|
||||
space_if_not_bol(s);
|
||||
}
|
||||
}
|
||||
@ -345,8 +345,7 @@ pub fn commasep_cmnt<IN: Copy>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
|
||||
}
|
||||
|
||||
pub fn commasep_exprs(s: @ps, b: breaks, exprs: &[@ast::expr]) {
|
||||
fn expr_span(expr: @ast::expr) -> codemap::span { return expr.span; }
|
||||
commasep_cmnt(s, b, exprs, print_expr, expr_span);
|
||||
commasep_cmnt(s, b, exprs, |p, &e| print_expr(p, e), |e| e.span);
|
||||
}
|
||||
|
||||
pub fn print_mod(s: @ps, _mod: &ast::_mod, attrs: &[ast::attribute]) {
|
||||
@ -373,7 +372,7 @@ pub fn print_opt_lifetime(s: @ps, lifetime: &Option<ast::Lifetime>) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_type(s: @ps, ty: @ast::Ty) {
|
||||
pub fn print_type(s: @ps, ty: &ast::Ty) {
|
||||
maybe_print_comment(s, ty.span.lo);
|
||||
ibox(s, 0u);
|
||||
match ty.node {
|
||||
@ -399,7 +398,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
|
||||
}
|
||||
ast::ty_tup(ref elts) => {
|
||||
popen(s);
|
||||
commasep(s, inconsistent, *elts, print_type);
|
||||
commasep(s, inconsistent, *elts, |p, &t| print_type(p, t));
|
||||
if elts.len() == 1 {
|
||||
word(s.s, ",");
|
||||
}
|
||||
@ -443,7 +442,7 @@ pub fn print_type(s: @ps, ty: @ast::Ty) {
|
||||
end(s);
|
||||
}
|
||||
|
||||
pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
|
||||
pub fn print_foreign_item(s: @ps, item: &ast::foreign_item) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
print_outer_attributes(s, item.attrs);
|
||||
@ -470,7 +469,7 @@ pub fn print_foreign_item(s: @ps, item: @ast::foreign_item) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_item(s: @ps, item: @ast::item) {
|
||||
pub fn print_item(s: @ps, item: &ast::item) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, item.span.lo);
|
||||
print_outer_attributes(s, item.attrs);
|
||||
@ -560,7 +559,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
|
||||
print_struct(s, struct_def, generics, item.ident, item.span);
|
||||
}
|
||||
|
||||
ast::item_impl(ref generics, opt_trait, ty, ref methods) => {
|
||||
ast::item_impl(ref generics, ref opt_trait, ty, ref methods) => {
|
||||
head(s, visibility_qualified(item.vis, "impl"));
|
||||
if generics.is_parameterized() {
|
||||
print_generics(s, generics);
|
||||
@ -568,12 +567,12 @@ pub fn print_item(s: @ps, item: @ast::item) {
|
||||
}
|
||||
|
||||
match opt_trait {
|
||||
Some(t) => {
|
||||
&Some(ref t) => {
|
||||
print_trait_ref(s, t);
|
||||
space(s.s);
|
||||
word_space(s, "for");
|
||||
}
|
||||
None => ()
|
||||
&None => ()
|
||||
};
|
||||
|
||||
print_type(s, ty);
|
||||
@ -618,7 +617,7 @@ pub fn print_item(s: @ps, item: @ast::item) {
|
||||
print_ident(s, item.ident);
|
||||
cbox(s, indent_unit);
|
||||
popen(s);
|
||||
print_tts(s, *tts);
|
||||
print_tts(s, &(tts.as_slice()));
|
||||
pclose(s);
|
||||
end(s);
|
||||
}
|
||||
@ -681,7 +680,7 @@ pub fn print_visibility(s: @ps, vis: ast::visibility) {
|
||||
}
|
||||
|
||||
pub fn print_struct(s: @ps,
|
||||
struct_def: @ast::struct_def,
|
||||
struct_def: &ast::struct_def,
|
||||
generics: &ast::Generics,
|
||||
ident: ast::ident,
|
||||
span: codemap::span) {
|
||||
@ -738,7 +737,7 @@ pub fn print_struct(s: @ps,
|
||||
/// expression arguments as expressions). It can be done! I think.
|
||||
pub fn print_tt(s: @ps, tt: &ast::token_tree) {
|
||||
match *tt {
|
||||
ast::tt_delim(ref tts) => print_tts(s, *tts),
|
||||
ast::tt_delim(ref tts) => print_tts(s, &(tts.as_slice())),
|
||||
ast::tt_tok(_, ref tk) => {
|
||||
word(s.s, parse::token::to_str(s.intr, tk));
|
||||
}
|
||||
@ -759,7 +758,7 @@ pub fn print_tt(s: @ps, tt: &ast::token_tree) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_tts(s: @ps, tts: &[ast::token_tree]) {
|
||||
pub fn print_tts(s: @ps, tts: & &[ast::token_tree]) {
|
||||
ibox(s, 0);
|
||||
for tts.iter().enumerate().advance |(i, tt)| {
|
||||
if i != 0 {
|
||||
@ -777,7 +776,7 @@ pub fn print_variant(s: @ps, v: &ast::variant) {
|
||||
print_ident(s, v.node.name);
|
||||
if !args.is_empty() {
|
||||
popen(s);
|
||||
fn print_variant_arg(s: @ps, arg: ast::variant_arg) {
|
||||
fn print_variant_arg(s: @ps, arg: &ast::variant_arg) {
|
||||
print_type(s, arg.ty);
|
||||
}
|
||||
commasep(s, consistent, *args, print_variant_arg);
|
||||
@ -817,7 +816,7 @@ pub fn print_trait_method(s: @ps, m: &ast::trait_method) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_method(s: @ps, meth: @ast::method) {
|
||||
pub fn print_method(s: @ps, meth: &ast::method) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, meth.span.lo);
|
||||
print_outer_attributes(s, meth.attrs);
|
||||
@ -832,7 +831,7 @@ pub fn print_outer_attributes(s: @ps, attrs: &[ast::attribute]) {
|
||||
let mut count = 0;
|
||||
for attrs.iter().advance |attr| {
|
||||
match attr.node.style {
|
||||
ast::attr_outer => { print_attribute(s, *attr); count += 1; }
|
||||
ast::attr_outer => { print_attribute(s, attr); count += 1; }
|
||||
_ => {/* fallthrough */ }
|
||||
}
|
||||
}
|
||||
@ -844,7 +843,7 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) {
|
||||
for attrs.iter().advance |attr| {
|
||||
match attr.node.style {
|
||||
ast::attr_inner => {
|
||||
print_attribute(s, *attr);
|
||||
print_attribute(s, attr);
|
||||
if !attr.node.is_sugared_doc {
|
||||
word(s.s, ";");
|
||||
}
|
||||
@ -856,11 +855,11 @@ pub fn print_inner_attributes(s: @ps, attrs: &[ast::attribute]) {
|
||||
if count > 0 { hardbreak_if_not_bol(s); }
|
||||
}
|
||||
|
||||
pub fn print_attribute(s: @ps, attr: ast::attribute) {
|
||||
pub fn print_attribute(s: @ps, attr: &ast::attribute) {
|
||||
hardbreak_if_not_bol(s);
|
||||
maybe_print_comment(s, attr.span.lo);
|
||||
if attr.node.is_sugared_doc {
|
||||
let meta = attr::attr_meta(attr);
|
||||
let meta = attr::attr_meta(*attr);
|
||||
let comment = attr::get_meta_item_value_str(meta).get();
|
||||
word(s.s, comment);
|
||||
} else {
|
||||
@ -963,7 +962,7 @@ pub fn print_possibly_embedded_block_(s: @ps,
|
||||
(s.ann.post)(ann_node);
|
||||
}
|
||||
|
||||
pub fn print_if(s: @ps, test: @ast::expr, blk: &ast::blk,
|
||||
pub fn print_if(s: @ps, test: &ast::expr, blk: &ast::blk,
|
||||
elseopt: Option<@ast::expr>, chk: bool) {
|
||||
head(s, "if");
|
||||
if chk { word_nbsp(s, "check"); }
|
||||
@ -1009,7 +1008,7 @@ pub fn print_mac(s: @ps, m: &ast::mac) {
|
||||
print_path(s, pth, false);
|
||||
word(s.s, "!");
|
||||
popen(s);
|
||||
print_tts(s, *tts);
|
||||
print_tts(s, &tts.as_slice());
|
||||
pclose(s);
|
||||
}
|
||||
}
|
||||
@ -1088,15 +1087,15 @@ pub fn print_call_post(s: @ps,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_expr(s: @ps, expr: @ast::expr) {
|
||||
fn print_field(s: @ps, field: ast::field) {
|
||||
pub fn print_expr(s: @ps, expr: &ast::expr) {
|
||||
fn print_field(s: @ps, field: &ast::field) {
|
||||
ibox(s, indent_unit);
|
||||
print_ident(s, field.node.ident);
|
||||
word_space(s, ":");
|
||||
print_expr(s, field.node.expr);
|
||||
end(s);
|
||||
}
|
||||
fn get_span(field: ast::field) -> codemap::span { return field.span; }
|
||||
fn get_span(field: &ast::field) -> codemap::span { return field.span; }
|
||||
|
||||
maybe_print_comment(s, expr.span.lo);
|
||||
ibox(s, indent_unit);
|
||||
@ -1173,7 +1172,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
||||
print_ident(s, ident);
|
||||
if tys.len() > 0u {
|
||||
word(s.s, "::<");
|
||||
commasep(s, inconsistent, *tys, print_type);
|
||||
commasep(s, inconsistent, *tys, |p, &e| print_type(p, e));
|
||||
word(s.s, ">");
|
||||
}
|
||||
print_call_post(s, sugar, &blk, &mut base_args);
|
||||
@ -1349,7 +1348,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
||||
print_ident(s, id);
|
||||
if tys.len() > 0u {
|
||||
word(s.s, "::<");
|
||||
commasep(s, inconsistent, *tys, print_type);
|
||||
commasep(s, inconsistent, *tys, |p, &e| print_type(p, e));
|
||||
word(s.s, ">");
|
||||
}
|
||||
}
|
||||
@ -1434,7 +1433,7 @@ pub fn print_expr(s: @ps, expr: @ast::expr) {
|
||||
end(s);
|
||||
}
|
||||
|
||||
pub fn print_local_decl(s: @ps, loc: @ast::local) {
|
||||
pub fn print_local_decl(s: @ps, loc: &ast::local) {
|
||||
print_irrefutable_pat(s, loc.node.pat);
|
||||
match loc.node.ty.node {
|
||||
ast::ty_infer => (),
|
||||
@ -1442,7 +1441,7 @@ pub fn print_local_decl(s: @ps, loc: @ast::local) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_decl(s: @ps, decl: @ast::decl) {
|
||||
pub fn print_decl(s: @ps, decl: &ast::decl) {
|
||||
maybe_print_comment(s, decl.span.lo);
|
||||
match decl.node {
|
||||
ast::decl_local(ref loc) => {
|
||||
@ -1454,7 +1453,7 @@ pub fn print_decl(s: @ps, decl: @ast::decl) {
|
||||
word_nbsp(s, "mut");
|
||||
}
|
||||
|
||||
fn print_local(s: @ps, loc: @ast::local) {
|
||||
fn print_local(s: @ps, loc: &ast::local) {
|
||||
ibox(s, indent_unit);
|
||||
print_local_decl(s, loc);
|
||||
end(s);
|
||||
@ -1479,7 +1478,7 @@ pub fn print_ident(s: @ps, ident: ast::ident) {
|
||||
word(s.s, ident_to_str(&ident));
|
||||
}
|
||||
|
||||
pub fn print_for_decl(s: @ps, loc: @ast::local, coll: @ast::expr) {
|
||||
pub fn print_for_decl(s: @ps, loc: &ast::local, coll: &ast::expr) {
|
||||
print_local_decl(s, loc);
|
||||
space(s.s);
|
||||
word_space(s, "in");
|
||||
@ -1511,7 +1510,7 @@ fn print_path_(s: @ps, path: &ast::Path, colons_before_params: bool,
|
||||
}
|
||||
}
|
||||
|
||||
commasep(s, inconsistent, path.types, print_type);
|
||||
commasep(s, inconsistent, path.types, |p, &e| print_type(p, e));
|
||||
|
||||
word(s.s, ">");
|
||||
}
|
||||
@ -1527,15 +1526,15 @@ pub fn print_bounded_path(s: @ps, path: &ast::Path,
|
||||
print_path_(s, path, false, bounds)
|
||||
}
|
||||
|
||||
pub fn print_irrefutable_pat(s: @ps, pat: @ast::pat) {
|
||||
pub fn print_irrefutable_pat(s: @ps, pat: &ast::pat) {
|
||||
print_pat(s, pat, false)
|
||||
}
|
||||
|
||||
pub fn print_refutable_pat(s: @ps, pat: @ast::pat) {
|
||||
pub fn print_refutable_pat(s: @ps, pat: &ast::pat) {
|
||||
print_pat(s, pat, true)
|
||||
}
|
||||
|
||||
pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
pub fn print_pat(s: @ps, pat: &ast::pat, refutable: bool) {
|
||||
maybe_print_comment(s, pat.span.lo);
|
||||
let ann_node = node_pat(s, pat);
|
||||
(s.ann.pre)(ann_node);
|
||||
@ -1570,7 +1569,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
if !args.is_empty() {
|
||||
popen(s);
|
||||
commasep(s, inconsistent, *args,
|
||||
|s, p| print_pat(s, p, refutable));
|
||||
|s, &p| print_pat(s, p, refutable));
|
||||
pclose(s);
|
||||
} else { }
|
||||
}
|
||||
@ -1579,14 +1578,14 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
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) {
|
||||
fn print_field(s: @ps, f: &ast::field_pat, refutable: bool) {
|
||||
cbox(s, indent_unit);
|
||||
print_ident(s, f.ident);
|
||||
word_space(s, ":");
|
||||
print_pat(s, f.pat, refutable);
|
||||
end(s);
|
||||
}
|
||||
fn get_span(f: ast::field_pat) -> codemap::span { return f.pat.span; }
|
||||
fn get_span(f: &ast::field_pat) -> codemap::span { return f.pat.span; }
|
||||
commasep_cmnt(s, consistent, *fields,
|
||||
|s, f| print_field(s,f,refutable),
|
||||
get_span);
|
||||
@ -1598,7 +1597,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
}
|
||||
ast::pat_tup(ref elts) => {
|
||||
popen(s);
|
||||
commasep(s, inconsistent, *elts, |s, p| print_pat(s, p, refutable));
|
||||
commasep(s, inconsistent, *elts, |s, &p| print_pat(s, p, refutable));
|
||||
if elts.len() == 1 {
|
||||
word(s.s, ",");
|
||||
}
|
||||
@ -1625,7 +1624,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
}
|
||||
ast::pat_vec(ref before, slice, ref after) => {
|
||||
word(s.s, "[");
|
||||
do commasep(s, inconsistent, *before) |s, p| {
|
||||
do commasep(s, inconsistent, *before) |s, &p| {
|
||||
print_pat(s, p, refutable);
|
||||
}
|
||||
for slice.iter().advance |&p| {
|
||||
@ -1634,7 +1633,7 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
print_pat(s, p, refutable);
|
||||
if !after.is_empty() { word_space(s, ","); }
|
||||
}
|
||||
do commasep(s, inconsistent, *after) |s, p| {
|
||||
do commasep(s, inconsistent, *after) |s, &p| {
|
||||
print_pat(s, p, refutable);
|
||||
}
|
||||
word(s.s, "]");
|
||||
@ -1643,8 +1642,8 @@ pub fn print_pat(s: @ps, pat: @ast::pat, refutable: bool) {
|
||||
(s.ann.post)(ann_node);
|
||||
}
|
||||
|
||||
pub fn explicit_self_to_str(explicit_self: ast::explicit_self_, intr: @ident_interner) -> ~str {
|
||||
to_str(explicit_self, |a, b| { print_explicit_self(a, b); () }, intr)
|
||||
pub fn explicit_self_to_str(explicit_self: &ast::explicit_self_, intr: @ident_interner) -> ~str {
|
||||
to_str(explicit_self, |a, &b| { print_explicit_self(a, b); () }, intr)
|
||||
}
|
||||
|
||||
// Returns whether it printed anything
|
||||
@ -1748,7 +1747,7 @@ pub fn print_bounds(s: @ps, bounds: &OptVec<ast::TyParamBound>,
|
||||
}
|
||||
|
||||
match *bound {
|
||||
TraitTyParamBound(tref) => print_trait_ref(s, tref),
|
||||
TraitTyParamBound(ref tref) => print_trait_ref(s, tref),
|
||||
RegionTyParamBound => word(s.s, "'static"),
|
||||
}
|
||||
}
|
||||
@ -1784,12 +1783,12 @@ pub fn print_generics(s: @ps, generics: &ast::Generics) {
|
||||
}
|
||||
|
||||
commasep(s, inconsistent, ints,
|
||||
|s, i| print_item(s, generics, i));
|
||||
|s, &i| print_item(s, generics, i));
|
||||
word(s.s, ">");
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
|
||||
pub fn print_meta_item(s: @ps, item: &ast::meta_item) {
|
||||
ibox(s, indent_unit);
|
||||
match item.node {
|
||||
ast::meta_word(name) => word(s.s, name),
|
||||
@ -1804,8 +1803,8 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
|
||||
commasep(
|
||||
s,
|
||||
consistent,
|
||||
/* FIXME (#2543) */ copy *items,
|
||||
print_meta_item
|
||||
items.as_slice(),
|
||||
|p, &i| print_meta_item(p, i)
|
||||
);
|
||||
pclose(s);
|
||||
}
|
||||
@ -1813,7 +1812,7 @@ pub fn print_meta_item(s: @ps, item: @ast::meta_item) {
|
||||
end(s);
|
||||
}
|
||||
|
||||
pub fn print_view_path(s: @ps, vp: @ast::view_path) {
|
||||
pub fn print_view_path(s: @ps, vp: &ast::view_path) {
|
||||
match vp.node {
|
||||
ast::view_path_simple(ident, ref path, _) => {
|
||||
if path.idents[path.idents.len()-1u] != ident {
|
||||
@ -1841,7 +1840,7 @@ pub fn print_view_path(s: @ps, vp: @ast::view_path) {
|
||||
}
|
||||
|
||||
pub fn print_view_paths(s: @ps, vps: &[@ast::view_path]) {
|
||||
commasep(s, inconsistent, vps, print_view_path);
|
||||
commasep(s, inconsistent, vps, |p, &vp| print_view_path(p, vp));
|
||||
}
|
||||
|
||||
pub fn print_view_item(s: @ps, item: &ast::view_item) {
|
||||
@ -1855,7 +1854,7 @@ pub fn print_view_item(s: @ps, item: &ast::view_item) {
|
||||
print_ident(s, id);
|
||||
if !mta.is_empty() {
|
||||
popen(s);
|
||||
commasep(s, consistent, *mta, print_meta_item);
|
||||
commasep(s, consistent, *mta, |p, &i| print_meta_item(p, i));
|
||||
pclose(s);
|
||||
}
|
||||
}
|
||||
@ -2003,7 +2002,7 @@ pub fn print_remaining_comments(s: @ps) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_literal(s: @ps, lit: @ast::lit) {
|
||||
pub fn print_literal(s: @ps, lit: &ast::lit) {
|
||||
maybe_print_comment(s, lit.span.lo);
|
||||
match next_lit(s, lit.span.lo) {
|
||||
Some(ref ltrl) => {
|
||||
@ -2056,7 +2055,7 @@ pub fn print_literal(s: @ps, lit: @ast::lit) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn lit_to_str(l: @ast::lit) -> ~str {
|
||||
pub fn lit_to_str(l: &ast::lit) -> ~str {
|
||||
return to_str(l, print_literal, parse::token::mk_fake_ident_interner());
|
||||
}
|
||||
|
||||
@ -2139,10 +2138,10 @@ pub fn print_string(s: @ps, st: &str) {
|
||||
word(s.s, "\"");
|
||||
}
|
||||
|
||||
pub fn to_str<T: Copy>(t: T, f: @fn(@ps, T), intr: @ident_interner) -> ~str {
|
||||
pub fn to_str<T>(t: &T, f: &fn(@ps, &T), intr: @ident_interner) -> ~str {
|
||||
do io::with_str_writer |wr| {
|
||||
let s = rust_printer(wr, intr);
|
||||
f(s, copy t);
|
||||
f(s, t);
|
||||
eof(s.s);
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ pub fn visit_item<E: Copy>(i: &item, (e, v): (E, vt<E>)) {
|
||||
}
|
||||
item_impl(ref tps, ref traits, ty, ref methods) => {
|
||||
(v.visit_generics)(tps, (copy e, v));
|
||||
for traits.iter().advance |&p| {
|
||||
for traits.iter().advance |p| {
|
||||
visit_trait_ref(p, (copy e, v));
|
||||
}
|
||||
(v.visit_ty)(ty, (copy e, v));
|
||||
@ -336,7 +336,7 @@ pub fn visit_ty_param_bounds<E: Copy>(bounds: &OptVec<TyParamBound>,
|
||||
(e, v): (E, vt<E>)) {
|
||||
for bounds.iter().advance |bound| {
|
||||
match *bound {
|
||||
TraitTyParamBound(ty) => visit_trait_ref(ty, (copy e, v)),
|
||||
TraitTyParamBound(ref ty) => visit_trait_ref(ty, (copy e, v)),
|
||||
RegionTyParamBound => {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user