Box AST idents

This commit is contained in:
Brian Anderson 2012-06-10 00:49:59 -07:00
parent bdd2000066
commit ce750a7dbc
74 changed files with 629 additions and 603 deletions

View File

@ -224,10 +224,10 @@ fn load_link(mis: [@ast::meta_item]) -> (option<str>,
for mis.each {|a|
alt a.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"name" { name = some(s); }
"vers" { vers = some(s); }
"uuid" { uuid = some(s); }
alt *v {
"name" { name = some(*s); }
"vers" { vers = some(*s); }
"uuid" { uuid = some(*s); }
_ { }
}
}
@ -259,15 +259,15 @@ fn load_crate(filename: str) -> option<crate> {
for c.node.attrs.each {|a|
alt a.node.value.node {
ast::meta_name_value(v, {node: ast::lit_str(s), span: _}) {
alt v {
"desc" { desc = some(v); }
"sigs" { sigs = some(v); }
"crate_type" { crate_type = some(v); }
alt *v {
"desc" { desc = some(*v); }
"sigs" { sigs = some(*v); }
"crate_type" { crate_type = some(*v); }
_ { }
}
}
ast::meta_list(v, mis) {
if v == "link" {
if *v == "link" {
let (n, v, u) = load_link(mis);
name = n;
vers = v;
@ -290,7 +290,7 @@ fn load_crate(filename: str) -> option<crate> {
ast::view_item_use(ident, metas, id) {
let name_items = attr::find_meta_items_by_name(metas, "name");
let m = if name_items.is_empty() {
metas + [attr::mk_name_value_item_str("name", ident)]
metas + [attr::mk_name_value_item_str(@"name", *ident)]
} else {
metas
};
@ -303,9 +303,9 @@ fn load_crate(filename: str) -> option<crate> {
some(value) {
let name = attr::get_meta_item_name(item);
alt name {
"vers" { attr_vers = value; }
"from" { attr_from = value; }
alt *name {
"vers" { attr_vers = *value; }
"from" { attr_from = *value; }
_ {}
}
}
@ -317,11 +317,11 @@ fn load_crate(filename: str) -> option<crate> {
attr_from
} else {
if !str::is_empty(attr_vers) {
attr_name + "@" + attr_vers
} else { attr_name }
*attr_name + "@" + attr_vers
} else { *attr_name }
};
alt attr_name {
alt *attr_name {
"std" | "core" { }
_ { e.deps += [query]; }
}

View File

@ -45,7 +45,7 @@ fn common_exprs() -> [ast::expr] {
dse(ast::expr_cont),
dse(ast::expr_fail(option::none)),
dse(ast::expr_fail(option::some(
@dse(ast::expr_lit(@dsl(ast::lit_str("boo"))))))),
@dse(ast::expr_lit(@dsl(ast::lit_str(@"boo"))))))),
dse(ast::expr_ret(option::none)),
dse(ast::expr_lit(@dsl(ast::lit_nil))),
dse(ast::expr_lit(@dsl(ast::lit_bool(false)))),

View File

@ -2,6 +2,7 @@
import chained::hashmap;
export hashmap, hashfn, eqfn, set, map, chained, hashmap, str_hash;
export box_str_hash;
export bytes_hash, int_hash, uint_hash, set_add;
export hash_from_vec, hash_from_strs, hash_from_bytes;
export hash_from_ints, hash_from_uints;
@ -292,6 +293,11 @@ fn str_hash<V: copy>() -> hashmap<str, V> {
ret hashmap(str::hash, str::eq);
}
#[doc = "Construct a hashmap for boxed string keys"]
fn box_str_hash<V: copy>() -> hashmap<@str, V> {
ret hashmap({|x: @str|str::hash(*x)}, {|x,y|str::eq(*x,*y)});
}
#[doc = "Construct a hashmap for byte string keys"]
fn bytes_hash<V: copy>() -> hashmap<[u8], V> {
ret hashmap(vec::u8::hash, vec::u8::eq);

View File

@ -30,7 +30,7 @@ fn deserialize_span<D>(_d: D) -> span {
type spanned<T> = {node: T, span: span};
#[auto_serialize]
type ident = str;
type ident = @str;
// Functions may or may not have names.
#[auto_serialize]
@ -399,11 +399,11 @@ type lit = spanned<lit_>;
#[auto_serialize]
enum lit_ {
lit_str(str),
lit_str(@str),
lit_int(i64, int_ty),
lit_uint(u64, uint_ty),
lit_int_unsuffixed(i64, int_ty),
lit_float(str, float_ty),
lit_float(@str, float_ty),
lit_nil,
lit_bool(bool),
}

View File

@ -6,14 +6,14 @@ import ast_util::path_to_ident;
import ast_util::inlined_item_methods;
import diagnostic::span_handler;
enum path_elt { path_mod(str), path_name(str) }
enum path_elt { path_mod(ident), path_name(ident) }
type path = [path_elt];
fn path_to_str_with_sep(p: path, sep: str) -> str {
let strs = vec::map(p) {|e|
alt e {
path_mod(s) { /* FIXME: bad */ copy s }
path_name(s) { /* FIXME: bad */ copy s }
path_mod(s) { /* FIXME: bad */ copy *s }
path_name(s) { /* FIXME: bad */ copy *s }
}
};
str::connect(strs, sep)
@ -21,9 +21,9 @@ fn path_to_str_with_sep(p: path, sep: str) -> str {
fn path_ident_to_str(p: path, i: ident) -> str {
if vec::is_empty(p) {
/* FIXME: bad */ copy i
/* FIXME: bad */ copy *i
} else {
#fmt["%s::%s", path_to_str(p), i]
#fmt["%s::%s", path_to_str(p), *i]
}
}
@ -59,7 +59,7 @@ type ctx = {map: map, mut path: path,
mut local_id: uint, diag: span_handler};
type vt = visit::vt<ctx>;
fn extend(cx: ctx, +elt: str) -> @path {
fn extend(cx: ctx, +elt: ident) -> @path {
@(cx.path + [path_name(elt)])
}
@ -192,7 +192,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
item_impl(_, _, _, _, ms) {
let impl_did = ast_util::local_def(i.id);
for ms.each {|m|
map_method(impl_did, extend(cx, /* FIXME: bad */ copy i.ident), m,
map_method(impl_did, extend(cx, i.ident), m,
cx);
}
}
@ -208,7 +208,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
for vs.each {|v|
cx.map.insert(v.node.id, node_variant(
/* FIXME: bad */ copy v, i,
extend(cx, /* FIXME: bad */ copy i.ident)));
extend(cx, i.ident)));
}
}
item_native_mod(nm) {
@ -229,7 +229,7 @@ fn map_item(i: @item, cx: ctx, v: vt) {
vec::iter(ifces) {|p| cx.map.insert(p.id,
node_item(i, item_path)); };
let d_id = ast_util::local_def(i.id);
let p = extend(cx, /* FIXME: bad */ copy i.ident);
let p = extend(cx, i.ident);
// only need to handle methods
vec::iter(ms) {|m| map_method(d_id, p, m, cx); }
}
@ -237,9 +237,9 @@ fn map_item(i: @item, cx: ctx, v: vt) {
}
alt i.node {
item_mod(_) | item_native_mod(_) {
cx.path += [path_mod(/* FIXME: bad */ copy i.ident)];
cx.path += [path_mod(i.ident)];
}
_ { cx.path += [path_name(/* FIXME: bad */ copy i.ident)]; }
_ { cx.path += [path_name(i.ident)]; }
}
visit::visit_item(i, cx, v);
vec::pop(cx.path);
@ -281,11 +281,11 @@ fn node_id_to_str(map: map, id: node_id) -> str {
}
some(node_method(m, impl_did, path)) {
#fmt["method %s in %s (id=%?)",
m.ident, path_to_str(*path), id]
*m.ident, path_to_str(*path), id]
}
some(node_variant(variant, def_id, path)) {
#fmt["variant %s in %s (id=%?)",
variant.node.name, path_to_str(*path), id]
*variant.node.name, path_to_str(*path), id]
}
some(node_expr(expr)) {
#fmt["expr %s (id=%?)",

View File

@ -23,7 +23,10 @@ pure fn dummy_sp() -> span { ret mk_sp(0u, 0u); }
pure fn path_name(p: @path) -> str { path_name_i(p.idents) }
pure fn path_name_i(idents: [ident]) -> str { str::connect(idents, "::") }
pure fn path_name_i(idents: [ident]) -> str {
// FIXME: Bad copies
str::connect(idents.map({|i|*i}), "::")
}
pure fn path_to_ident(p: @path) -> ident { vec::last(p.idents) }
@ -380,7 +383,7 @@ fn dtor_dec() -> fn_decl {
let nil_t = @{id: 0, node: ty_nil, span: dummy_sp()};
// dtor has one argument, of type ()
{inputs: [{mode: ast::expl(ast::by_ref),
ty: nil_t, ident: "_", id: 0}],
ty: nil_t, ident: @"_", id: 0}],
output: nil_t, purity: impure_fn, cf: return_val, constraints: []}
}

View File

@ -47,7 +47,7 @@ export require_unique_names;
/* Constructors */
fn mk_name_value_item_str(+name: ast::ident, +value: str) -> @ast::meta_item {
let value_lit = dummy_spanned(ast::lit_str(value));
let value_lit = dummy_spanned(ast::lit_str(@value));
ret mk_name_value_item(name, value_lit);
}
@ -100,12 +100,12 @@ fn get_meta_item_name(meta: @ast::meta_item) -> ast::ident {
Gets the string value if the meta_item is a meta_name_value variant
containing a string, otherwise none
"]
fn get_meta_item_value_str(meta: @ast::meta_item) -> option<str> {
fn get_meta_item_value_str(meta: @ast::meta_item) -> option<@str> {
alt meta.node {
ast::meta_name_value(_, v) {
alt v.node {
ast::lit_str(s) {
option::some(/* FIXME bad */ copy s)
option::some(s)
}
_ {
option::none
@ -130,11 +130,11 @@ a tuple containing the name and string value, otherwise `none`
"]
fn get_name_value_str_pair(
item: @ast::meta_item
) -> option<(str, str)> {
) -> option<(ast::ident, @str)> {
alt attr::get_meta_item_value_str(item) {
some(value) {
let name = attr::get_meta_item_name(item);
some((name, /* FIXME bad */ copy value))
some((name, value))
}
none { none }
}
@ -146,11 +146,11 @@ fn get_name_value_str_pair(
#[doc = "
Search a list of attributes and return only those with a specific name
"]
fn find_attrs_by_name(attrs: [ast::attribute], +name: ast::ident) ->
fn find_attrs_by_name(attrs: [ast::attribute], +name: str) ->
[ast::attribute] {
let filter = (
fn@(a: ast::attribute) -> option<ast::attribute> {
if get_attr_name(a) == name {
if *get_attr_name(a) == name {
option::some(a)
} else { option::none }
}
@ -161,10 +161,10 @@ fn find_attrs_by_name(attrs: [ast::attribute], +name: ast::ident) ->
#[doc = "
Searcha list of meta items and return only those with a specific name
"]
fn find_meta_items_by_name(metas: [@ast::meta_item], +name: ast::ident) ->
fn find_meta_items_by_name(metas: [@ast::meta_item], +name: str) ->
[@ast::meta_item] {
let filter = fn@(&&m: @ast::meta_item) -> option<@ast::meta_item> {
if get_meta_item_name(m) == name {
if *get_meta_item_name(m) == name {
option::some(m)
} else { option::none }
};
@ -209,17 +209,17 @@ fn eq(a: @ast::meta_item, b: @ast::meta_item) -> bool {
}
}
fn contains_name(metas: [@ast::meta_item], +name: ast::ident) -> bool {
fn contains_name(metas: [@ast::meta_item], +name: str) -> bool {
let matches = find_meta_items_by_name(metas, name);
ret vec::len(matches) > 0u;
}
fn attrs_contains_name(attrs: [ast::attribute], +name: ast::ident) -> bool {
fn attrs_contains_name(attrs: [ast::attribute], +name: str) -> bool {
vec::is_not_empty(find_attrs_by_name(attrs, name))
}
fn first_attr_value_str_by_name(attrs: [ast::attribute], +name: ast::ident)
-> option<str> {
fn first_attr_value_str_by_name(attrs: [ast::attribute], +name: str)
-> option<@str> {
let mattrs = find_attrs_by_name(attrs, name);
if vec::len(mattrs) > 0u {
ret get_meta_item_value_str(attr_meta(mattrs[0]));
@ -238,11 +238,11 @@ fn last_meta_item_by_name(
fn last_meta_item_value_str_by_name(
items: [@ast::meta_item],
+name: str
) -> option<str> {
) -> option<@str> {
alt last_meta_item_by_name(items, name) {
some(item) {
alt attr::get_meta_item_value_str(item) {
some(value) { some(/* FIXME bad */ copy value) }
some(value) { some(value) }
none { none }
}
}
@ -285,7 +285,7 @@ fn sort_meta_items(+items: [@ast::meta_item]) -> [@ast::meta_item] {
ret vec::from_mut(v);
}
fn remove_meta_items_by_name(items: [@ast::meta_item], name: str) ->
fn remove_meta_items_by_name(items: [@ast::meta_item], name: ast::ident) ->
[@ast::meta_item] {
ret vec::filter_map(items, {
@ -326,17 +326,17 @@ fn native_abi(attrs: [ast::attribute]) -> either<str, ast::native_abi> {
option::none {
either::right(ast::native_abi_cdecl)
}
option::some("rust-intrinsic") {
option::some(@"rust-intrinsic") {
either::right(ast::native_abi_rust_intrinsic)
}
option::some("cdecl") {
option::some(@"cdecl") {
either::right(ast::native_abi_cdecl)
}
option::some("stdcall") {
option::some(@"stdcall") {
either::right(ast::native_abi_stdcall)
}
option::some(t) {
either::left("unsupported abi: " + t)
either::left("unsupported abi: " + *t)
}
};
}
@ -352,8 +352,8 @@ fn find_inline_attr(attrs: [ast::attribute]) -> inline_attr {
// TODO---validate the usage of #[inline] and #[inline(always)]
vec::foldl(ia_none, attrs) {|ia,attr|
alt attr.node.value.node {
ast::meta_word("inline") { ia_hint }
ast::meta_list("inline", items) {
ast::meta_word(@"inline") { ia_hint }
ast::meta_list(@"inline", items) {
if !vec::is_empty(find_meta_items_by_name(items, "always")) {
ia_always
} else {
@ -373,11 +373,11 @@ fn require_unique_names(diagnostic: span_handler,
let name = get_meta_item_name(meta);
// FIXME: How do I silence the warnings? --pcw
if map.contains_key(name) {
if map.contains_key(*name) {
diagnostic.span_fatal(meta.span,
#fmt["duplicate meta item `%s`", name]);
#fmt["duplicate meta item `%s`", *name]);
}
map.insert(name, ());
map.insert(*name, ());
}
}

View File

@ -92,7 +92,7 @@ fn expand(cx: ext_ctxt,
_mitem: ast::meta_item,
in_items: [@ast::item]) -> [@ast::item] {
fn not_auto_serialize(a: ast::attribute) -> bool {
attr::get_attr_name(a) != "auto_serialize"
attr::get_attr_name(a) != @"auto_serialize"
}
fn filter_attrs(item: @ast::item) -> @ast::item {
@ -126,18 +126,19 @@ impl helpers for ext_ctxt {
helper_name: str) -> @ast::path {
let head = vec::init(base_path.idents);
let tail = vec::last(base_path.idents);
self.path(base_path.span, head + [helper_name + "_" + tail])
self.path(base_path.span, head + [@(helper_name + "_" + *tail)])
}
fn path(span: span, strs: [str]) -> @ast::path {
fn path(span: span, strs: [ast::ident]) -> @ast::path {
@{span: span, global: false, idents: strs, rp: none, types: []}
}
fn path_tps(span: span, strs: [str], tps: [@ast::ty]) -> @ast::path {
fn path_tps(span: span, strs: [ast::ident],
tps: [@ast::ty]) -> @ast::path {
@{span: span, global: false, idents: strs, rp: none, types: tps}
}
fn ty_path(span: span, strs: [str], tps: [@ast::ty]) -> @ast::ty {
fn ty_path(span: span, strs: [ast::ident], tps: [@ast::ty]) -> @ast::ty {
@{id: self.next_id(),
node: ast::ty_path(self.path_tps(span, strs, tps), self.next_id()),
span: span}
@ -149,7 +150,7 @@ impl helpers for ext_ctxt {
let args = vec::map(input_tys) {|ty|
{mode: ast::expl(ast::by_ref),
ty: ty,
ident: "",
ident: @"",
id: self.next_id()}
};
@ -170,7 +171,7 @@ impl helpers for ext_ctxt {
@{id: self.next_id(), node: node, span: span}
}
fn var_ref(span: span, name: str) -> @ast::expr {
fn var_ref(span: span, name: ast::ident) -> @ast::expr {
self.expr(span, ast::expr_path(self.path(span, [name])))
}
@ -192,7 +193,7 @@ impl helpers for ext_ctxt {
span: expr.span}
}
fn binder_pat(span: span, nm: str) -> @ast::pat {
fn binder_pat(span: span, nm: ast::ident) -> @ast::pat {
let path = @{span: span, global: false, idents: [nm],
rp: none, types: []};
@{id: self.next_id(),
@ -212,7 +213,7 @@ impl helpers for ext_ctxt {
ast::expr_alt(v, arms, ast::alt_exhaustive)))
}
fn lit_str(span: span, s: str) -> @ast::expr {
fn lit_str(span: span, s: @str) -> @ast::expr {
self.expr(
span,
ast::expr_lit(
@ -310,7 +311,7 @@ fn ser_variant(cx: ext_ctxt,
bodyfn: fn(-@ast::expr, ast::blk) -> @ast::expr,
argfn: fn(-@ast::expr, uint, ast::blk) -> @ast::expr)
-> ast::arm {
let vnames = vec::from_fn(vec::len(tys)) {|i| #fmt["__v%u", i]};
let vnames = vec::from_fn(vec::len(tys)) {|i| @#fmt["__v%u", i]};
let pats = vec::from_fn(vec::len(tys)) {|i|
cx.binder_pat(tys[i].span, vnames[i])
};
@ -428,7 +429,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
vec::is_empty(path.types) {
let ident = path.idents[0];
alt tps.find(ident) {
alt tps.find(*ident) {
some(f) { f(v) }
none { ser_path(cx, tps, path, s, v) }
}
@ -474,7 +475,7 @@ fn ser_ty(cx: ext_ctxt, tps: ser_tps_map,
}
}
fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
fn mk_ser_fn(cx: ext_ctxt, span: span, name: ast::ident, tps: [ast::ty_param],
f: fn(ext_ctxt, ser_tps_map,
-@ast::expr, -@ast::expr) -> [@ast::stmt])
-> @ast::item {
@ -489,7 +490,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
ty: cx.ty_fn(span,
[cx.ty_path(span, [tp.ident], [])],
cx.ty_nil(span)),
ident: "__s" + tp.ident,
ident: @("__s" + *tp.ident),
id: cx.next_id()}});
#debug["tp_inputs = %?", tp_inputs];
@ -497,12 +498,12 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let ser_inputs: [ast::arg] =
[{mode: ast::expl(ast::by_ref),
ty: cx.ty_path(span, ["__S"], []),
ident: "__s",
ty: cx.ty_path(span, [@"__S"], []),
ident: @"__s",
id: cx.next_id()},
{mode: ast::expl(ast::by_ref),
ty: v_ty,
ident: "__v",
ident: @"__v",
id: cx.next_id()}]
+ tp_inputs;
@ -510,21 +511,21 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident;
tps_map.insert(
tp.ident,
*tp.ident,
fn@(v: @ast::expr) -> [@ast::stmt] {
let f = cx.var_ref(span, arg_ident);
#debug["serializing type arg %s", arg_ident];
#debug["serializing type arg %s", *arg_ident];
[#ast(stmt){$(f)($(v));}]
});
}
let ser_bnds = @[
ast::bound_iface(cx.ty_path(span,
["std", "serialization", "serializer"],
[@"std", @"serialization", @"serializer"],
[]))];
let ser_tps: [ast::ty_param] =
[{ident: "__S",
[{ident: @"__S",
id: cx.next_id(),
bounds: ser_bnds}] +
vec::map(tps) {|tp| cx.clone_ty_param(tp) };
@ -536,7 +537,7 @@ fn mk_ser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let ser_blk = cx.blk(span,
f(cx, tps_map, #ast{ __s }, #ast{ __v }));
@{ident: "serialize_" + name,
@{ident: @("serialize_" + *name),
attrs: [],
id: cx.next_id(),
node: ast::item_fn({inputs: ser_inputs,
@ -651,7 +652,7 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
vec::is_empty(path.types) {
let ident = path.idents[0];
alt tps.find(ident) {
alt tps.find(*ident) {
some(f) { f() }
none { deser_path(cx, tps, path, d) }
}
@ -683,7 +684,8 @@ fn deser_ty(cx: ext_ctxt, tps: deser_tps_map,
}
}
fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
fn mk_deser_fn(cx: ext_ctxt, span: span,
name: ast::ident, tps: [ast::ty_param],
f: fn(ext_ctxt, deser_tps_map, -@ast::expr) -> @ast::expr)
-> @ast::item {
let ext_cx = cx; // required for #ast
@ -697,15 +699,15 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
ty: cx.ty_fn(span,
[],
cx.ty_path(span, [tp.ident], [])),
ident: "__d" + tp.ident,
ident: @("__d" + *tp.ident),
id: cx.next_id()}});
#debug["tp_inputs = %?", tp_inputs];
let deser_inputs: [ast::arg] =
[{mode: ast::expl(ast::by_ref),
ty: cx.ty_path(span, ["__D"], []),
ident: "__d",
ty: cx.ty_path(span, [@"__D"], []),
ident: @"__d",
id: cx.next_id()}]
+ tp_inputs;
@ -713,7 +715,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
vec::iter2(tps, tp_inputs) {|tp, arg|
let arg_ident = arg.ident;
tps_map.insert(
tp.ident,
*tp.ident,
fn@() -> @ast::expr {
let f = cx.var_ref(span, arg_ident);
#ast{ $(f)() }
@ -721,12 +723,13 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
}
let deser_bnds = @[
ast::bound_iface(cx.ty_path(span,
["std", "serialization", "deserializer"],
[]))];
ast::bound_iface(cx.ty_path(
span,
[@"std", @"serialization", @"deserializer"],
[]))];
let deser_tps: [ast::ty_param] =
[{ident: "__D",
[{ident: @"__D",
id: cx.next_id(),
bounds: deser_bnds}] + vec::map(tps) {|tp|
let cloned = cx.clone_ty_param(tp);
@ -735,7 +738,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
let deser_blk = cx.expr_blk(f(cx, tps_map, #ast(expr){__d}));
@{ident: "deserialize_" + name,
@{ident: @("deserialize_" + *name),
attrs: [],
id: cx.next_id(),
node: ast::item_fn({inputs: deser_inputs,
@ -749,7 +752,7 @@ fn mk_deser_fn(cx: ext_ctxt, span: span, name: str, tps: [ast::ty_param],
span: span}
}
fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param])
fn ty_fns(cx: ext_ctxt, name: ast::ident, ty: @ast::ty, tps: [ast::ty_param])
-> [@ast::item] {
let span = ty.span;
@ -759,7 +762,7 @@ fn ty_fns(cx: ext_ctxt, name: str, ty: @ast::ty, tps: [ast::ty_param])
]
}
fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str,
fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: ast::ident,
e_span: span, variants: [ast::variant],
-s: @ast::expr, -v: @ast::expr) -> [@ast::stmt] {
let ext_cx = cx;
@ -808,7 +811,7 @@ fn ser_enum(cx: ext_ctxt, tps: ser_tps_map, e_name: str,
[#ast(stmt){ $(s).emit_enum($(e_name), $(lam)) }]
}
fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str,
fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: ast::ident,
e_span: span, variants: [ast::variant],
-d: @ast::expr) -> @ast::expr {
let ext_cx = cx;
@ -852,7 +855,7 @@ fn deser_enum(cx: ext_ctxt, tps: deser_tps_map, e_name: str,
#ast{ $(d).read_enum($(e_name), $(read_lambda)) }
}
fn enum_fns(cx: ext_ctxt, e_name: str, e_span: span,
fn enum_fns(cx: ext_ctxt, e_name: ast::ident, e_span: span,
variants: [ast::variant], tps: [ast::ty_param])
-> [@ast::item] {
[

View File

@ -9,7 +9,7 @@ type syntax_expander_ =
type syntax_expander = {
expander: syntax_expander_,
span: option<span>};
type macro_def = {ident: str, ext: syntax_extension};
type macro_def = {ident: ast::ident, ext: syntax_extension};
type macro_definer =
fn@(ext_ctxt, span, ast::mac_arg, ast::mac_body) -> macro_def;
type item_decorator =
@ -150,7 +150,7 @@ fn expr_to_str(cx: ext_ctxt, expr: @ast::expr, error: str) -> str {
alt expr.node {
ast::expr_lit(l) {
alt l.node {
ast::lit_str(s) { ret s; }
ast::lit_str(s) { ret *s; }
_ { cx.span_fatal(l.span, error); }
}
}

View File

@ -6,7 +6,7 @@ fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
}
fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr {
let lit = ast::lit_str(s);
let lit = ast::lit_str(@s);
ret mk_lit(cx, sp, lit);
}
fn mk_int(cx: ext_ctxt, sp: span, i: int) -> @ast::expr {

View File

@ -3,13 +3,13 @@ import base::*;
fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr {
let args = get_mac_args_no_max(cx,sp,arg,1u,"concat_idents");
let mut res: ast::ident = "";
let mut res = "";
for args.each {|e|
res += expr_to_ident(cx, e, "expected an ident");
res += *expr_to_ident(cx, e, "expected an ident");
}
ret @{id: cx.next_id(),
node: ast::expr_path(@{span: sp, global: false, idents: [res],
node: ast::expr_path(@{span: sp, global: false, idents: [@res],
rp: none, types: []}),
span: sp};
}

View File

@ -21,8 +21,8 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
}
}
fn make_new_str(cx: ext_ctxt, sp: codemap::span, s: str) -> @ast::expr {
ret make_new_lit(cx, sp, ast::lit_str(s));
fn make_new_str(cx: ext_ctxt, sp: codemap::span, +s: str) -> @ast::expr {
ret make_new_lit(cx, sp, ast::lit_str(@s));
}
//
// Local Variables:

View File

@ -21,21 +21,21 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
mac_invoc(pth, args, body) {
assert (vec::len(pth.idents) > 0u);
let extname = pth.idents[0];
alt exts.find(extname) {
alt exts.find(*extname) {
none {
cx.span_fatal(pth.span,
#fmt["macro undefined: '%s'", extname])
#fmt["macro undefined: '%s'", *extname])
}
some(item_decorator(_)) {
cx.span_fatal(
pth.span,
#fmt["%s can only be used as a decorator", extname]);
#fmt["%s can only be used as a decorator", *extname]);
}
some(normal({expander: exp, span: exp_sp})) {
let expanded = exp(cx, pth.span, args, body);
cx.bt_push(expanded_from({call_site: s,
callie: {name: extname, span: exp_sp}}));
callie: {name: *extname, span: exp_sp}}));
//keep going, outside-in
let fully_expanded = fld.fold_expr(expanded).node;
cx.bt_pop();
@ -44,7 +44,7 @@ fn expand_expr(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
}
some(macro_defining(ext)) {
let named_extension = ext(cx, pth.span, args, body);
exts.insert(named_extension.ident, named_extension.ext);
exts.insert(*named_extension.ident, named_extension.ext);
(ast::expr_rec([], none), s)
}
}
@ -74,7 +74,7 @@ fn expand_mod_items(exts: hashmap<str, syntax_extension>, cx: ext_ctxt,
ast::meta_name_value(n, _) { n }
ast::meta_list(n, _) { n }
};
alt exts.find(mname) {
alt exts.find(*mname) {
none | some(normal(_)) | some(macro_defining(_)) {
items
}

View File

@ -36,9 +36,10 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
-> @ast::expr {
fn make_path_vec(_cx: ext_ctxt, ident: ast::ident) -> [ast::ident] {
ret ["extfmt", "rt", ident];
ret [@"extfmt", @"rt", ident];
}
fn make_rt_path_expr(cx: ext_ctxt, sp: span, ident: str) -> @ast::expr {
fn make_rt_path_expr(cx: ext_ctxt, sp: span,
ident: ast::ident) -> @ast::expr {
let path = make_path_vec(cx, ident);
ret mk_path(cx, sp, path);
}
@ -57,18 +58,18 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
flag_sign_always { fstr = "flag_sign_always"; }
flag_alternate { fstr = "flag_alternate"; }
}
flagexprs += [make_rt_path_expr(cx, sp, fstr)];
flagexprs += [make_rt_path_expr(cx, sp, @fstr)];
}
ret mk_vec_e(cx, sp, flagexprs);
}
fn make_count(cx: ext_ctxt, sp: span, cnt: count) -> @ast::expr {
alt cnt {
count_implied {
ret make_rt_path_expr(cx, sp, "count_implied");
ret make_rt_path_expr(cx, sp, @"count_implied");
}
count_is(c) {
let count_lit = mk_int(cx, sp, c);
let count_is_path = make_path_vec(cx, "count_is");
let count_is_path = make_path_vec(cx, @"count_is");
let count_is_args = [count_lit];
ret mk_call(cx, sp, count_is_path, count_is_args);
}
@ -88,16 +89,16 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
ty_octal { rt_type = "ty_octal"; }
_ { rt_type = "ty_default"; }
}
ret make_rt_path_expr(cx, sp, rt_type);
ret make_rt_path_expr(cx, sp, @rt_type);
}
fn make_conv_rec(cx: ext_ctxt, sp: span, flags_expr: @ast::expr,
width_expr: @ast::expr, precision_expr: @ast::expr,
ty_expr: @ast::expr) -> @ast::expr {
ret mk_rec_e(cx, sp,
[{ident: "flags", ex: flags_expr},
{ident: "width", ex: width_expr},
{ident: "precision", ex: precision_expr},
{ident: "ty", ex: ty_expr}]);
[{ident: @"flags", ex: flags_expr},
{ident: @"width", ex: width_expr},
{ident: @"precision", ex: precision_expr},
{ident: @"ty", ex: ty_expr}]);
}
let rt_conv_flags = make_flags(cx, sp, cnv.flags);
let rt_conv_width = make_count(cx, sp, cnv.width);
@ -109,7 +110,7 @@ fn pieces_to_expr(cx: ext_ctxt, sp: span, pieces: [piece], args: [@ast::expr])
fn make_conv_call(cx: ext_ctxt, sp: span, conv_type: str, cnv: conv,
arg: @ast::expr) -> @ast::expr {
let fname = "conv_" + conv_type;
let path = make_path_vec(cx, fname);
let path = make_path_vec(cx, @fname);
let cnv_expr = make_rt_conv_expr(cx, sp, cnv);
let args = [cnv_expr, arg];
ret mk_call(cx, arg.span, path, args);

View File

@ -35,7 +35,7 @@ impl of qq_helper for @ast::crate {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_crate(*self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_crate"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_crate"])
}
fn get_fold_fn() -> str {"fold_crate"}
}
@ -49,7 +49,7 @@ impl of qq_helper for @ast::expr {
}
}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_expr"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_expr"])
}
fn get_fold_fn() -> str {"fold_expr"}
}
@ -63,7 +63,7 @@ impl of qq_helper for @ast::ty {
}
}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_ty"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_ty"])
}
fn get_fold_fn() -> str {"fold_ty"}
}
@ -72,7 +72,7 @@ impl of qq_helper for @ast::item {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_item(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_item"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_item"])
}
fn get_fold_fn() -> str {"fold_item"}
}
@ -81,7 +81,7 @@ impl of qq_helper for @ast::stmt {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_stmt(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_stmt"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_stmt"])
}
fn get_fold_fn() -> str {"fold_stmt"}
}
@ -90,7 +90,7 @@ impl of qq_helper for @ast::pat {
fn visit(cx: aq_ctxt, v: vt<aq_ctxt>) {visit_pat(self, cx, v);}
fn extract_mac() -> option<ast::mac_> {fail}
fn mk_parse_fn(cx: ext_ctxt, sp: span) -> @ast::expr {
mk_path(cx, sp, ["syntax", "ext", "qquote", "parse_pat"])
mk_path(cx, sp, [@"syntax", @"ext", @"qquote", @"parse_pat"])
}
fn get_fold_fn() -> str {"fold_pat"}
}
@ -146,7 +146,7 @@ fn expand_ast(ecx: ext_ctxt, _sp: span,
}
alt (args[0].node) {
ast::expr_path(@{idents: id, _}) if vec::len(id) == 1u
{what = id[0]}
{what = *id[0]}
_ {ecx.span_fatal(args[0].span, "expected an identifier");}
}
}
@ -230,20 +230,21 @@ fn finish<T: qq_helper>
let cx = ecx;
let cfg_call = {||
mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "cfg"), [])
mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"cfg"), [])
};
let parse_sess_call = {||
mk_call_(cx, sp, mk_access(cx, sp, ["ext_cx"], "parse_sess"), [])
mk_call_(cx, sp, mk_access(cx, sp, [@"ext_cx"], @"parse_sess"), [])
};
let pcall = mk_call(cx,sp,
["syntax", "parse", "parser",
"parse_from_source_str"],
[@"syntax", @"parse", @"parser",
@"parse_from_source_str"],
[node.mk_parse_fn(cx,sp),
mk_str(cx,sp, fname),
mk_call(cx,sp,
["syntax","ext","qquote", "mk_file_substr"],
[@"syntax",@"ext",
@"qquote", @"mk_file_substr"],
[mk_str(cx,sp, loc.file.name),
mk_uint(cx,sp, loc.line),
mk_uint(cx,sp, loc.col)]),
@ -255,15 +256,16 @@ fn finish<T: qq_helper>
let mut rcall = pcall;
if (g_len > 0u) {
rcall = mk_call(cx,sp,
["syntax", "ext", "qquote", "replace"],
[@"syntax", @"ext", @"qquote", @"replace"],
[pcall,
mk_vec_e(cx,sp, qcx.gather.map_to_vec {|g|
mk_call(cx,sp,
["syntax", "ext", "qquote", g.constr],
[@"syntax", @"ext",
@"qquote", @g.constr],
[g.e])}),
mk_path(cx,sp,
["syntax", "ext", "qquote",
node.get_fold_fn()])]);
[@"syntax", @"ext", @"qquote",
@node.get_fold_fn()])]);
}
ret rcall;
}

View File

@ -1,5 +1,5 @@
import codemap::span;
import std::map::{hashmap, str_hash};
import std::map::{hashmap, str_hash, box_str_hash};
import dvec::{dvec, extensions};
import base::*;
@ -146,7 +146,7 @@ fn acumm_bindings(_cx: ext_ctxt, _b_dest: bindings, _b_src: bindings) { }
fn pattern_to_selectors(cx: ext_ctxt, e: @expr) -> binders {
let res: binders =
{real_binders: str_hash::<selector>(),
{real_binders: box_str_hash::<selector>(),
literal_ast_matchers: dvec()};
//this oughta return binders instead, but macro args are a sequence of
//expressions, rather than a single expression
@ -162,7 +162,7 @@ bindings. Most of the work is done in p_t_s, which generates the
selectors. */
fn use_selectors_to_bind(b: binders, e: @expr) -> option<bindings> {
let res = str_hash::<arb_depth<matchable>>();
let res = box_str_hash::<arb_depth<matchable>>();
//need to do this first, to check vec lengths.
for b.literal_ast_matchers.each {|sel|
alt sel(match_expr(e)) { none { ret none; } _ { } }
@ -240,7 +240,7 @@ fn follow_for_trans(cx: ext_ctxt, mmaybe: option<arb_depth<matchable>>,
/* helper for transcribe_exprs: what vars from `b` occur in `e`? */
fn free_vars(b: bindings, e: @expr, it: fn(ident)) {
let idents: hashmap<ident, ()> = str_hash::<()>();
let idents: hashmap<ident, ()> = box_str_hash::<()>();
fn mark_ident(&&i: ident, _fld: ast_fold, b: bindings,
idents: hashmap<ident, ()>) -> ident {
if b.contains_key(i) { idents.insert(i, ()); }
@ -282,8 +282,8 @@ fn transcribe_exprs(cx: ext_ctxt, b: bindings, idx_path: @mut [uint],
let len = vec::len(*ms);
if old_len != len {
let msg =
#fmt["'%s' occurs %u times, but ", fv, len] +
#fmt["'%s' occurs %u times", old_name,
#fmt["'%s' occurs %u times, but ", *fv, len] +
#fmt["'%s' occurs %u times", *old_name,
old_len];
cx.span_fatal(repeat_me.span, msg);
}
@ -672,7 +672,7 @@ fn add_new_extension(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> base::macro_def {
let args = get_mac_args_no_max(cx, sp, arg, 0u, "macro");
let mut macro_name: option<str> = none;
let mut macro_name: option<@str> = none;
let mut clauses: [@clause] = [];
for args.each {|arg|
alt arg.node {

View File

@ -36,19 +36,20 @@ fn expand_file(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
get_mac_args(cx, sp, arg, 0u, option::some(0u), "file");
let { file: @{ name: filename, _ }, _ } =
codemap::lookup_char_pos(cx.codemap(), sp.lo);
ret make_new_lit(cx, sp, ast::lit_str(filename));
ret make_new_lit(cx, sp, ast::lit_str(@filename));
}
fn expand_stringify(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
_body: ast::mac_body) -> @ast::expr {
let args = get_mac_args(cx, sp, arg, 1u, option::some(1u), "stringify");
ret make_new_lit(cx, sp, ast::lit_str(pprust::expr_to_str(args[0])));
ret make_new_lit(cx, sp, ast::lit_str(@pprust::expr_to_str(args[0])));
}
fn expand_mod(cx: ext_ctxt, sp: span, arg: ast::mac_arg, _body: ast::mac_body)
-> @ast::expr {
get_mac_args(cx, sp, arg, 0u, option::some(0u), "file");
ret make_new_lit(cx, sp, ast::lit_str(str::connect(cx.mod_path(), "::")));
ret make_new_lit(cx, sp, ast::lit_str(
@str::connect(cx.mod_path().map({|x|*x}), "::")));
}
fn expand_include(cx: ext_ctxt, sp: span, arg: ast::mac_arg,
@ -75,7 +76,7 @@ fn expand_include_str(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
}
}
ret make_new_lit(cx, sp, ast::lit_str(result::unwrap(res)));
ret make_new_lit(cx, sp, ast::lit_str(@result::unwrap(res)));
}
fn expand_include_bin(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,

View File

@ -81,7 +81,7 @@ impl parser_common for parser {
fn token_is_keyword(word: str, ++tok: token::token) -> bool {
self.require_keyword(word);
alt tok {
token::IDENT(sid, false) { str::eq(word, self.get_str(sid)) }
token::IDENT(sid, false) { str::eq(word, *self.get_str(sid)) }
_ { false }
}
}
@ -97,7 +97,7 @@ impl parser_common for parser {
// workaround LLVM bug #13042
alt @self.token {
@token::IDENT(sid, false) {
if str::eq(word, self.get_str(sid)) {
if str::eq(word, *self.get_str(sid)) {
self.bump();
ret true;
} else { ret false; }
@ -128,7 +128,7 @@ impl parser_common for parser {
}
}
fn check_restricted_keywords_(w: ast::ident) {
fn check_restricted_keywords_(w: str) {
if self.is_restricted_keyword(w) {
self.fatal("found `" + w + "` in restricted position");
}

View File

@ -75,7 +75,7 @@ fn parse_companion_mod(cx: ctx, prefix: str, suffix: option<str>)
}
}
fn cdir_path_opt(id: str, attrs: [ast::attribute]) -> str {
fn cdir_path_opt(id: ast::ident, attrs: [ast::attribute]) -> @str {
alt ::attr::first_attr_value_str_by_name(attrs, "path") {
some(d) {
ret d;
@ -89,11 +89,11 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
&items: [@ast::item]) {
alt cdir.node {
ast::cdir_src_mod(id, attrs) {
let file_path = cdir_path_opt(id + ".rs", attrs);
let file_path = cdir_path_opt(@(*id + ".rs"), attrs);
let full_path =
if path::path_is_absolute(file_path) {
file_path
} else { prefix + path::path_sep() + file_path };
if path::path_is_absolute(*file_path) {
*file_path
} else { prefix + path::path_sep() + *file_path };
let p0 =
new_parser_from_file(cx.sess, cx.cfg, full_path, SOURCE_FILE);
let inner_attrs = p0.parse_inner_attrs_and_next();
@ -112,9 +112,9 @@ fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: str,
ast::cdir_dir_mod(id, cdirs, attrs) {
let path = cdir_path_opt(id, attrs);
let full_path =
if path::path_is_absolute(path) {
path
} else { prefix + path::path_sep() + path };
if path::path_is_absolute(*path) {
*path
} else { prefix + path::path_sep() + *path };
let (m0, a0) = eval_crate_directives_to_mod(
cx, cdirs, full_path, none);
let i =

View File

@ -151,8 +151,8 @@ class parser {
fn warn(m: str) {
self.sess.span_diagnostic.span_warn(copy self.span, m)
}
fn get_str(i: token::str_num) -> str {
*interner::get(*self.reader.interner, i)
fn get_str(i: token::str_num) -> @str {
interner::get(*self.reader.interner, i)
}
fn get_id() -> node_id { next_node_id(self.sess) }
@ -178,7 +178,7 @@ class parser {
let name = self.parse_value_ident();
p.bump();
name
} else { "" };
} else { @"" };
{mode: mode, ty: p.parse_ty(false), ident: name,
id: p.get_id()}
@ -229,7 +229,7 @@ class parser {
fn ident_index(args: [arg], i: ident) -> uint {
let mut j = 0u;
for args.each {|a| if a.ident == i { ret j; } j += 1u; }
self.fatal("unbound variable `" + i + "` in constraint arg");
self.fatal("unbound variable `" + *i + "` in constraint arg");
}
fn parse_type_constr_arg() -> @ty_constr_arg {
@ -315,7 +315,7 @@ class parser {
}
}
fn region_from_name(s: option<str>) -> @region {
fn region_from_name(s: option<@str>) -> @region {
let r = alt s {
some (string) { re_named(string) }
none { re_anon }
@ -1858,13 +1858,13 @@ class parser {
fn parse_method_name() -> ident {
alt copy self.token {
token::BINOP(op) { self.bump(); token::binop_to_str(op) }
token::NOT { self.bump(); "!" }
token::LBRACKET { self.bump(); self.expect(token::RBRACKET); "[]" }
token::BINOP(op) { self.bump(); @token::binop_to_str(op) }
token::NOT { self.bump(); @"!" }
token::LBRACKET { self.bump(); self.expect(token::RBRACKET); @"[]" }
_ {
let id = self.parse_value_ident();
if id == "unary" && self.eat(token::BINOP(token::MINUS)) {
"unary-"
if id == @"unary" && self.eat(token::BINOP(token::MINUS)) {
@"unary-"
}
else { id }
}
@ -1969,7 +1969,7 @@ class parser {
// Hack. But then, this whole function is in service of a hack.
let a_r = alt rp {
rp_none { none }
rp_self { some(self.region_from_name(some("self"))) }
rp_self { some(self.region_from_name(some(@"self"))) }
};
@{span: s, global: false, idents: [i],
@ -2243,7 +2243,7 @@ class parser {
let mut variants: [variant] = [];
// Newtype syntax
if self.token == token::EQ {
self.check_restricted_keywords_(id);
self.check_restricted_keywords_(*id);
self.bump();
let ty = self.parse_ty(false);
self.expect(token::SEMI);
@ -2381,7 +2381,7 @@ class parser {
let lo = self.span.lo;
let first_ident = self.parse_ident();
let mut path = [first_ident];
#debug("parsed view_path: %s", first_ident);
#debug("parsed view_path: %s", *first_ident);
alt self.token {
token::EQ {
// x = foo::bar
@ -2504,7 +2504,7 @@ class parser {
config: self.cfg});
}
fn parse_str() -> str {
fn parse_str() -> @str {
alt copy self.token {
token::LIT_STR(s) { self.bump(); self.get_str(s) }
_ {

View File

@ -342,7 +342,7 @@ fn print_region(s: ps, region: @ast::region) {
ast::re_anon { word_space(s, "&"); }
ast::re_named(name) {
word(s.s, "&");
word_space(s, name);
word_space(s, *name);
}
}
}
@ -382,7 +382,7 @@ fn print_type_ex(s: ps, &&ty: @ast::ty, print_colons: bool) {
fn print_field(s: ps, f: ast::ty_field) {
cbox(s, indent_unit);
print_mutability(s, f.node.mt.mutbl);
word(s.s, f.node.ident);
word(s.s, *f.node.ident);
word_space(s, ":");
print_type(s, f.node.mt.ty);
end(s);
@ -443,7 +443,7 @@ fn print_item(s: ps, &&item: @ast::item) {
alt item.node {
ast::item_const(ty, expr) {
head(s, "const");
word_space(s, item.ident + ":");
word_space(s, *item.ident + ":");
print_type(s, ty);
space(s.s);
end(s); // end the head-ibox
@ -461,7 +461,7 @@ fn print_item(s: ps, &&item: @ast::item) {
}
ast::item_mod(_mod) {
head(s, "mod");
word_nbsp(s, item.ident);
word_nbsp(s, *item.ident);
bopen(s);
print_mod(s, _mod, item.attrs);
bclose(s, item.span);
@ -469,7 +469,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::item_native_mod(nmod) {
head(s, "native");
word_nbsp(s, "mod");
word_nbsp(s, item.ident);
word_nbsp(s, *item.ident);
bopen(s);
print_native_mod(s, nmod, item.attrs);
bclose(s, item.span);
@ -478,7 +478,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ibox(s, indent_unit);
ibox(s, 0u);
word_nbsp(s, "type");
word(s.s, item.ident);
word(s.s, *item.ident);
print_region_param(s, rp);
print_type_params(s, params);
end(s); // end the inner ibox
@ -492,13 +492,13 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::item_enum(variants, params, rp) {
let newtype =
vec::len(variants) == 1u &&
str::eq(item.ident, variants[0].node.name) &&
str::eq(*item.ident, *variants[0].node.name) &&
vec::len(variants[0].node.args) == 1u;
if newtype {
ibox(s, indent_unit);
word_space(s, "enum");
} else { head(s, "enum"); }
word(s.s, item.ident);
word(s.s, *item.ident);
print_region_param(s, rp);
print_type_params(s, params);
space(s.s);
@ -524,7 +524,7 @@ fn print_item(s: ps, &&item: @ast::item) {
}
ast::item_class(tps, ifaces, items, ctor, m_dtor, rp) {
head(s, "class");
word_nbsp(s, item.ident);
word_nbsp(s, *item.ident);
print_region_param(s, rp);
print_type_params(s, tps);
word_space(s, "implements");
@ -570,7 +570,7 @@ fn print_item(s: ps, &&item: @ast::item) {
ast::class_mutable { word_nbsp(s, "mut"); }
_ {}
}
word(s.s, nm);
word(s.s, *nm);
word_nbsp(s, ":");
print_type(s, t);
word(s.s, ";");
@ -588,7 +588,7 @@ fn print_item(s: ps, &&item: @ast::item) {
}
ast::item_impl(tps, rp, ifce, ty, methods) {
head(s, "impl");
word(s.s, item.ident);
word(s.s, *item.ident);
print_region_param(s, rp);
print_type_params(s, tps);
space(s.s);
@ -608,7 +608,7 @@ fn print_item(s: ps, &&item: @ast::item) {
}
ast::item_iface(tps, rp, methods) {
head(s, "iface");
word(s.s, item.ident);
word(s.s, *item.ident);
print_region_param(s, rp);
print_type_params(s, tps);
word(s.s, " ");
@ -627,18 +627,18 @@ fn print_item(s: ps, &&item: @ast::item) {
fn print_res(s: ps, decl: ast::fn_decl, name: ast::ident,
typarams: [ast::ty_param], rp: ast::region_param) {
head(s, "resource");
word(s.s, name);
word(s.s, *name);
print_region_param(s, rp);
print_type_params(s, typarams);
popen(s);
word_space(s, decl.inputs[0].ident + ":");
word_space(s, *decl.inputs[0].ident + ":");
print_type(s, decl.inputs[0].ty);
pclose(s);
space(s.s);
}
fn print_variant(s: ps, v: ast::variant) {
word(s.s, v.node.name);
word(s.s, *v.node.name);
if vec::len(v.node.args) > 0u {
popen(s);
fn print_variant_arg(s: ps, arg: ast::variant_arg) {
@ -892,7 +892,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
fn print_field(s: ps, field: ast::field) {
ibox(s, indent_unit);
if field.node.mutbl == ast::m_mutbl { word_nbsp(s, "mut"); }
word(s.s, field.node.ident);
word(s.s, *field.node.ident);
word_space(s, ":");
print_expr(s, field.node.expr);
end(s);
@ -1089,7 +1089,7 @@ fn print_expr(s: ps, &&expr: @ast::expr) {
print_expr_parens_if_not_bot(s, expr);
}
word(s.s, ".");
word(s.s, id);
word(s.s, *id);
if vec::len(tys) > 0u {
word(s.s, "::<");
commasep(s, inconsistent, tys, print_type);
@ -1222,7 +1222,7 @@ fn print_decl(s: ps, decl: @ast::decl) {
}
}
fn print_ident(s: ps, ident: ast::ident) { word(s.s, ident); }
fn print_ident(s: ps, ident: ast::ident) { word(s.s, *ident); }
fn print_for_decl(s: ps, loc: @ast::local, coll: @ast::expr) {
print_local_decl(s, loc);
@ -1237,7 +1237,7 @@ fn print_path(s: ps, &&path: @ast::path, colons_before_params: bool) {
let mut first = true;
for path.idents.each {|id|
if first { first = false; } else { word(s.s, "::"); }
word(s.s, id);
word(s.s, *id);
}
if path.rp.is_some() || !path.types.is_empty() {
if colons_before_params { word(s.s, "::"); }
@ -1290,7 +1290,7 @@ fn print_pat(s: ps, &&pat: @ast::pat) {
word(s.s, "{");
fn print_field(s: ps, f: ast::field_pat) {
cbox(s, indent_unit);
word(s.s, f.ident);
word(s.s, *f.ident);
word_space(s, ":");
print_pat(s, f.pat);
end(s);
@ -1327,7 +1327,7 @@ fn print_fn(s: ps, decl: ast::fn_decl, name: ast::ident,
ast::impure_fn { head(s, "fn") }
_ { head(s, purity_to_str(decl.purity) + " fn") }
}
word(s.s, name);
word(s.s, *name);
print_type_params(s, typarams);
print_fn_args_and_ret(s, decl, []);
}
@ -1341,7 +1341,7 @@ fn print_fn_args(s: ps, decl: ast::fn_decl,
if first { first = false; } else { word_space(s, ","); }
if cap_item.is_move { word_nbsp(s, "move") }
else { word_nbsp(s, "copy") }
word(s.s, cap_item.name);
word(s.s, *cap_item.name);
}
}
}
@ -1418,7 +1418,7 @@ fn print_type_params(s: ps, &&params: [ast::ty_param]) {
if vec::len(params) > 0u {
word(s.s, "<");
fn printParam(s: ps, param: ast::ty_param) {
word(s.s, param.ident);
word(s.s, *param.ident);
print_bounds(s, param.bounds);
}
commasep(s, inconsistent, params, printParam);
@ -1429,14 +1429,14 @@ fn print_type_params(s: ps, &&params: [ast::ty_param]) {
fn print_meta_item(s: ps, &&item: @ast::meta_item) {
ibox(s, indent_unit);
alt item.node {
ast::meta_word(name) { word(s.s, name); }
ast::meta_word(name) { word(s.s, *name); }
ast::meta_name_value(name, value) {
word_space(s, name);
word_space(s, *name);
word_space(s, "=");
print_literal(s, @value);
}
ast::meta_list(name, items) {
word(s.s, name);
word(s.s, *name);
popen(s);
commasep(s, consistent, items, print_meta_item);
pclose(s);
@ -1449,7 +1449,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
alt vp.node {
ast::view_path_simple(ident, path, _) {
if path.idents[vec::len(path.idents)-1u] != ident {
word_space(s, ident);
word_space(s, *ident);
word_space(s, "=");
}
print_path(s, path, false);
@ -1464,7 +1464,7 @@ fn print_view_path(s: ps, &&vp: @ast::view_path) {
print_path(s, path, false);
word(s.s, "::{");
commasep(s, inconsistent, idents) {|s, w|
word(s.s, w.node.name)
word(s.s, *w.node.name)
}
word(s.s, "}");
}
@ -1481,7 +1481,7 @@ fn print_view_item(s: ps, item: @ast::view_item) {
alt item.node {
ast::view_item_use(id, mta, _) {
head(s, "use");
word(s.s, id);
word(s.s, *id);
if vec::len(mta) > 0u {
popen(s);
commasep(s, consistent, mta, print_meta_item);
@ -1529,11 +1529,11 @@ fn print_arg(s: ps, input: ast::arg) {
print_arg_mode(s, input.mode);
alt input.ty.node {
ast::ty_infer {
word(s.s, input.ident);
word(s.s, *input.ident);
}
_ {
if str::len(input.ident) > 0u {
word_space(s, input.ident + ":");
if str::len(*input.ident) > 0u {
word_space(s, *input.ident + ":");
}
print_type(s, input.ty);
}
@ -1546,7 +1546,7 @@ fn print_ty_fn(s: ps, opt_proto: option<ast::proto>,
tps: option<[ast::ty_param]>) {
ibox(s, indent_unit);
word(s.s, opt_proto_to_str(opt_proto));
alt id { some(id) { word(s.s, " "); word(s.s, id); } _ { } }
alt id { some(id) { word(s.s, " "); word(s.s, *id); } _ { } }
alt tps { some(tps) { print_type_params(s, tps); } _ { } }
zerobreak(s.s);
popen(s);
@ -1608,7 +1608,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
_ {}
}
alt lit.node {
ast::lit_str(st) { print_string(s, st); }
ast::lit_str(st) { print_string(s, *st); }
ast::lit_int(ch, ast::ty_char) {
word(s.s, "'" + char::escape_default(ch as char) + "'");
}
@ -1640,7 +1640,7 @@ fn print_literal(s: ps, &&lit: @ast::lit) {
}
}
ast::lit_float(f, t) {
word(s.s, f + ast_util::float_ty_to_str(t));
word(s.s, *f + ast_util::float_ty_to_str(t));
}
ast::lit_nil { word(s.s, "()"); }
ast::lit_bool(val) {
@ -1804,7 +1804,7 @@ fn constrs_str<T>(constrs: [T], elt: fn(T) -> str) -> str {
}
fn fn_arg_idx_to_str(decl: ast::fn_decl, &&idx: uint) -> str {
decl.inputs[idx].ident
*decl.inputs[idx].ident
}
fn opt_proto_to_str(opt_p: option<ast::proto>) -> str {

View File

@ -29,8 +29,8 @@ fn name_of_fn(fk: fn_kind) -> ident {
alt fk {
fk_item_fn(name, _) | fk_method(name, _, _) | fk_res(name, _, _)
| fk_ctor(name, _, _, _) { /* FIXME: bad */ copy name }
fk_anon(*) | fk_fn_block(*) { "anon" }
fk_dtor(*) { "drop" }
fk_anon(*) | fk_fn_block(*) { @"anon" }
fk_dtor(*) { @"drop" }
}
}

View File

@ -291,24 +291,24 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
sha: sha1) -> link_meta {
type provided_metas =
{name: option<str>,
vers: option<str>,
{name: option<@str>,
vers: option<@str>,
cmh_items: [@ast::meta_item]};
fn provided_link_metas(sess: session, c: ast::crate) ->
provided_metas {
let mut name: option<str> = none;
let mut vers: option<str> = none;
let mut name: option<@str> = none;
let mut vers: option<@str> = none;
let mut cmh_items: [@ast::meta_item] = [];
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
attr::require_unique_names(sess.diagnostic(), linkage_metas);
for linkage_metas.each {|meta|
if attr::get_meta_item_name(meta) == "name" {
if *attr::get_meta_item_name(meta) == "name" {
alt attr::get_meta_item_value_str(meta) {
some(v) { name = some(v); }
none { cmh_items += [meta]; }
}
} else if attr::get_meta_item_name(meta) == "vers" {
} else if *attr::get_meta_item_name(meta) == "vers" {
alt attr::get_meta_item_value_str(meta) {
some(v) { vers = some(v); }
none { cmh_items += [meta]; }
@ -321,7 +321,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
// This calculates CMH as defined above
fn crate_meta_extras_hash(sha: sha1, _crate: ast::crate,
metas: provided_metas,
dep_hashes: [str]) -> str {
dep_hashes: [@str]) -> str {
fn len_and_str(s: str) -> str {
ret #fmt["%u_%s", str::len(s), s];
}
@ -337,10 +337,10 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
let m = m_;
alt m.node {
ast::meta_name_value(key, value) {
sha.input_str(len_and_str(key));
sha.input_str(len_and_str(*key));
sha.input_str(len_and_str_lit(value));
}
ast::meta_word(name) { sha.input_str(len_and_str(name)); }
ast::meta_word(name) { sha.input_str(len_and_str(*name)); }
ast::meta_list(_, _) {
// FIXME (#607): Implement this
fail "unimplemented meta_item variant";
@ -349,7 +349,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
}
for dep_hashes.each {|dh|
sha.input_str(len_and_str(dh));
sha.input_str(len_and_str(*dh));
}
ret truncated_sha1_result(sha);
@ -362,7 +362,7 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
}
fn crate_meta_name(sess: session, _crate: ast::crate,
output: str, metas: provided_metas) -> str {
output: str, metas: provided_metas) -> @str {
ret alt metas.name {
some(v) { v }
none {
@ -378,19 +378,19 @@ fn build_link_meta(sess: session, c: ast::crate, output: str,
str::connect(os, ".")
};
warn_missing(sess, "name", name);
name
@name
}
};
}
fn crate_meta_vers(sess: session, _crate: ast::crate,
metas: provided_metas) -> str {
metas: provided_metas) -> @str {
ret alt metas.vers {
some(v) { v }
none {
let vers = "0.0";
warn_missing(sess, "vers", vers);
vers
@vers
}
};
}
@ -417,7 +417,7 @@ fn symbol_hash(tcx: ty::ctxt, sha: sha1, t: ty::t,
// to be independent of one another in the crate.
sha.reset();
sha.input_str(link_meta.name);
sha.input_str(*link_meta.name);
sha.input_str("-");
sha.input_str(link_meta.extras_hash);
sha.input_str("-");
@ -482,7 +482,7 @@ fn mangle(ss: path) -> str {
for ss.each {|s|
alt s { path_name(s) | path_mod(s) {
let sani = sanitize(s);
let sani = sanitize(*s);
n += #fmt["%u%s", str::len(sani), sani];
} }
}
@ -490,33 +490,34 @@ fn mangle(ss: path) -> str {
n
}
fn exported_name(path: path, hash: str, vers: str) -> str {
fn exported_name(path: path, hash: @str, vers: @str) -> str {
ret mangle(path + [path_name(hash)] + [path_name(vers)]);
}
fn mangle_exported_name(ccx: @crate_ctxt, path: path, t: ty::t) -> str {
let hash = get_symbol_hash(ccx, t);
ret exported_name(path, hash, ccx.link_meta.vers);
ret exported_name(path, @hash, ccx.link_meta.vers);
}
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt, t: ty::t, name: str) ->
fn mangle_internal_name_by_type_only(ccx: @crate_ctxt,
t: ty::t, name: @str) ->
str {
let s = util::ppaux::ty_to_short_str(ccx.tcx, t);
let s = @util::ppaux::ty_to_short_str(ccx.tcx, t);
let hash = get_symbol_hash(ccx, t);
ret mangle([path_name(name), path_name(s), path_name(hash)]);
ret mangle([path_name(name), path_name(s), path_name(@hash)]);
}
fn mangle_internal_name_by_path_and_seq(ccx: @crate_ctxt, path: path,
flav: str) -> str {
ret mangle(path + [path_name(ccx.names(flav))]);
flav: @str) -> str {
ret mangle(path + [path_name(@ccx.names(*flav))]);
}
fn mangle_internal_name_by_path(_ccx: @crate_ctxt, path: path) -> str {
ret mangle(path);
}
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: str) -> str {
ret ccx.names(flav);
fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: @str) -> str {
ret ccx.names(*flav);
}
// If the user wants an exe generated we need to invoke
@ -552,8 +553,8 @@ fn link_binary(sess: session,
let output = if sess.building_library {
let long_libname =
os::dll_filename(#fmt("%s-%s-%s",
lm.name, lm.extras_hash, lm.vers));
#debug("link_meta.name: %s", lm.name);
*lm.name, lm.extras_hash, *lm.vers));
#debug("link_meta.name: %s", *lm.name);
#debug("long_libname: %s", long_libname);
#debug("out_filename: %s", out_filename);
#debug("dirname(out_filename): %s", path::dirname(out_filename));

View File

@ -49,14 +49,14 @@ fn default_configuration(sess: session, argv0: str, input: input) ->
};
ret [ // Target bindings.
attr::mk_word_item(os::family()),
mk("target_os", os::sysname()),
mk("target_family", os::family()),
mk("target_arch", arch),
mk("target_libc", libc),
attr::mk_word_item(@os::family()),
mk(@"target_os", os::sysname()),
mk(@"target_family", os::family()),
mk(@"target_arch", arch),
mk(@"target_libc", libc),
// Build bindings.
mk("build_compiler", argv0),
mk("build_input", source_name(input))];
mk(@"build_compiler", argv0),
mk(@"build_input", source_name(input))];
}
fn build_configuration(sess: session, argv0: str, input: input) ->
@ -70,7 +70,7 @@ fn build_configuration(sess: session, argv0: str, input: input) ->
{
if sess.opts.test && !attr::contains_name(user_cfg, "test")
{
[attr::mk_word_item("test")]
[attr::mk_word_item(@"test")]
} else { [] }
};
ret user_cfg + gen_cfg + default_cfg;
@ -82,7 +82,7 @@ fn parse_cfgspecs(cfgspecs: [str]) -> ast::crate_cfg {
// meta_item here. At the moment we just support the meta_word variant.
// #2399
let mut words = [];
for cfgspecs.each {|s| words += [attr::mk_word_item(s)]; }
for cfgspecs.each {|s| words += [attr::mk_word_item(@s)]; }
ret words;
}

View File

@ -199,7 +199,7 @@ fn building_library(req_crate_type: crate_type, crate: @ast::crate,
alt syntax::attr::first_attr_value_str_by_name(
crate.node.attrs,
"crate_type") {
option::some("lib") { true }
option::some(@"lib") { true }
_ { false }
}
}
@ -227,9 +227,9 @@ mod test {
style: ast::attr_outer,
value: ast_util::respan(ast_util::dummy_sp(),
ast::meta_name_value(
"crate_type",
@"crate_type",
ast_util::respan(ast_util::dummy_sp(),
ast::lit_str(t))))
ast::lit_str(@t))))
})
}

View File

@ -30,11 +30,11 @@ fn inject_libcore_ref(sess: session,
let n1 = sess.next_node_id();
let n2 = sess.next_node_id();
let vi1 = @{node: ast::view_item_use("core", [], n1),
let vi1 = @{node: ast::view_item_use(@"core", [], n1),
attrs: [],
vis: ast::public,
span: dummy_sp()};
let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), "core"),
let vp = spanned(ast::view_path_glob(ident_to_path(dummy_sp(), @"core"),
n2));
let vi2 = @{node: ast::view_item_import([vp]),
attrs: [],

View File

@ -70,7 +70,7 @@ fn fold_mod(_cx: test_ctxt, m: ast::_mod, fld: fold::ast_fold) -> ast::_mod {
fn nomain(&&item: @ast::item) -> option<@ast::item> {
alt item.node {
ast::item_fn(_, _, _) {
if item.ident == "main" {
if *item.ident == "main" {
option::none
} else { option::some(item) }
}
@ -190,9 +190,9 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_mod(testmod);
// This attribute tells resolve to let us call unexported functions
let resolve_unexported_attr =
attr::mk_attr(attr::mk_word_item("!resolve_unexported"));
attr::mk_attr(attr::mk_word_item(@"!resolve_unexported"));
let item: ast::item =
{ident: "__test",
{ident: @"__test",
attrs: [resolve_unexported_attr],
id: cx.sess.next_node_id(),
node: item_,
@ -231,7 +231,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_fn(decl, [], body);
let item: ast::item =
{ident: "tests",
{ident: @"tests",
attrs: [],
id: cx.sess.next_node_id(),
node: item_,
@ -246,16 +246,16 @@ fn mk_path(cx: test_ctxt, path: [ast::ident]) -> [ast::ident] {
let is_std = {
let items = attr::find_linkage_metas(cx.crate.node.attrs);
alt attr::last_meta_item_value_str_by_name(items, "name") {
some("std") { true }
some(@"std") { true }
_ { false }
}
};
(if is_std { [] } else { ["std"] }) + path
(if is_std { [] } else { [@"std"] }) + path
}
// The ast::ty of [std::test::test_desc]
fn mk_test_desc_vec_ty(cx: test_ctxt) -> @ast::ty {
let test_desc_ty_path = path_node(mk_path(cx, ["test", "test_desc"]));
let test_desc_ty_path = path_node(mk_path(cx, [@"test", @"test_desc"]));
let test_desc_ty: ast::ty =
{id: cx.sess.next_node_id(),
@ -288,14 +288,14 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
#debug("encoding %s", ast_util::path_name_i(path));
let name_lit: ast::lit =
nospan(ast::lit_str(ast_util::path_name_i(path)));
nospan(ast::lit_str(@ast_util::path_name_i(path)));
let name_expr: ast::expr =
{id: cx.sess.next_node_id(),
node: ast::expr_lit(@name_lit),
span: span};
let name_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "name", expr: @name_expr});
nospan({mutbl: ast::m_imm, ident: @"name", expr: @name_expr});
let fn_path = path_node(path);
@ -307,7 +307,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
let fn_wrapper_expr = mk_test_wrapper(cx, fn_expr, span);
let fn_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "fn", expr: fn_wrapper_expr});
nospan({mutbl: ast::m_imm, ident: @"fn", expr: fn_wrapper_expr});
let ignore_lit: ast::lit = nospan(ast::lit_bool(test.ignore));
@ -317,7 +317,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
span: span};
let ignore_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "ignore", expr: @ignore_expr});
nospan({mutbl: ast::m_imm, ident: @"ignore", expr: @ignore_expr});
let fail_lit: ast::lit = nospan(ast::lit_bool(test.should_fail));
@ -327,7 +327,7 @@ fn mk_test_desc_rec(cx: test_ctxt, test: test) -> @ast::expr {
span: span};
let fail_field: ast::field =
nospan({mutbl: ast::m_imm, ident: "should_fail", expr: @fail_expr});
nospan({mutbl: ast::m_imm, ident: @"should_fail", expr: @fail_expr});
let desc_rec_: ast::expr_ =
ast::expr_rec([name_field, fn_field, ignore_field, fail_field],
@ -379,7 +379,7 @@ fn mk_test_wrapper(cx: test_ctxt,
}
fn mk_main(cx: test_ctxt) -> @ast::item {
let str_pt = path_node(["str"]);
let str_pt = path_node([@"str"]);
let str_ty = @{id: cx.sess.next_node_id(),
node: ast::ty_path(str_pt, cx.sess.next_node_id()),
span: dummy_sp()};
@ -391,7 +391,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let args_arg: ast::arg =
{mode: ast::expl(ast::by_val),
ty: @args_ty,
ident: "args",
ident: @"args",
id: cx.sess.next_node_id()};
let ret_ty = {id: cx.sess.next_node_id(),
@ -414,7 +414,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
let item_ = ast::item_fn(decl, [], body);
let item: ast::item =
{ident: "main",
{ident: @"main",
attrs: [],
id: cx.sess.next_node_id(),
node: item_,
@ -426,7 +426,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
// Get the args passed to main so we can pass the to test_main
let args_path = path_node(["args"]);
let args_path = path_node([@"args"]);
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
@ -434,7 +434,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.sess.next_node_id(), node: args_path_expr_, span: dummy_sp()};
// Call __test::test to generate the vector of test_descs
let test_path = path_node(["tests"]);
let test_path = path_node([@"tests"]);
let test_path_expr_: ast::expr_ = ast::expr_path(test_path);
@ -447,7 +447,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
{id: cx.sess.next_node_id(), node: test_call_expr_, span: dummy_sp()};
// Call std::test::test_main
let test_main_path = path_node(mk_path(cx, ["test", "test_main"]));
let test_main_path = path_node(mk_path(cx, [@"test", @"test_main"]));
let test_main_path_expr_: ast::expr_ = ast::expr_path(test_main_path);

View File

@ -132,5 +132,5 @@ fn hash_path(&&s: str) -> uint {
ret h;
}
type link_meta = {name: str, vers: str, extras_hash: str};
type link_meta = {name: @str, vers: @str, extras_hash: str};

View File

@ -42,7 +42,7 @@ fn read_crates(diag: span_handler, crate: ast::crate,
type cache_entry = {
cnum: int,
span: span,
hash: str,
hash: @str,
metas: @[@ast::meta_item]
};
@ -53,7 +53,7 @@ fn dump_crates(crate_cache: dvec<cache_entry>) {
#debug("span: %?", entry.span);
#debug("hash: %?", entry.hash);
let attrs = [
attr::mk_attr(attr::mk_list_item("link", *entry.metas))
attr::mk_attr(attr::mk_list_item(@"link", *entry.metas))
];
for attr::find_linkage_attrs(attrs).each {|attr|
#debug("meta: %s", pprust::attr_to_str(attr));
@ -81,11 +81,11 @@ fn warn_if_multiple_versions(diag: span_handler,
if matches.len() != 1u {
diag.handler().warn(
#fmt("using multiple versions of crate `%s`", name));
#fmt("using multiple versions of crate `%s`", *name));
for matches.each {|match|
diag.span_note(match.span, "used here");
let attrs = [
attr::mk_attr(attr::mk_list_item("link", *match.metas))
attr::mk_attr(attr::mk_list_item(@"link", *match.metas))
];
loader::note_linkage_attrs(diag, attrs);
}
@ -129,7 +129,7 @@ fn visit_item(e: env, i: @ast::item) {
let native_name =
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
some(nn) {
if nn == "" {
if *nn == "" {
e.diag.span_fatal(
i.span,
"empty #[link_name] not allowed; use #[nolink].");
@ -140,17 +140,17 @@ fn visit_item(e: env, i: @ast::item) {
};
let mut already_added = false;
if vec::len(attr::find_attrs_by_name(i.attrs, "nolink")) == 0u {
already_added = !cstore::add_used_library(cstore, native_name);
already_added = !cstore::add_used_library(cstore, *native_name);
}
let link_args = attr::find_attrs_by_name(i.attrs, "link_args");
if vec::len(link_args) > 0u && already_added {
e.diag.span_fatal(i.span, "library '" + native_name +
e.diag.span_fatal(i.span, "library '" + *native_name +
"' already added: can't specify link_args.");
}
for link_args.each {|a|
alt attr::get_meta_item_value_str(attr::attr_meta(a)) {
some(linkarg) {
cstore::add_used_link_args(cstore, linkarg);
cstore::add_used_link_args(cstore, *linkarg);
}
none {/* fallthrough */ }
}
@ -160,11 +160,11 @@ fn visit_item(e: env, i: @ast::item) {
}
}
fn metas_with(ident: ast::ident, key: str,
fn metas_with(ident: ast::ident, key: ast::ident,
metas: [@ast::meta_item]) -> [@ast::meta_item] {
let name_items = attr::find_meta_items_by_name(metas, key);
let name_items = attr::find_meta_items_by_name(metas, *key);
if name_items.is_empty() {
metas + [attr::mk_name_value_item_str(key, ident)]
metas + [attr::mk_name_value_item_str(key, *ident)]
} else {
metas
}
@ -172,7 +172,7 @@ fn metas_with(ident: ast::ident, key: str,
fn metas_with_ident(ident: ast::ident,
metas: [@ast::meta_item]) -> [@ast::meta_item] {
metas_with(ident, "name", metas)
metas_with(ident, @"name", metas)
}
fn existing_match(e: env, metas: [@ast::meta_item], hash: str) ->
@ -180,7 +180,7 @@ fn existing_match(e: env, metas: [@ast::meta_item], hash: str) ->
for e.crate_cache.each {|c|
if loader::metadata_matches(*c.metas, metas)
&& (hash.is_empty() || c.hash == hash) {
&& (hash.is_empty() || *c.hash == hash) {
ret some(c.cnum);
}
}
@ -226,7 +226,7 @@ fn resolve_crate(e: env, ident: ast::ident, metas: [@ast::meta_item],
option::some(v) { v }
option::none { ident }
};
let cmeta = @{name: cname, data: cdata,
let cmeta = @{name: *cname, data: cdata,
cnum_map: cnum_map, cnum: cnum};
let cstore = e.cstore;
@ -249,10 +249,10 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map {
for decoder::get_crate_deps(cdata).each {|dep|
let extrn_cnum = dep.cnum;
let cname = dep.name;
let cmetas = metas_with(dep.vers, "vers", []);
let cmetas = metas_with(dep.vers, @"vers", []);
#debug("resolving dep crate %s ver: %s hash: %s",
dep.name, dep.vers, dep.hash);
alt existing_match(e, metas_with_ident(cname, cmetas), dep.hash) {
*dep.name, *dep.vers, *dep.hash);
alt existing_match(e, metas_with_ident(cname, cmetas), *dep.hash) {
some(local_cnum) {
#debug("already have it");
// We've already seen this crate
@ -265,7 +265,7 @@ fn resolve_crate_deps(e: env, cdata: @[u8]) -> cstore::cnum_map {
// #2404
let fake_span = ast_util::dummy_sp();
let local_cnum =
resolve_crate(e, cname, cmetas, dep.hash, fake_span);
resolve_crate(e, cname, cmetas, *dep.hash, fake_span);
cnum_map.insert(extrn_cnum, local_cnum);
}
}

View File

@ -64,7 +64,7 @@ fn resolve_path(cstore: cstore::cstore, cnum: ast::crate_num,
[(ast::crate_num, @[u8], ast::def_id)] {
let cm = cstore::get_crate_data(cstore, cnum);
#debug("resolve_path %s in crates[%d]:%s",
str::connect(path, "::"), cnum, cm.name);
ast_util::path_name_i(path), cnum, cm.name);
let mut result = [];
for decoder::resolve_path(path, cm.data).each {|def|
if def.crate == ast::local_crate {
@ -88,7 +88,7 @@ fn get_item_path(tcx: ty::ctxt, def: ast::def_id) -> ast_map::path {
// FIXME #1920: This path is not always correct if the crate is not linked
// into the root namespace.
[ast_map::path_mod(cdata.name)] + path
[ast_map::path_mod(@cdata.name)] + path
}
enum found_ast {
@ -170,7 +170,8 @@ fn get_impl_iface(tcx: ty::ctxt, def: ast::def_id) -> option<ty::t> {
decoder::get_impl_iface(cdata, def.node, tcx)
}
fn get_impl_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
fn get_impl_method(cstore: cstore::cstore,
def: ast::def_id, mname: ast::ident)
-> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_impl_method(cdata, def.node, mname)
@ -180,7 +181,8 @@ fn get_impl_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
for their methods (so that get_iface_methods can be reused to get
class methods), classes require a slightly different version of
get_impl_method. Sigh. */
fn get_class_method(cstore: cstore::cstore, def: ast::def_id, mname: str)
fn get_class_method(cstore: cstore::cstore,
def: ast::def_id, mname: ast::ident)
-> ast::def_id {
let cdata = cstore::get_crate_data(cstore, def.crate);
decoder::get_class_method(cdata, def.node, mname)

View File

@ -37,7 +37,7 @@ type cnum_map = map::hashmap<ast::crate_num, ast::crate_num>;
// Multiple items may have the same def_id in crate metadata. They may be
// renamed imports or reexports. This map keeps the "real" module path
// and def_id.
type mod_path_map = map::hashmap<ast::def_id, str>;
type mod_path_map = map::hashmap<ast::def_id, @str>;
type crate_metadata = @{name: str,
data: @[u8],
@ -83,12 +83,12 @@ fn get_crate_data(cstore: cstore, cnum: ast::crate_num) -> crate_metadata {
ret p(cstore).metas.get(cnum);
}
fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> str {
fn get_crate_hash(cstore: cstore, cnum: ast::crate_num) -> @str {
let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_hash(cdata.data);
}
fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> str {
fn get_crate_vers(cstore: cstore, cnum: ast::crate_num) -> @str {
let cdata = get_crate_data(cstore, cnum);
ret decoder::get_crate_vers(cdata.data);
}
@ -99,7 +99,7 @@ fn set_crate_data(cstore: cstore, cnum: ast::crate_num,
vec::iter(decoder::get_crate_module_paths(data.data)) {|dp|
let (did, path) = dp;
let d = {crate: cnum, node: did.node};
p(cstore).mod_path_map.insert(d, path);
p(cstore).mod_path_map.insert(d, @path);
}
}
@ -153,32 +153,32 @@ fn find_use_stmt_cnum(cstore: cstore,
// returns hashes of crates directly used by this crate. Hashes are
// sorted by crate name.
fn get_dep_hashes(cstore: cstore) -> [str] {
type crate_hash = {name: str, hash: str};
fn get_dep_hashes(cstore: cstore) -> [@str] {
type crate_hash = {name: @str, hash: @str};
let mut result = [];
for p(cstore).use_crate_map.each_value {|cnum|
let cdata = cstore::get_crate_data(cstore, cnum);
let hash = decoder::get_crate_hash(cdata.data);
#debug("Add hash[%s]: %s", cdata.name, hash);
result += [{name: cdata.name, hash: hash}];
#debug("Add hash[%s]: %s", cdata.name, *hash);
result += [{name: @cdata.name, hash: hash}];
};
fn lteq(a: crate_hash, b: crate_hash) -> bool {
ret a.name <= b.name;
ret *a.name <= *b.name;
}
let sorted = std::sort::merge_sort(lteq, result);
#debug("sorted:");
for sorted.each {|x|
#debug(" hash[%s]: %s", x.name, x.hash);
#debug(" hash[%s]: %s", *x.name, *x.hash);
}
fn mapper(ch: crate_hash) -> str { ret ch.hash; }
fn mapper(ch: crate_hash) -> @str { ret ch.hash; }
ret vec::map(sorted, mapper);
}
fn get_path(cstore: cstore, d: ast::def_id) -> [str] {
fn get_path(cstore: cstore, d: ast::def_id) -> [ast::ident] {
// let f = bind str::split_str(_, "::");
option::map_default(p(cstore).mod_path_map.find(d), [],
{|ds| str::split_str(ds, "::")})
{|ds| str::split_str(*ds, "::").map({|x|@x})})
}
// Local Variables:
// mode: rust

View File

@ -210,7 +210,7 @@ fn resolve_path(path: [ast::ident], data: @[u8]) -> [ast::def_id] {
fn eq_item(data: [u8], s: str) -> bool {
ret str::eq(str::from_bytes(data), s);
}
let s = str::connect(path, "::");
let s = ast_util::path_name_i(path);
let md = ebml::doc(data);
let paths = ebml::get_doc(md, tag_paths);
let eqer = bind eq_item(_, s);
@ -235,10 +235,10 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
ebml::docs(path_doc) {|tag, elt_doc|
if tag == tag_path_elt_mod {
let str = ebml::doc_as_str(elt_doc);
result += [ast_map::path_mod(str)];
result += [ast_map::path_mod(@str)];
} else if tag == tag_path_elt_name {
let str = ebml::doc_as_str(elt_doc);
result += [ast_map::path_name(str)];
result += [ast_map::path_name(@str)];
} else {
// ignore tag_path_len element
}
@ -249,7 +249,7 @@ fn item_path(item_doc: ebml::doc) -> ast_map::path {
fn item_name(item: ebml::doc) -> ast::ident {
let name = ebml::get_doc(item, tag_paths_data_name);
str::from_bytes(ebml::doc_data(name))
@str::from_bytes(ebml::doc_data(name))
}
fn lookup_item_name(data: @[u8], id: ast::node_id) -> ast::ident {
@ -302,7 +302,8 @@ fn get_impl_iface(cdata: cmd, id: ast::node_id, tcx: ty::ctxt)
item_impl_iface(lookup_item(id, cdata.data), tcx, cdata)
}
fn get_impl_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
fn get_impl_method(cdata: cmd, id: ast::node_id,
name: ast::ident) -> ast::def_id {
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none;
ebml::tagged_docs(find_item(id, items), tag_item_impl_method) {|mid|
@ -314,13 +315,14 @@ fn get_impl_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
option::get(found)
}
fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
fn get_class_method(cdata: cmd, id: ast::node_id,
name: ast::ident) -> ast::def_id {
let items = ebml::get_doc(ebml::doc(cdata.data), tag_items);
let mut found = none;
let cls_items = alt maybe_find_item(id, items) {
some(it) { it }
none { fail (#fmt("get_class_method: class id not found \
when looking up method %s", name)) }};
when looking up method %s", *name)) }};
ebml::tagged_docs(cls_items, tag_item_iface_method) {|mid|
let m_did = class_member_id(mid, cdata);
if item_name(mid) == name {
@ -329,7 +331,7 @@ fn get_class_method(cdata: cmd, id: ast::node_id, name: str) -> ast::def_id {
}
alt found {
some(found) { found }
none { fail (#fmt("get_class_method: no method named %s", name)) }
none { fail (#fmt("get_class_method: no method named %s", *name)) }
}
}
@ -574,7 +576,7 @@ fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] {
ebml::tagged_docs(md, tag_meta_item_word) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd));
items += [attr::mk_word_item(n)];
items += [attr::mk_word_item(@n)];
};
ebml::tagged_docs(md, tag_meta_item_name_value) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
@ -583,13 +585,13 @@ fn get_meta_items(md: ebml::doc) -> [@ast::meta_item] {
let v = str::from_bytes(ebml::doc_data(vd));
// FIXME (#623): Should be able to decode meta_name_value variants,
// but currently the encoder just drops them
items += [attr::mk_name_value_item_str(n, v)];
items += [attr::mk_name_value_item_str(@n, v)];
};
ebml::tagged_docs(md, tag_meta_item_list) {|meta_item_doc|
let nd = ebml::get_doc(meta_item_doc, tag_meta_item_name);
let n = str::from_bytes(ebml::doc_data(nd));
let subitems = get_meta_items(meta_item_doc);
items += [attr::mk_list_item(n, subitems)];
items += [attr::mk_list_item(@n, subitems)];
};
ret items;
}
@ -620,8 +622,8 @@ fn list_meta_items(meta_items: ebml::doc, out: io::writer) {
}
}
fn list_crate_attributes(md: ebml::doc, hash: str, out: io::writer) {
out.write_str(#fmt("=Crate Attributes (%s)=\n", hash));
fn list_crate_attributes(md: ebml::doc, hash: @str, out: io::writer) {
out.write_str(#fmt("=Crate Attributes (%s)=\n", *hash));
for get_attributes(md).each {|attr|
out.write_str(#fmt["%s\n", pprust::attribute_to_str(attr)]);
@ -635,7 +637,7 @@ fn get_crate_attributes(data: @[u8]) -> [ast::attribute] {
}
type crate_dep = {cnum: ast::crate_num, name: ast::ident,
vers: str, hash: str};
vers: @str, hash: @str};
fn get_crate_deps(data: @[u8]) -> [crate_dep] {
let mut deps: [crate_dep] = [];
@ -647,9 +649,9 @@ fn get_crate_deps(data: @[u8]) -> [crate_dep] {
}
ebml::tagged_docs(depsdoc, tag_crate_dep) {|depdoc|
deps += [{cnum: crate_num,
name: docstr(depdoc, tag_crate_dep_name),
vers: docstr(depdoc, tag_crate_dep_vers),
hash: docstr(depdoc, tag_crate_dep_hash)}];
name: @docstr(depdoc, tag_crate_dep_name),
vers: @docstr(depdoc, tag_crate_dep_vers),
hash: @docstr(depdoc, tag_crate_dep_hash)}];
crate_num += 1;
};
ret deps;
@ -660,24 +662,24 @@ fn list_crate_deps(data: @[u8], out: io::writer) {
for get_crate_deps(data).each {|dep|
out.write_str(#fmt["%d %s-%s-%s\n",
dep.cnum, dep.name, dep.hash, dep.vers]);
dep.cnum, *dep.name, *dep.hash, *dep.vers]);
}
out.write_str("\n");
}
fn get_crate_hash(data: @[u8]) -> str {
fn get_crate_hash(data: @[u8]) -> @str {
let cratedoc = ebml::doc(data);
let hashdoc = ebml::get_doc(cratedoc, tag_crate_hash);
ret str::from_bytes(ebml::doc_data(hashdoc));
ret @str::from_bytes(ebml::doc_data(hashdoc));
}
fn get_crate_vers(data: @[u8]) -> str {
fn get_crate_vers(data: @[u8]) -> @str {
let attrs = decoder::get_crate_attributes(data);
ret alt attr::last_meta_item_value_str_by_name(
attr::find_linkage_metas(attrs), "vers") {
some(ver) { ver }
none { "0.0" }
none { @"0.0" }
};
}

View File

@ -71,8 +71,8 @@ fn reachable(ecx: @encode_ctxt, id: node_id) -> bool {
}
// Path table encoding
fn encode_name(ebml_w: ebml::writer, name: str) {
ebml_w.wr_tagged_str(tag_paths_data_name, name);
fn encode_name(ebml_w: ebml::writer, name: ident) {
ebml_w.wr_tagged_str(tag_paths_data_name, *name);
}
fn encode_def_id(ebml_w: ebml::writer, id: def_id) {
@ -92,7 +92,7 @@ fn encode_region_param(ebml_w: ebml::writer, rp: region_param) {
}
}
fn encode_named_def_id(ebml_w: ebml::writer, name: str, id: def_id) {
fn encode_named_def_id(ebml_w: ebml::writer, name: ident, id: def_id) {
ebml_w.wr_tag(tag_paths_data_item) {||
encode_name(ebml_w, name);
encode_def_id(ebml_w, id);
@ -109,7 +109,7 @@ fn encode_mutability(ebml_w: ebml::writer, mt: class_mutability) {
type entry<T> = {val: T, pos: uint};
fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant],
path: [str], &index: [entry<str>]) {
path: [ident], &index: [entry<str>]) {
for variants.each {|variant|
add_to_index(ebml_w, path, index, variant.node.name);
ebml_w.wr_tag(tag_paths_data_item) {||
@ -119,15 +119,15 @@ fn encode_enum_variant_paths(ebml_w: ebml::writer, variants: [variant],
}
}
fn add_to_index(ebml_w: ebml::writer, path: [str], &index: [entry<str>],
name: str) {
fn add_to_index(ebml_w: ebml::writer, path: [ident], &index: [entry<str>],
name: ident) {
let full_path = path + [name];
index +=
[{val: str::connect(full_path, "::"), pos: ebml_w.writer.tell()}];
[{val: ast_util::path_name_i(full_path), pos: ebml_w.writer.tell()}];
}
fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
path: [str], &index: [entry<str>]) {
path: [ident], &index: [entry<str>]) {
for nmod.items.each {|nitem|
add_to_index(ebml_w, path, index, nitem.ident);
encode_named_def_id(ebml_w, nitem.ident, local_def(nitem.id));
@ -135,7 +135,7 @@ fn encode_native_module_item_paths(ebml_w: ebml::writer, nmod: native_mod,
}
fn encode_class_item_paths(ebml_w: ebml::writer,
items: [@class_member], path: [str], &index: [entry<str>]) {
items: [@class_member], path: [ident], &index: [entry<str>]) {
for items.each {|it|
alt ast_util::class_member_visibility(it) {
private { cont; }
@ -152,7 +152,8 @@ fn encode_class_item_paths(ebml_w: ebml::writer,
}
fn encode_module_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt,
module: _mod, path: [str], &index: [entry<str>]) {
module: _mod, path: [ident],
&index: [entry<str>]) {
for module.items.each {|it|
if !reachable(ecx, it.id) ||
!ast_util::is_exported(it.ident, module) { cont; }
@ -235,7 +236,7 @@ fn encode_iface_ref(ebml_w: ebml::writer, ecx: @encode_ctxt, t: @iface_ref) {
fn encode_item_paths(ebml_w: ebml::writer, ecx: @encode_ctxt, crate: @crate)
-> [entry<str>] {
let mut index: [entry<str>] = [];
let mut path: [str] = [];
let mut path: [ident] = [];
ebml_w.start_tag(tag_paths);
encode_module_item_paths(ebml_w, ecx, crate.node.module, path, index);
encode_reexport_paths(ebml_w, ecx, index);
@ -249,7 +250,7 @@ fn encode_reexport_paths(ebml_w: ebml::writer,
let (path, def_id) = reexport;
index += [{val: path, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_paths_data_item);
encode_name(ebml_w, path);
encode_name(ebml_w, @path);
encode_def_id(ebml_w, def_id);
ebml_w.end_tag();
}
@ -374,7 +375,7 @@ fn encode_path(ebml_w: ebml::writer,
ast_map::path_name(name) { (tag_path_elt_name, name) }
};
ebml_w.wr_tagged_str(tag, name);
ebml_w.wr_tagged_str(tag, *name);
}
ebml_w.wr_tag(tag_path) {||
@ -439,7 +440,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
instance_var(nm, _, mt, id, vis) {
*index += [{val: id, pos: ebml_w.writer.tell()}];
ebml_w.start_tag(tag_items_data_item);
#debug("encode_info_for_class: doing %s %d", nm, id);
#debug("encode_info_for_class: doing %s %d", *nm, id);
encode_visibility(ebml_w, vis);
encode_name(ebml_w, nm);
encode_path(ebml_w, path, ast_map::path_name(nm));
@ -456,7 +457,7 @@ fn encode_info_for_class(ecx: @encode_ctxt, ebml_w: ebml::writer,
but it works for now -- tjc */
*global_index += [{val: m.id, pos: ebml_w.writer.tell()}];
let impl_path = path + [ast_map::path_name(m.ident)];
#debug("encode_info_for_class: doing %s %d", m.ident, m.id);
#debug("encode_info_for_class: doing %s %d", *m.ident, m.id);
encode_info_for_method(ecx, ebml_w, impl_path,
should_inline(m.attrs), id, m,
class_tps + m.tps);
@ -479,7 +480,7 @@ fn encode_info_for_fn(ecx: @encode_ctxt, ebml_w: ebml::writer,
encode_family(ebml_w, purity_fn_family(decl.purity));
encode_type_param_bounds(ebml_w, ecx, tps);
let its_ty = node_id_to_type(ecx.tcx, id);
#debug("fn name = %s ty = %s its node id = %d", ident,
#debug("fn name = %s ty = %s its node id = %d", *ident,
util::ppaux::ty_to_str(ecx.tcx, its_ty), id);
encode_type(ecx, ebml_w, its_ty);
encode_path(ebml_w, path, ast_map::path_name(ident));
@ -498,7 +499,7 @@ fn encode_info_for_method(ecx: @encode_ctxt, ebml_w: ebml::writer,
impl_path: ast_map::path, should_inline: bool,
parent_id: node_id,
m: @method, all_tps: [ty_param]) {
#debug("encode_info_for_method: %d %s %u", m.id, m.ident, all_tps.len());
#debug("encode_info_for_method: %d %s %u", m.id, *m.ident, all_tps.len());
ebml_w.start_tag(tag_items_data_item);
encode_def_id(ebml_w, local_def(m.id));
encode_family(ebml_w, purity_fn_family(m.decl.purity));
@ -627,8 +628,8 @@ fn encode_info_for_item(ecx: @encode_ctxt, ebml_w: ebml::writer, item: @item,
/* Encode the dtor */
option::iter(m_dtor) {|dtor|
*index += [{val: dtor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, dtor.node.id, item.ident
+ "_dtor", path, if tps.len() > 0u {
encode_info_for_fn(ecx, ebml_w, dtor.node.id, @(*item.ident
+ "_dtor"), path, if tps.len() > 0u {
some(ii_dtor(dtor, item.ident, tps,
local_def(item.id))) }
else { none }, tps, ast_util::dtor_dec());
@ -805,7 +806,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
ebml_w.start_tag(tag_items_data);
*index += [{val: crate_node_id, pos: ebml_w.writer.tell()}];
encode_info_for_mod(ecx, ebml_w, crate.node.module,
crate_node_id, [], "");
crate_node_id, [], @"");
visit::visit_crate(*crate, (), visit::mk_vt(@{
visit_expr: {|_e, _cx, _v|},
visit_item: {|i, cx, v, copy ebml_w|
@ -816,7 +817,7 @@ fn encode_info_for_items(ecx: @encode_ctxt, ebml_w: ebml::writer,
/* encode ctor, then encode items */
alt i.node {
item_class(tps, _, _, ctor, m_dtor, _) {
#debug("encoding info for ctor %s %d", i.ident,
#debug("encoding info for ctor %s %d", *i.ident,
ctor.node.id);
*index += [{val: ctor.node.id, pos: ebml_w.writer.tell()}];
encode_info_for_fn(ecx, ebml_w, ctor.node.id, i.ident,
@ -898,7 +899,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
meta_word(name) {
ebml_w.start_tag(tag_meta_item_word);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
ebml_w.end_tag();
}
@ -907,10 +908,10 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
lit_str(value) {
ebml_w.start_tag(tag_meta_item_name_value);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
ebml_w.start_tag(tag_meta_item_value);
ebml_w.writer.write(str::bytes(value));
ebml_w.writer.write(str::bytes(*value));
ebml_w.end_tag();
ebml_w.end_tag();
}
@ -920,7 +921,7 @@ fn encode_meta_item(ebml_w: ebml::writer, mi: meta_item) {
meta_list(name, items) {
ebml_w.start_tag(tag_meta_item_list);
ebml_w.start_tag(tag_meta_item_name);
ebml_w.writer.write(str::bytes(name));
ebml_w.writer.write(str::bytes(*name));
ebml_w.end_tag();
for items.each {|inner_item|
encode_meta_item(ebml_w, *inner_item);
@ -949,22 +950,22 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] {
fn synthesize_link_attr(ecx: @encode_ctxt, items: [@meta_item]) ->
attribute {
assert (ecx.link_meta.name != "");
assert (ecx.link_meta.vers != "");
assert (*ecx.link_meta.name != "");
assert (*ecx.link_meta.vers != "");
let name_item =
attr::mk_name_value_item_str("name", ecx.link_meta.name);
attr::mk_name_value_item_str(@"name", *ecx.link_meta.name);
let vers_item =
attr::mk_name_value_item_str("vers", ecx.link_meta.vers);
attr::mk_name_value_item_str(@"vers", *ecx.link_meta.vers);
let other_items =
{
let tmp = attr::remove_meta_items_by_name(items, "name");
attr::remove_meta_items_by_name(tmp, "vers")
let tmp = attr::remove_meta_items_by_name(items, @"name");
attr::remove_meta_items_by_name(tmp, @"vers")
};
let meta_items = [name_item, vers_item] + other_items;
let link_item = attr::mk_list_item("link", meta_items);
let link_item = attr::mk_list_item(@"link", meta_items);
ret attr::mk_attr(link_item);
}
@ -973,7 +974,7 @@ fn synthesize_crate_attrs(ecx: @encode_ctxt, crate: @crate) -> [attribute] {
let mut found_link_attr = false;
for crate.node.attrs.each {|attr|
attrs +=
if attr::get_attr_name(attr) != "link" {
if *attr::get_attr_name(attr) != "link" {
[attr]
} else {
alt attr.node.value.node {
@ -1000,9 +1001,9 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
// Pull the cnums and name,vers,hash out of cstore
let mut deps: [mut numdep] = [mut];
cstore::iter_crate_data(cstore) {|key, val|
let dep = {cnum: key, name: val.name,
let dep = {cnum: key, name: @val.name,
vers: decoder::get_crate_vers(val.data),
hash: decoder::get_crate_hash(val.data)};
hash: decoder::get_crate_hash(val.data)};
deps += [mut dep];
};
@ -1036,13 +1037,13 @@ fn encode_crate_deps(ebml_w: ebml::writer, cstore: cstore::cstore) {
fn encode_crate_dep(ebml_w: ebml::writer, dep: decoder::crate_dep) {
ebml_w.start_tag(tag_crate_dep);
ebml_w.start_tag(tag_crate_dep_name);
ebml_w.writer.write(str::bytes(dep.name));
ebml_w.writer.write(str::bytes(*dep.name));
ebml_w.end_tag();
ebml_w.start_tag(tag_crate_dep_vers);
ebml_w.writer.write(str::bytes(dep.vers));
ebml_w.writer.write(str::bytes(*dep.vers));
ebml_w.end_tag();
ebml_w.start_tag(tag_crate_dep_hash);
ebml_w.writer.write(str::bytes(dep.hash));
ebml_w.writer.write(str::bytes(*dep.hash));
ebml_w.end_tag();
ebml_w.end_tag();
}

View File

@ -44,7 +44,7 @@ fn load_library_crate(cx: ctxt) -> {ident: str, data: @[u8]} {
some(t) { ret t; }
none {
cx.diag.span_fatal(
cx.span, #fmt["can't find crate for '%s'", cx.ident]);
cx.span, #fmt["can't find crate for '%s'", *cx.ident]);
}
}
}
@ -69,7 +69,7 @@ fn find_library_crate_aux(cx: ctxt,
filesearch: filesearch::filesearch) ->
option<{ident: str, data: @[u8]}> {
let crate_name = crate_name_from_metas(cx.metas);
let prefix: str = nn.prefix + crate_name + "-";
let prefix: str = nn.prefix + *crate_name + "-";
let suffix: str = nn.suffix;
let mut matches = [];
@ -107,7 +107,7 @@ fn find_library_crate_aux(cx: ctxt,
some(matches[0])
} else {
cx.diag.span_err(
cx.span, #fmt("multiple matching crates for `%s`", crate_name));
cx.span, #fmt("multiple matching crates for `%s`", *crate_name));
cx.diag.handler().note("candidates:");
for matches.each {|match|
cx.diag.handler().note(#fmt("path: %s", match.ident));
@ -119,7 +119,7 @@ fn find_library_crate_aux(cx: ctxt,
}
}
fn crate_name_from_metas(metas: [@ast::meta_item]) -> str {
fn crate_name_from_metas(metas: [@ast::meta_item]) -> @str {
let name_items = attr::find_meta_items_by_name(metas, "name");
alt vec::last_opt(name_items) {
some(i) {
@ -146,7 +146,7 @@ fn crate_matches(crate_data: @[u8], metas: [@ast::meta_item], hash: str) ->
let linkage_metas = attr::find_linkage_metas(attrs);
if hash.is_not_empty() {
let chash = decoder::get_crate_hash(crate_data);
if chash != hash { ret false; }
if *chash != hash { ret false; }
}
metadata_matches(linkage_metas, metas)
}

View File

@ -46,7 +46,7 @@ fn parse_ident_(st: @pstate, is_last: fn@(char) -> bool) ->
while !is_last(peek(st)) {
rslt += str::from_byte(next_byte(st));
}
ret rslt;
ret @rslt;
}
@ -210,7 +210,7 @@ fn parse_bound_region(st: @pstate) -> ty::bound_region {
alt check next(st) {
's' { ty::br_self }
'a' { ty::br_anon }
'[' { ty::br_named(parse_str(st, ']')) }
'[' { ty::br_named(@parse_str(st, ']')) }
}
}
@ -322,7 +322,7 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
assert (next(st) == '[');
let mut fields: [ty::field] = [];
while peek(st) != ']' {
let name = parse_str(st, '=');
let name = @parse_str(st, '=');
fields += [{ident: name, mt: parse_mt(st, conv)}];
}
st.pos = st.pos + 1u;

View File

@ -157,7 +157,7 @@ fn enc_bound_region(w: io::writer, br: ty::bound_region) {
ty::br_anon { w.write_char('a') }
ty::br_named(s) {
w.write_char('[');
w.write_str(s);
w.write_str(*s);
w.write_char(']')
}
}
@ -256,7 +256,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
ty::ty_rec(fields) {
w.write_str("R["/&);
for fields.each {|field|
w.write_str(field.ident);
w.write_str(*field.ident);
w.write_char('=');
enc_mt(w, cx, field.mt);
}

View File

@ -83,7 +83,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
ii: ast::inlined_item,
maps: maps) {
#debug["> Encoding inlined item: %s::%s (%u)",
ast_map::path_to_str(path), ii.ident(),
ast_map::path_to_str(path), *ii.ident(),
ebml_w.writer.tell()];
let id_range = compute_id_range(ii);
@ -94,7 +94,7 @@ fn encode_inlined_item(ecx: @e::encode_ctxt,
}
#debug["< Encoded inlined fn: %s::%s (%u)",
ast_map::path_to_str(path), ii.ident(),
ast_map::path_to_str(path), *ii.ident(),
ebml_w.writer.tell()];
}
@ -117,10 +117,10 @@ fn decode_inlined_item(cdata: cstore::crate_metadata,
let ii = renumber_ast(xcx, raw_ii);
ast_map::map_decoded_item(tcx.sess.diagnostic(),
dcx.tcx.items, path, ii);
#debug["Fn named: %s", ii.ident()];
#debug["Fn named: %s", *ii.ident()];
decode_side_tables(xcx, ast_doc);
#debug["< Decoded inlined fn: %s::%s",
ast_map::path_to_str(path), ii.ident()];
ast_map::path_to_str(path), *ii.ident()];
alt ii {
ast::ii_item(i) {
#debug(">>> DECODED ITEM >>>\n%s\n<<< DECODED ITEM <<<",

View File

@ -241,7 +241,7 @@ enum comp_kind {
comp_tuple, // elt in a tuple
comp_res, // data for a resource
comp_variant(ast::def_id), // internals to a variant of given enum
comp_field(str, // name of field
comp_field(ast::ident, // name of field
ast::mutability), // declared mutability of field
comp_index(ty::t, // type of vec/str/etc being deref'd
ast::mutability) // mutability of vec content
@ -409,7 +409,7 @@ impl to_str_methods for borrowck_ctxt {
fn comp_to_repr(comp: comp_kind) -> str {
alt comp {
comp_field(fld, _) { fld }
comp_field(fld, _) { *fld }
comp_index(*) { "[]" }
comp_tuple { "()" }
comp_res { "<res>" }

View File

@ -295,14 +295,15 @@ impl public_methods for borrowck_ctxt {
ret @{cat:cat_discr(cmt, alt_id) with *cmt};
}
fn cat_field<N:ast_node>(node: N, base_cmt: cmt, f_name: str) -> cmt {
fn cat_field<N:ast_node>(node: N, base_cmt: cmt,
f_name: ast::ident) -> cmt {
let f_mutbl = alt field_mutbl(self.tcx, base_cmt.ty, f_name) {
some(f_mutbl) { f_mutbl }
none {
self.tcx.sess.span_bug(
node.span(),
#fmt["Cannot find field `%s` in type `%s`",
f_name, ty_to_str(self.tcx, base_cmt.ty)]);
*f_name, ty_to_str(self.tcx, base_cmt.ty)]);
}
};
let m = alt f_mutbl {
@ -427,7 +428,7 @@ impl private_methods for borrowck_ctxt {
fn field_mutbl(tcx: ty::ctxt,
base_ty: ty::t,
f_name: str) -> option<ast::mutability> {
f_name: ast::ident) -> option<ast::mutability> {
// Need to refactor so that records/class fields can be treated uniformly.
alt ty::get(base_ty).struct {
ty::ty_rec(fields) {

View File

@ -44,7 +44,7 @@ fn check_capture_clause(tcx: ty::ctxt,
tcx.sess.span_warn(
cap_item.span,
#fmt("captured variable '%s' not used in closure",
cap_item.name));
*cap_item.name));
}
let cap_def_id = ast_util::def_id_of_def(cap_def).node;
@ -52,7 +52,7 @@ fn check_capture_clause(tcx: ty::ctxt,
tcx.sess.span_err(
cap_item.span,
#fmt("variable '%s' captured more than once",
cap_item.name));
*cap_item.name));
}
}
}
@ -68,7 +68,7 @@ fn compute_capture_vars(tcx: ty::ctxt,
for (*cap_clause).each { |cap_item|
#debug("Doing capture var: %s (%?)",
cap_item.name, cap_item.id);
*cap_item.name, cap_item.id);
let cap_def = tcx.def_map.get(cap_item.id);
let cap_def_id = ast_util::def_id_of_def(cap_def).node;

View File

@ -67,8 +67,8 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) {
alt ty::get(ty).struct {
ty::ty_bool {
alt check ctor {
val(const_int(1i64)) { some("true") }
val(const_int(0i64)) { some("false") }
val(const_int(1i64)) { some(@"true") }
val(const_int(0i64)) { some(@"false") }
}
}
ty::ty_enum(id, _) {
@ -83,7 +83,7 @@ fn check_exhaustive(tcx: ty::ctxt, sp: span, pats: [@pat]) {
}
};
let msg = "non-exhaustive patterns" + alt ext {
some(s) { ": " + s + " not covered" }
some(s) { ": " + *s + " not covered" }
none { "" }
};
tcx.sess.span_err(sp, msg);

View File

@ -108,11 +108,11 @@ fn eval_const_expr(tcx: middle::ty::ctxt, e: @expr) -> const_val {
fn lit_to_const(lit: @lit) -> const_val {
alt lit.node {
lit_str(s) { const_str(s) }
lit_str(s) { const_str(*s) }
lit_int(n, _) { const_int(n) }
lit_uint(n, _) { const_uint(n) }
lit_int_unsuffixed(n, _) { const_int(n) }
lit_float(n, _) { const_float(option::get(float::from_str(n)) as f64) }
lit_float(n, _) { const_float(option::get(float::from_str(*n)) as f64) }
lit_nil { const_int(0i64) }
lit_bool(b) { const_int(b as i64) }
}

View File

@ -210,7 +210,7 @@ impl methods for ctxt {
for metas.each {|meta|
alt meta.node {
ast::meta_word(lintname) {
alt lookup_lint(self.dict, lintname) {
alt lookup_lint(self.dict, *lintname) {
(name, none) {
self.span_lint(
self.get_level(unrecognized_warning),
@ -444,7 +444,7 @@ fn check_item_old_vecs(cx: ty::ctxt, it: @ast::item) {
ast::ty_path(@{span: _, global: _, idents: ids,
rp: none, types: _}, _)
if ids == ["str"] && (! uses_vstore.contains_key(t.id)) {
if ids == [@"str"] && (! uses_vstore.contains_key(t.id)) {
cx.sess.span_lint(
old_vecs, it.id, t.id,
t.span, "deprecated str type");

View File

@ -45,7 +45,7 @@ of `f`.
*/
import dvec::{dvec, extensions};
import std::map::{hashmap, int_hash, str_hash};
import std::map::{hashmap, int_hash, str_hash, box_str_hash};
import syntax::{visit, ast_util};
import syntax::print::pprust::{expr_to_str};
import visit::vt;
@ -134,9 +134,9 @@ enum relevant_def { rdef_var(node_id), rdef_self }
type capture_info = {ln: live_node, is_move: bool, rv: relevant_def};
enum var_kind {
vk_arg(node_id, str, rmode),
vk_local(node_id, str),
vk_field(str),
vk_arg(node_id, ident, rmode),
vk_local(node_id, ident),
vk_field(ident),
vk_self,
vk_implicit_ret
}
@ -158,7 +158,7 @@ class ir_maps {
let mut num_vars: uint;
let live_node_map: hashmap<node_id, live_node>;
let variable_map: hashmap<node_id, variable>;
let field_map: hashmap<str, variable>;
let field_map: hashmap<ident, variable>;
let capture_map: hashmap<node_id, @[capture_info]>;
let mut var_kinds: [var_kind];
let mut lnks: [live_node_kind];
@ -174,7 +174,7 @@ class ir_maps {
self.live_node_map = int_hash();
self.variable_map = int_hash();
self.capture_map = int_hash();
self.field_map = str_hash();
self.field_map = box_str_hash();
self.var_kinds = [];
self.lnks = [];
}
@ -227,12 +227,12 @@ class ir_maps {
}
}
fn variable_name(var: variable) -> str {
fn variable_name(var: variable) -> ident {
alt self.var_kinds[*var] {
vk_local(_, name) | vk_arg(_, name, _) {name}
vk_field(name) {"self." + name}
vk_self {"self"}
vk_implicit_ret {"<implicit-ret>"}
vk_field(name) {@("self." + *name)}
vk_self {@"self"}
vk_implicit_ret {@"<implicit-ret>"}
}
}
@ -1208,7 +1208,8 @@ class liveness {
}
}
fn as_self_field(expr: @expr, fld: str) -> option<(live_node,variable)> {
fn as_self_field(expr: @expr,
fld: ident) -> option<(live_node,variable)> {
// If we checking a constructor, then we treat self.f as a
// variable. we use the live_node id that will be assigned to
// the reference to self but the variable id for `f`.
@ -1429,7 +1430,7 @@ impl check_methods for @liveness {
none { /* ok */ }
some(lnk_exit) {
self.tcx.sess.span_err(
sp, #fmt["field `self.%s` is never initialized", nm]);
sp, #fmt["field `self.%s` is never initialized", *nm]);
}
some(lnk) {
self.report_illegal_read(
@ -1605,13 +1606,13 @@ impl check_methods for @liveness {
self.tcx.sess.span_err(
move_span,
#fmt["illegal move from argument `%s`, which is not \
copy or move mode", name]);
copy or move mode", *name]);
ret;
}
vk_field(name) {
self.tcx.sess.span_err(
move_span,
#fmt["illegal move from field `%s`", name]);
#fmt["illegal move from field `%s`", *name]);
ret;
}
vk_local(*) | vk_self | vk_implicit_ret {
@ -1643,12 +1644,12 @@ impl check_methods for @liveness {
lnk_freevar(span) {
self.tcx.sess.span_err(
span,
#fmt["capture of %s: `%s`", msg, name]);
#fmt["capture of %s: `%s`", msg, *name]);
}
lnk_expr(span) {
self.tcx.sess.span_err(
span,
#fmt["use of %s: `%s`", msg, name]);
#fmt["use of %s: `%s`", msg, *name]);
}
lnk_exit |
lnk_vdef(_) {
@ -1659,9 +1660,9 @@ impl check_methods for @liveness {
}
}
fn should_warn(var: variable) -> option<str> {
fn should_warn(var: variable) -> option<ident> {
let name = (*self.ir).variable_name(var);
if name[0] == ('_' as u8) {none} else {some(name)}
if (*name)[0] == ('_' as u8) {none} else {some(name)}
}
fn warn_about_unused_args(sp: span, decl: fn_decl, entry_ln: live_node) {
@ -1712,10 +1713,10 @@ impl check_methods for @liveness {
if is_assigned {
self.tcx.sess.span_warn(
sp, #fmt["variable `%s` is assigned to, \
but never used", name]);
but never used", *name]);
} else {
self.tcx.sess.span_warn(
sp, #fmt["unused variable: `%s`", name]);
sp, #fmt["unused variable: `%s`", *name]);
}
}
ret true;
@ -1728,7 +1729,7 @@ impl check_methods for @liveness {
for self.should_warn(var).each { |name|
self.tcx.sess.span_warn(
sp,
#fmt["value assigned to `%s` is never read", name]);
#fmt["value assigned to `%s` is never read", *name]);
}
}
}

View File

@ -9,12 +9,12 @@ import std::map::hashmap;
export pat_binding_ids, pat_bindings, pat_id_map;
export pat_is_variant;
type pat_id_map = std::map::hashmap<str, node_id>;
type pat_id_map = std::map::hashmap<ident, node_id>;
// This is used because same-named variables in alternative patterns need to
// use the node_id of their namesake in the first pattern.
fn pat_id_map(dm: resolve::def_map, pat: @pat) -> pat_id_map {
let map = std::map::str_hash();
let map = std::map::box_str_hash();
pat_bindings(dm, pat) {|p_id, _s, n|
map.insert(path_to_ident(n), p_id);
};

View File

@ -9,7 +9,7 @@ import syntax::attr;
import metadata::{csearch, cstore};
import driver::session::session;
import util::common::is_main_name;
import std::map::{int_hash, str_hash, hashmap};
import std::map::{int_hash, str_hash, box_str_hash, hashmap};
import vec::each;
import syntax::codemap::span;
import syntax::visit;
@ -68,16 +68,16 @@ enum glob_import_state {
option<def>), /* module */
}
type ext_hash = hashmap<{did: def_id, ident: str, ns: namespace}, def>;
type ext_hash = hashmap<{did: def_id, ident: ast::ident, ns: namespace}, def>;
fn new_ext_hash() -> ext_hash {
type key = {did: def_id, ident: str, ns: namespace};
type key = {did: def_id, ident: ast::ident, ns: namespace};
fn hash(v: key) -> uint {
str::hash(v.ident) + ast_util::hash_def(v.did) + v.ns as uint
str::hash(*v.ident) + ast_util::hash_def(v.did) + v.ns as uint
}
fn eq(v1: key, v2: key) -> bool {
ret ast_util::def_eq(v1.did, v2.did) &&
str::eq(v1.ident, v2.ident) && v1.ns == v2.ns;
str::eq(*v1.ident, *v2.ident) && v1.ns == v2.ns;
}
std::map::hashmap(hash, {|a, b| a == b})
}
@ -102,7 +102,7 @@ type indexed_mod = {
index: mod_index,
glob_imports: dvec<glob_imp_def>,
mut globbed_exports: [ident],
glob_imported_names: hashmap<str, glob_import_state>,
glob_imported_names: hashmap<ident, glob_import_state>,
path: str
};
@ -132,7 +132,7 @@ type env =
ext_cache: ext_hash,
used_imports: {mut track: bool,
mut data: [node_id]},
reported: dvec<{ident: str, sc: scope}>,
reported: dvec<{ident: ast::ident, sc: scope}>,
mut ignored_imports: [node_id],
mut current_tp: option<uint>,
mut resolve_unexported: bool,
@ -256,7 +256,7 @@ fn map_crate(e: @env, c: @ast::crate) {
let mut path = n + "::";
list::iter(sc) {|s|
alt s {
scope_item(i) { path = i.ident + "::" + path; }
scope_item(i) { path = *i.ident + "::" + path; }
_ {}
}
}
@ -272,8 +272,8 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_mod(md),
glob_imports: dvec(),
mut globbed_exports: [],
glob_imported_names: str_hash(),
path: path_from_scope(sc, i.ident)});
glob_imported_names: box_str_hash(),
path: path_from_scope(sc, *i.ident)});
}
ast::item_native_mod(nmd) {
e.mod_map.insert(i.id,
@ -281,8 +281,8 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_nmod(nmd),
glob_imports: dvec(),
mut globbed_exports: [],
glob_imported_names: str_hash(),
path: path_from_scope(sc, i.ident)});
glob_imported_names: box_str_hash(),
path: path_from_scope(sc, *i.ident)});
}
_ { }
}
@ -340,7 +340,7 @@ fn map_crate(e: @env, c: @ast::crate) {
index: index_mod(c.node.module),
glob_imports: dvec(),
mut globbed_exports: [],
glob_imported_names: str_hash(),
glob_imported_names: box_str_hash(),
path: ""});
// Next, assemble the links for globbed imports and exports.
@ -377,10 +377,10 @@ fn check_unused_imports(e: @env, level: lint::level) {
if !vec::contains(e.used_imports.data, k) {
alt level {
lint::warn {
e.sess.span_warn(sp, "unused import " + name);
e.sess.span_warn(sp, "unused import " + *name);
}
lint::error {
e.sess.span_err(sp, "unused import " + name);
e.sess.span_err(sp, "unused import " + *name);
}
lint::ignore {
}
@ -518,7 +518,7 @@ fn resolve_names(e: @env, c: @ast::crate) {
}
some(fnd@ast::def_const(_)) {
e.sess.span_err(p.span, "pattern variable conflicts \
with constant '" + path_to_ident(p) + "'");
with constant '" + *path_to_ident(p) + "'");
}
// Binds a var -- nothing needs to be done
_ {}
@ -701,7 +701,7 @@ fn visit_local_with_scope(e: @env, loc: @local, &&sc: scopes, v:vt<scopes>) {
e.sess.span_err(loc.span,
#fmt("declaration of `%s` shadows an \
enum that's in scope",
path_to_ident(path)));
*path_to_ident(path)));
}
_ {}
}
@ -734,7 +734,7 @@ fn follow_import(e: env, &&sc: scopes, path: [ident], sp: span) ->
alt dcur {
some(ast::def_mod(_)) | some(ast::def_native_mod(_)) { ret dcur; }
_ {
e.sess.span_err(sp, str::connect(path, "::") +
e.sess.span_err(sp, str::connect(path.map({|x|*x}), "::") +
" does not name a module.");
ret none;
}
@ -860,7 +860,7 @@ fn resolve_import(e: env, n_id: node_id, name: ast::ident,
// import
alt e.imports.find(n_id) {
some(resolving(sp)) {
e.imports.insert(n_id, resolved(none, none, none, @[], "", sp));
e.imports.insert(n_id, resolved(none, none, none, @[], @"", sp));
}
_ { }
}
@ -897,7 +897,7 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
alt find_fn_or_mod_scope(sc) {
some(err_scope) {
for e.reported.each {|rs|
if str::eq(rs.ident, name) && err_scope == rs.sc { ret; }
if str::eq(*rs.ident, *name) && err_scope == rs.sc { ret; }
}
e.reported.push({ident: name, sc: err_scope});
}
@ -907,10 +907,10 @@ fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
in_mod(def) {
let did = def_id_of_def(def);
if did.crate == ast::local_crate {
path = e.mod_map.get(did.node).path + path;
path = @(e.mod_map.get(did.node).path + *path);
} else if did.node != ast::crate_node_id {
let paths = e.ext_map.get(did);
path = str::connect(paths + [path], "::");
path = @str::connect((paths + [path]).map({|x|*x}), "::");
}
}
}
@ -922,7 +922,7 @@ fn unresolved_fatal(e: env, sp: span, id: ident, kind: str) -> ! {
}
fn mk_unresolved_msg(id: ident, kind: str) -> str {
ret #fmt["unresolved %s: %s", kind, id];
ret #fmt["unresolved %s: %s", kind, *id];
}
// Lookup helpers
@ -1010,7 +1010,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
alt s {
scope_toplevel {
if ns == ns_type {
ret some(ast::def_prim_ty(alt name {
ret some(ast::def_prim_ty(alt *name {
"bool" { ast::ty_bool }
"int" { ast::ty_int(ast::ty_i) }
"uint" { ast::ty_uint(ast::ty_u) }
@ -1045,7 +1045,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
}
ast::item_iface(tps, _, _) {
if ns == ns_type {
if name == "self" {
if *name == "self" {
ret some(def_self(it.id));
}
ret lookup_in_ty_params(e, name, tps);
@ -1070,7 +1070,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
}
}
scope_method(id, tps) {
if (name == "self" && ns == ns_val) {
if (*name == "self" && ns == ns_val) {
ret some(ast::def_self(id));
} else if ns == ns_type {
ret lookup_in_ty_params(e, name, tps);
@ -1135,7 +1135,7 @@ fn lookup_in_scope(e: env, &&sc: scopes, sp: span, name: ident, ns: namespace,
let mut i = vec::len(closing);
while i > 0u {
i -= 1u;
#debug["name=%s df=%?", name, df];
#debug["name=%s df=%?", *name, df];
assert def_is_local(df) || def_is_self(df);
let df_id = def_id_of_def(df).node;
df = ast::def_upvar(df_id, @df, closing[i]);
@ -1164,7 +1164,7 @@ fn lookup_in_ty_params(e: env, name: ident, ty_params: [ast::ty_param])
-> option<def> {
let mut n = 0u;
for ty_params.each {|tp|
if str::eq(tp.ident, name) && alt e.current_tp {
if str::eq(*tp.ident, *name) && alt e.current_tp {
some(cur) { n < cur } none { true }
} { ret some(ast::def_ty_param(local_def(tp.id), n)); }
n += 1u;
@ -1176,7 +1176,7 @@ fn lookup_in_pat(e: env, name: ident, pat: @ast::pat) -> option<node_id> {
let mut found = none;
pat_util::pat_bindings(e.def_map, pat) {|p_id, _sp, n|
if str::eq(path_to_ident(n), name)
if str::eq(*path_to_ident(n), *name)
{ found = some(p_id); }
};
ret found;
@ -1188,7 +1188,7 @@ fn lookup_in_fn(e: env, name: ident, decl: ast::fn_decl,
alt ns {
ns_val {
for decl.inputs.each {|a|
if str::eq(a.ident, name) {
if str::eq(*a.ident, *name) {
ret some(ast::def_arg(a.id, a.mode));
}
}
@ -1231,14 +1231,14 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
alt it.node {
ast::item_enum(variants, _, _) {
if ns == ns_type {
if str::eq(it.ident, name) {
if str::eq(*it.ident, *name) {
ret some(ast::def_ty(local_def(it.id)));
}
} else {
alt ns {
ns_val {
for variants.each {|v|
if str::eq(v.node.name, name) {
if str::eq(*v.node.name, *name) {
let i = v.node.id;
ret some(ast::def_variant
(local_def(it.id), local_def(i)));
@ -1250,7 +1250,7 @@ fn lookup_in_block(e: env, name: ident, sp: span, b: ast::blk_, pos: uint,
}
}
_ {
if str::eq(it.ident, name) {
if str::eq(*it.ident, *name) {
let found = found_def_item(it, ns);
if !is_none(found) {
ret found;
@ -1521,9 +1521,9 @@ fn lookup_in_globs(e: env, globs: [glob_imp_def], sp: span, id: ident,
} else {
for matches.each {|match|
let sp = match.path.span;
e.sess.span_note(sp, #fmt["'%s' is imported here", id]);
e.sess.span_note(sp, #fmt["'%s' is imported here", *id]);
}
e.sess.span_fatal(sp, "'" + id + "' is glob-imported from" +
e.sess.span_fatal(sp, "'" + *id + "' is glob-imported from" +
" multiple different modules.");
}
}
@ -1627,7 +1627,7 @@ fn index_view_items(view_items: [@ast::view_item],
}
fn index_mod(md: ast::_mod) -> mod_index {
let index = str_hash::<@list<mod_index_entry>>();
let index = box_str_hash::<@list<mod_index_entry>>();
index_view_items(md.view_items, index);
@ -1667,7 +1667,7 @@ fn index_mod(md: ast::_mod) -> mod_index {
fn index_nmod(md: ast::native_mod) -> mod_index {
let index = str_hash::<@list<mod_index_entry>>();
let index = box_str_hash::<@list<mod_index_entry>>();
index_view_items(md.view_items, index);
@ -1727,7 +1727,7 @@ fn check_mod_name(e: env, name: ident, entries: @list<mod_index_entry>) {
let mut saw_value = false;
let mut entries = entries;
fn dup(e: env, sp: span, word: str, name: ident) {
e.sess.span_fatal(sp, "duplicate definition of " + word + name);
e.sess.span_fatal(sp, "duplicate definition of " + word + *name);
}
loop {
alt *entries {
@ -1817,11 +1817,11 @@ fn check_arm(e: @env, a: ast::arm, &&x: (), v: vt<()>) {
"inconsistent number of bindings");
} else {
for ch.seen.each {|name|
if is_none(vec::find(seen0, bind str::eq(name, _))) {
if is_none(vec::find(seen0, {|x|str::eq(*name, *x)})) {
// Fight the alias checker
let name_ = name;
e.sess.span_err(a.pats[i].span,
"binding " + name_ +
"binding " + *name_ +
" does not occur in first pattern");
}
}
@ -1915,8 +1915,9 @@ fn checker(e: env, kind: str) -> checker {
fn check_name(ch: checker, sp: span, name: ident) {
for ch.seen.each {|s|
if str::eq(s, name) {
ch.sess.span_fatal(sp, "duplicate " + ch.kind + " name: " + name);
if str::eq(*s, *name) {
ch.sess.span_fatal(
sp, "duplicate " + ch.kind + " name: " + *name);
}
}
}
@ -2000,7 +2001,7 @@ fn check_exports(e: @env) {
e.exp_map.insert(export_id, found + [{reexp: reexp, id: target_id}]);
}
fn check_export(e: @env, ident: str, _mod: @indexed_mod,
fn check_export(e: @env, ident: ident, _mod: @indexed_mod,
export_id: node_id, vi: @view_item) {
let mut found_something = false;
if _mod.index.contains_key(ident) {
@ -2036,7 +2037,7 @@ fn check_exports(e: @env) {
lookup_glob_any(e, _mod, vi.span, ident, export_id);
if !found_something {
e.sess.span_warn(vi.span,
#fmt("exported item %s is not defined", ident));
#fmt("exported item %s is not defined", *ident));
}
}
@ -2044,7 +2045,7 @@ fn check_exports(e: @env) {
-> node_id {
alt _mod.index.find(id) {
none {
e.sess.span_fatal(sp, #fmt("undefined id %s in an export", id));
e.sess.span_fatal(sp, #fmt("undefined id %s in an export", *id));
}
some(ms) {
let maybe_id = list_search(ms) {|m|
@ -2056,7 +2057,7 @@ fn check_exports(e: @env) {
alt maybe_id {
some(an_id) { an_id }
_ { e.sess.span_fatal(sp, #fmt("%s does not refer \
to an enumeration", id)); }
to an enumeration", *id)); }
}
}
}
@ -2079,7 +2080,7 @@ fn check_exports(e: @env) {
e.sess.span_err(
span, #fmt("variant %s doesn't belong to \
enum %s",
variant_id.node.name, id));
*variant_id.node.name, *id));
}
}
_ {}
@ -2090,7 +2091,7 @@ fn check_exports(e: @env) {
}
if !found {
e.sess.span_err(span, #fmt("%s is not a variant",
variant_id.node.name));
*variant_id.node.name));
}
}
}

View File

@ -78,9 +78,9 @@ fn variant_opt(tcx: ty::ctxt, pat_id: ast::node_id) -> opt {
}
type bind_map = [{ident: ast::ident, val: ValueRef}];
fn assoc(key: str, list: bind_map) -> option<ValueRef> {
fn assoc(key: ast::ident, list: bind_map) -> option<ValueRef> {
for vec::each(list) {|elt|
if str::eq(elt.ident, key) { ret some(elt.val); }
if str::eq(*elt.ident, *key) { ret some(elt.val); }
}
ret none;
}
@ -194,7 +194,7 @@ fn enter_rec(dm: def_map, m: match, col: uint, fields: [ast::ident],
for vec::each(fields) {|fname|
let mut pat = dummy;
for vec::each(fpats) {|fpat|
if str::eq(fpat.ident, fname) { pat = fpat.pat; break; }
if str::eq(*fpat.ident, *fname) { pat = fpat.pat; break; }
}
pats += [pat];
}
@ -287,12 +287,12 @@ fn extract_variant_args(bcx: block, pat_id: ast::node_id,
}
fn collect_record_fields(m: match, col: uint) -> [ast::ident] {
let mut fields = [];
let mut fields: [ast::ident] = [];
for vec::each(m) {|br|
alt br.pats[col].node {
ast::pat_rec(fs, _) {
for vec::each(fs) {|f|
if !vec::any(fields, bind str::eq(f.ident, _)) {
if !vec::any(fields, {|x| str::eq(*f.ident, *x)}) {
fields += [f.ident];
}
}

View File

@ -513,8 +513,8 @@ fn declare_tydesc(ccx: @crate_ctxt, t: ty::t) -> @tydesc_info {
let mut name;
//XXX this triggers duplicate LLVM symbols
if false /*ccx.sess.opts.debuginfo*/ {
name = mangle_internal_name_by_type_only(ccx, t, "tydesc");
} else { name = mangle_internal_name_by_seq(ccx, "tydesc"); }
name = mangle_internal_name_by_type_only(ccx, t, @"tydesc");
} else { name = mangle_internal_name_by_seq(ccx, @"tydesc"); }
note_unique_llvm_symbol(ccx, name);
let gvar = str::as_c_str(name, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, ccx.tydesc_type, buf)
@ -541,9 +541,9 @@ fn declare_generic_glue(ccx: @crate_ctxt, t: ty::t, llfnty: TypeRef,
let mut fn_nm;
//XXX this triggers duplicate LLVM symbols
if false /*ccx.sess.opts.debuginfo*/ {
fn_nm = mangle_internal_name_by_type_only(ccx, t, "glue_" + name);
fn_nm = mangle_internal_name_by_type_only(ccx, t, @("glue_" + name));
} else {
fn_nm = mangle_internal_name_by_seq(ccx, "glue_" + name);
fn_nm = mangle_internal_name_by_seq(ccx, @("glue_" + name));
}
note_unique_llvm_symbol(ccx, fn_nm);
let llfn = decl_cdecl_fn(ccx.llmod, fn_nm, llfnty);
@ -697,8 +697,8 @@ fn incr_refcnt_of_boxed(cx: block, box_ptr: ValueRef) {
fn make_visit_glue(bcx: block, v: ValueRef, t: ty::t) {
let _icx = bcx.insn_ctxt("make_visit_glue");
let mut bcx = bcx;
assert bcx.ccx().tcx.intrinsic_ifaces.contains_key("ty_visitor");
let (iid, ty) = bcx.ccx().tcx.intrinsic_ifaces.get("ty_visitor");
assert bcx.ccx().tcx.intrinsic_ifaces.contains_key(@"ty_visitor");
let (iid, ty) = bcx.ccx().tcx.intrinsic_ifaces.get(@"ty_visitor");
let v = PointerCast(bcx, v, T_ptr(type_of::type_of(bcx.ccx(), ty)));
bcx = reflect::emit_calls_to_iface_visit_ty(bcx, t, v, iid);
build_return(bcx);
@ -1495,7 +1495,7 @@ fn trans_crate_lit(cx: @crate_ctxt, lit: ast::lit) -> ValueRef {
// to actually generate from this?
C_integral(T_int_ty(cx, t), i as u64, True)
}
ast::lit_float(fs, t) { C_floating(fs, T_float_ty(cx, t)) }
ast::lit_float(fs, t) { C_floating(*fs, T_float_ty(cx, t)) }
ast::lit_bool(b) { C_bool(b) }
ast::lit_nil { C_nil() }
ast::lit_str(s) {
@ -2158,7 +2158,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
ast_map::node_ctor(nm, _, ct, pt) { (pt, nm, alt ct {
ast_map::res_ctor(_, _, sp) { sp }
ast_map::class_ctor(ct_, _) { ct_.span }}) }
ast_map::node_dtor(_, dtor, _, pt) {(pt, "drop", dtor.span)}
ast_map::node_dtor(_, dtor, _, pt) {(pt, @"drop", dtor.span)}
ast_map::node_expr(*) { ccx.tcx.sess.bug("Can't monomorphize an expr") }
ast_map::node_export(*) {
ccx.tcx.sess.bug("Can't monomorphize an export")
@ -2184,7 +2184,7 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, real_substs: [ty::t],
}
ccx.monomorphizing.insert(fn_id, depth + 1u);
let pt = *pt + [path_name(ccx.names(name))];
let pt = *pt + [path_name(@ccx.names(*name))];
let s = mangle_exported_name(ccx, pt, mono_ty);
let mk_lldecl = {||
@ -3382,7 +3382,7 @@ fn trans_rec(bcx: block, fields: [ast::field],
let mut temp_cleanups = [];
for fields.each {|fld|
let ix = option::get(vec::position(ty_fields, {|ft|
str::eq(fld.node.ident, ft.ident)
str::eq(*fld.node.ident, *ft.ident)
}));
let dst = GEPi(bcx, addr, [0u, ix]);
bcx = trans_expr_save_in(bcx, fld.node.expr, dst);
@ -3395,7 +3395,7 @@ fn trans_rec(bcx: block, fields: [ast::field],
bcx = cx;
// Copy over inherited fields
for ty_fields.eachi {|i, tf|
if !vec::any(fields, {|f| str::eq(f.node.ident, tf.ident)}) {
if !vec::any(fields, {|f| str::eq(*f.node.ident, *tf.ident)}) {
let dst = GEPi(bcx, addr, [0u, i]);
let base = GEPi(bcx, base_val, [0u, i]);
let val = load_if_immediate(bcx, base, tf.mt.ty);
@ -3841,7 +3841,7 @@ fn trans_log(log_ex: @ast::expr, lvl: @ast::expr,
ccx.module_data.get(modname)
} else {
let s = link::mangle_internal_name_by_path_and_seq(
ccx, modpath, "loglevel");
ccx, modpath, @"loglevel");
let global = str::as_c_str(s, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf)
});
@ -4320,7 +4320,7 @@ fn alloc_local(cx: block, local: @ast::local) -> block {
let val = alloc_ty(cx, t);
if cx.sess().opts.debuginfo {
option::iter(simple_name) {|name|
str::as_c_str(name, {|buf|
str::as_c_str(*name, {|buf|
llvm::LLVMSetValueName(val, buf)
});
}
@ -4604,7 +4604,7 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
let fn_args = vec::map(variant.node.args, {|varg|
{mode: ast::expl(ast::by_copy),
ty: varg.ty,
ident: "arg",
ident: @"arg",
id: varg.id}
});
let fcx = new_fn_ctxt_w_id(ccx, [], llfndecl, variant.node.id,
@ -5122,7 +5122,7 @@ fn get_dtor_symbol(ccx: @crate_ctxt, path: path, id: ast::node_id) -> str {
some(s) { s }
none {
let s = mangle_exported_name(ccx, path +
[path_name(ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
[path_name(@ccx.names("dtor"))], ty::node_id_to_type(ccx.tcx, id));
ccx.item_symbols.insert(id, s);
s
}
@ -5164,7 +5164,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
// def_ids otherwise -- one to identify the type, and one to
// find the dtor symbol.
let t = ty::node_id_to_type(ccx.tcx, dtor_id);
register_fn_full(ccx, i.span, my_path + [path_name("dtor")],
register_fn_full(ccx, i.span, my_path + [path_name(@"dtor")],
i.id, t)
}
}
@ -5172,7 +5172,7 @@ fn get_item_val(ccx: @crate_ctxt, id: ast::node_id) -> ValueRef {
ast_map::node_method(m, impl_id, pth) {
exprt = true;
let mty = ty::node_id_to_type(ccx.tcx, id);
let pth = *pth + [path_name(ccx.names("meth")),
let pth = *pth + [path_name(@ccx.names("meth")),
path_name(m.ident)];
let llfn = register_fn_full(ccx, m.span, pth, id, mty);
set_inline_hint_if_appr(m.attrs, llfn);
@ -5248,7 +5248,7 @@ fn trans_constant(ccx: @crate_ctxt, it: @ast::item) {
let path = item_path(ccx, it);
for vec::each(variants) {|variant|
let p = path + [path_name(variant.node.name),
path_name("discrim")];
path_name(@"discrim")];
let s = mangle_exported_name(ccx, p, ty::mk_int(ccx.tcx));
let disr_val = vi[i].disr_val;
note_unique_llvm_symbol(ccx, s);
@ -5376,7 +5376,7 @@ fn decl_crate_map(sess: session::session, mapmeta: link_meta,
let cstore = sess.cstore;
while cstore::have_crate_data(cstore, n_subcrates) { n_subcrates += 1; }
let mapname = if sess.building_library {
mapmeta.name + "_" + mapmeta.vers + "_" + mapmeta.extras_hash
*mapmeta.name + "_" + *mapmeta.vers + "_" + mapmeta.extras_hash
} else { "toplevel" };
let sym_name = "_rust_crate_map_" + mapname;
let arrtype = T_array(int_type, n_subcrates as uint);
@ -5395,8 +5395,8 @@ fn fill_crate_map(ccx: @crate_ctxt, map: ValueRef) {
while cstore::have_crate_data(cstore, i) {
let cdata = cstore::get_crate_data(cstore, i);
let nm = "_rust_crate_map_" + cdata.name +
"_" + cstore::get_crate_vers(cstore, i) +
"_" + cstore::get_crate_hash(cstore, i);
"_" + *cstore::get_crate_vers(cstore, i) +
"_" + *cstore::get_crate_hash(cstore, i);
let cr = str::as_c_str(nm, {|buf|
llvm::LLVMAddGlobal(ccx.llmod, ccx.int_type, buf)
});
@ -5506,7 +5506,7 @@ fn trans_crate(sess: session::session, crate: @ast::crate, tcx: ty::ctxt,
// crashes if the module identifer is same as other symbols
// such as a function name in the module.
// 1. http://llvm.org/bugs/show_bug.cgi?id=11479
let llmod_id = link_meta.name + ".rc";
let llmod_id = *link_meta.name + ".rc";
let llmod = str::as_c_str(llmod_id, {|buf|
llvm::LLVMModuleCreateWithNameInContext

View File

@ -390,7 +390,7 @@ fn trans_expr_fn(bcx: block,
let ccx = bcx.ccx(), bcx = bcx;
let fty = node_id_type(bcx, id);
let llfnty = type_of_fn_from_ty(ccx, fty);
let sub_path = bcx.fcx.path + [path_name("anon")];
let sub_path = bcx.fcx.path + [path_name(@"anon")];
let s = mangle_internal_name_by_path(ccx, sub_path);
let llfn = decl_internal_cdecl_fn(ccx.llmod, s, llfnty);
@ -676,7 +676,7 @@ fn trans_bind_thunk(ccx: @crate_ctxt,
// construct and return that thunk.
// Give the thunk a name, type, and value.
let s = mangle_internal_name_by_path_and_seq(ccx, path, "thunk");
let s = mangle_internal_name_by_path_and_seq(ccx, path, @"thunk");
let llthunk_ty = get_pair_fn_ty(type_of(ccx, incoming_fty));
let llthunk = decl_internal_cdecl_fn(ccx.llmod, s, llthunk_ty);

View File

@ -933,7 +933,7 @@ fn path_str(p: path) -> str {
alt e { ast_map::path_name(s) | ast_map::path_mod(s) {
if first { first = false; }
else { r += "::"; }
r += s;
r += *s;
} }
}
r
@ -966,7 +966,7 @@ fn field_idx_strict(cx: ty::ctxt, sp: span, ident: ast::ident,
-> uint {
alt ty::field_idx(ident, fields) {
none { cx.sess.span_bug(sp, #fmt("base expr doesn't appear to \
have a field named %s", ident)); }
have a field named %s", *ident)); }
some(i) { i }
}
}

View File

@ -421,7 +421,7 @@ fn create_record(cx: @crate_ctxt, t: ty::t, fields: [ast::ty_field],
let field_t = ty::get_field(t, field.node.ident).mt.ty;
let ty_md = create_ty(cx, field_t, field.node.mt.ty);
let (size, align) = size_and_align_of(cx, field_t);
add_member(scx, field.node.ident,
add_member(scx, *field.node.ident,
line_from_span(cx.sess.codemap, field.span) as int,
size as int, align as int, ty_md.node);
}
@ -661,7 +661,7 @@ fn create_local_var(bcx: block, local: @ast::local)
none { create_function(bcx.fcx).node }
some(_) { create_block(bcx).node }
};
let mdnode = create_var(tg, context, name, filemd.node,
let mdnode = create_var(tg, context, *name, filemd.node,
loc.line as int, tymd.node);
let mdval = @{node: mdnode, data: {id: local.node.id}};
update_cache(cache, AutoVariableTag, local_var_metadata(mdval));
@ -703,7 +703,7 @@ fn create_arg(bcx: block, arg: ast::arg, sp: span)
let tymd = create_ty(cx, ty, arg.ty);
let filemd = create_file(cx, loc.file.name);
let context = create_function(bcx.fcx);
let mdnode = create_var(tg, context.node, arg.ident, filemd.node,
let mdnode = create_var(tg, context.node, *arg.ident, filemd.node,
loc.line as int, tymd.node);
let mdval = @{node: mdnode, data: {id: arg.id}};
update_cache(cache, tg, argument_metadata(mdval));
@ -769,10 +769,10 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
ast_map::node_expr(expr) {
alt expr.node {
ast::expr_fn(_, decl, _, _) {
(dbg_cx.names("fn"), decl.output, expr.id)
(@dbg_cx.names("fn"), decl.output, expr.id)
}
ast::expr_fn_block(decl, _, _) {
(dbg_cx.names("fn"), decl.output, expr.id)
(@dbg_cx.names("fn"), decl.output, expr.id)
}
_ { fcx.ccx.sess.span_bug(expr.span, "create_function: \
expected an expr_fn or fn_block here"); }
@ -810,8 +810,8 @@ fn create_function(fcx: fn_ctxt) -> @metadata<subprogram_md> {
let fn_metadata = [lltag(SubprogramTag),
llunused(),
file_node,
llstr(ident),
llstr(ident), //XXX fully-qualified C++ name
llstr(*ident),
llstr(*ident), //XXX fully-qualified C++ name
llstr(""), //XXX MIPS name?????
file_node,
lli32(loc.line as int),

View File

@ -421,8 +421,8 @@ fn decl_x86_64_fn(tys: x86_64_tys,
fn link_name(i: @ast::native_item) -> str {
alt attr::first_attr_value_str_by_name(i.attrs, "link_name") {
none { ret i.ident; }
option::some(ln) { ret ln; }
none { ret *i.ident; }
option::some(ln) { ret *ln; }
}
}
@ -805,7 +805,7 @@ fn trans_intrinsic(ccx: @crate_ctxt, decl: ValueRef, item: @ast::native_item,
let fcx = new_fn_ctxt_w_id(ccx, path, decl, item.id,
some(substs), some(item.span));
let mut bcx = top_scope_block(fcx, none), lltop = bcx.llbb;
alt check item.ident {
alt check *item.ident {
"size_of" {
let tp_ty = substs.tys[0];
let lltp_ty = type_of::type_of(ccx, tp_ty);
@ -913,7 +913,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
let _icx = ccx.insn_ctxt("native::crust::build_rust_fn");
let t = ty::node_id_to_type(ccx.tcx, id);
let ps = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name("__rust_abi")]);
ccx, path + [ast_map::path_name(@"__rust_abi")]);
let llty = type_of_fn_from_ty(ccx, t);
let llfndecl = decl_internal_cdecl_fn(ccx.llmod, ps, llty);
trans_fn(ccx, path, decl, body, llfndecl, no_self, none, id);
@ -950,7 +950,7 @@ fn trans_crust_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl,
}
let shim_name = link::mangle_internal_name_by_path(
ccx, path + [ast_map::path_name("__rust_stack_shim")]);
ccx, path + [ast_map::path_name(@"__rust_stack_shim")]);
ret build_shim_fn_(ccx, shim_name, llrustfn, tys,
lib::llvm::CCallConv,
build_args, build_ret);

View File

@ -41,7 +41,7 @@ impl methods for reflector {
fn visit(ty_name: str, args: [ValueRef]) {
let tcx = self.bcx.tcx();
let mth_idx = option::get(ty::method_idx("visit_" + ty_name,
let mth_idx = option::get(ty::method_idx(@("visit_" + ty_name),
*self.visitor_methods));
let mth_ty = ty::mk_fn(tcx, self.visitor_methods[mth_idx].fty);
let v = self.visitor_val;
@ -142,7 +142,7 @@ impl methods for reflector {
for fields.eachi {|i, field|
self.bracketed_mt("rec_field", field.mt,
[self.c_uint(i),
self.c_slice(field.ident)]);
self.c_slice(*field.ident)]);
}
self.visit("leave_rec", [self.c_uint(vec::len(fields))]);
}
@ -209,7 +209,7 @@ impl methods for reflector {
for fields.eachi {|i, field|
self.bracketed_mt("class_field", field.mt,
[self.c_uint(i),
self.c_slice(field.ident)]);
self.c_slice(*field.ident)]);
}
self.visit("leave_class", [self.c_uint(vec::len(fields))]);
}
@ -228,7 +228,7 @@ impl methods for reflector {
let extra = [self.c_uint(i),
self.c_int(v.disr_val),
self.c_uint(vec::len(v.args)),
self.c_slice(v.name)];
self.c_slice(*v.name)];
self.visit("enter_enum_variant", extra);
for v.args.eachi {|j, a|
self.bracketed_t("enum_variant_field", a,

View File

@ -421,7 +421,7 @@ fn gen_enum_shapes(ccx: @crate_ctxt) -> ValueRef {
let variant_shape = shape_of_variant(ccx, v);
add_substr(data, variant_shape);
let zname = str::bytes(v.name) + [0u8];
let zname = str::bytes(*v.name) + [0u8];
add_substr(data, zname);
}
enum_variants += [variants];

View File

@ -233,7 +233,7 @@ fn get_base_and_len(cx: block, v: ValueRef, e_ty: ty::t)
}
}
fn trans_estr(bcx: block, s: str, vstore: ast::vstore,
fn trans_estr(bcx: block, s: @str, vstore: ast::vstore,
dest: dest) -> block {
let _icx = bcx.insn_ctxt("tvec::trans_estr");
let ccx = bcx.ccx();
@ -242,27 +242,27 @@ fn trans_estr(bcx: block, s: str, vstore: ast::vstore,
ast::vstore_fixed(_)
{
// "hello"/_ => "hello"/5 => [i8 x 6] in llvm
#debug("trans_estr: fixed: %s", s);
C_postr(s)
#debug("trans_estr: fixed: %s", *s);
C_postr(*s)
}
ast::vstore_slice(_) {
// "hello" => (*i8, 6u) in llvm
#debug("trans_estr: slice '%s'", s);
C_estr_slice(ccx, s)
#debug("trans_estr: slice '%s'", *s);
C_estr_slice(ccx, *s)
}
ast::vstore_uniq {
let cs = PointerCast(bcx, C_cstr(ccx, s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(s));
let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(*s));
let c = Call(bcx, ccx.upcalls.str_new_uniq, [cs, len]);
PointerCast(bcx, c,
T_unique_ptr(T_unique(ccx, T_vec(ccx, T_i8()))))
}
ast::vstore_box {
let cs = PointerCast(bcx, C_cstr(ccx, s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(s));
let cs = PointerCast(bcx, C_cstr(ccx, *s), T_ptr(T_i8()));
let len = C_uint(ccx, str::len(*s));
Call(bcx, ccx.upcalls.str_new_shared, [cs, len])
}
};

View File

@ -76,7 +76,7 @@ fn type_uses_for(ccx: @crate_ctxt, fn_id: def_id, n_tps: uint)
}
ast_map::node_native_item(i@@{node: native_item_fn(_, _), _}, abi, _) {
if abi == native_abi_rust_intrinsic {
let flags = alt check i.ident {
let flags = alt check *i.ident {
"visit_ty" { 3u }
"size_of" | "pref_align_of" | "min_align_of" |
"init" | "reinterpret_cast" { use_repr }

View File

@ -41,7 +41,7 @@ fn comma_str(args: [@constr_arg_use]) -> str {
if comma { rslt += ", "; } else { comma = true; }
alt a.node {
carg_base { rslt += "*"; }
carg_ident(i) { rslt += i.ident; }
carg_ident(i) { rslt += *i.ident; }
carg_lit(l) { rslt += lit_to_str(l); }
}
}
@ -143,11 +143,11 @@ fn log_states_err(pp: pre_and_post_state) {
log_cond_err(p2);
}
fn print_ident(i: ident) { log(debug, " " + i + " "); }
fn print_ident(i: ident) { log(debug, " " + *i + " "); }
fn print_idents(&idents: [ident]) {
if vec::len::<ident>(idents) == 0u { ret; }
log(debug, "an ident: " + vec::pop::<ident>(idents));
log(debug, "an ident: " + *vec::pop::<ident>(idents));
print_idents(idents);
}
@ -500,7 +500,7 @@ fn constraints(fcx: fn_ctxt) -> [norm_constraint] {
fn match_args(fcx: fn_ctxt, occs: @dvec<pred_args>,
occ: [@constr_arg_use]) -> uint {
#debug("match_args: looking at %s",
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, occ));
constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, occ));
for (*occs).each {|pd|
log(debug,
"match_args: candidate " + pred_args_to_str(pd));
@ -581,7 +581,7 @@ fn expr_to_constr(tcx: ty::ctxt, e: @expr) -> sp_constr {
fn pred_args_to_str(p: pred_args) -> str {
"<" + uint::str(p.node.bit_num) + ", " +
constr_args_to_str(fn@(i: inst) -> str { ret i.ident; }, p.node.args)
constr_args_to_str(fn@(i: inst) -> str { ret *i.ident; }, p.node.args)
+ ">"
}
@ -695,7 +695,7 @@ fn insts_to_str(stuff: [constr_arg_general_<inst>]) -> str {
rslt +=
" " +
alt i {
carg_ident(p) { p.ident }
carg_ident(p) { *p.ident }
carg_base { "*" }
carg_lit(_) { "[lit]" }
} + " ";

View File

@ -138,7 +138,7 @@ fn mk_fn_info(ccx: crate_ctxt,
used_vars: v,
ignore: ignore};
ccx.fm.insert(id, rslt);
#debug("%s has %u constraints", name, num_constraints(rslt));
#debug("%s has %u constraints", *name, num_constraints(rslt));
}

View File

@ -516,7 +516,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
fn find_pre_post_state_stmt(fcx: fn_ctxt, pres: prestate, s: @stmt) -> bool {
let stmt_ann = stmt_to_ann(fcx.ccx, *s);
#debug["[ %s ]", fcx.name];
#debug["[ %s ]", *fcx.name];
#debug["*At beginning: stmt = %s", stmt_to_str(*s)];
#debug["*prestate = %s", tritv::to_str(stmt_ann.states.prestate)];
#debug["*poststate = %s", tritv::to_str(stmt_ann.states.prestate)];

View File

@ -237,7 +237,7 @@ type ctxt =
node_type_substs: hashmap<node_id, [t]>,
items: ast_map::map,
intrinsic_ifaces: hashmap<str, (ast::def_id, t)>,
intrinsic_ifaces: hashmap<ast::ident, (ast::def_id, t)>,
freevars: freevars::freevar_map,
tcache: type_cache,
rcache: creader_cache,
@ -322,7 +322,7 @@ enum region {
enum bound_region {
br_self, // The self region for classes, impls
br_anon, // The anonymous region parameter for a given function.
br_named(str) // A named region parameter.
br_named(ast::ident) // A named region parameter.
}
type opt_region = option<region>;
@ -414,7 +414,7 @@ enum type_err {
terr_constr_mismatch(@type_constr, @type_constr),
terr_regions_differ(region, region),
terr_vstores_differ(terr_vstore_kind, vstore, vstore),
terr_in_field(@type_err, str),
terr_in_field(@type_err, ast::ident),
terr_sorts(t, t),
terr_self_substs
}
@ -516,7 +516,7 @@ fn mk_ctxt(s: session::session, dm: resolve::def_map, amap: ast_map::map,
node_types: @smallintmap::mk(),
node_type_substs: map::int_hash(),
items: amap,
intrinsic_ifaces: map::str_hash(),
intrinsic_ifaces: map::box_str_hash(),
freevars: freevars,
tcache: ast_util::new_def_hash(),
rcache: mk_rcache(),
@ -1992,7 +1992,7 @@ fn hash_bound_region(br: bound_region) -> uint {
alt br { // no idea if this is any good
ty::br_self { 0u }
ty::br_anon { 1u }
ty::br_named(str) { str::hash(str) }
ty::br_named(str) { str::hash(*str) }
}
}
@ -2298,7 +2298,7 @@ fn field_idx(id: ast::ident, fields: [field]) -> option<uint> {
}
fn get_field(rec_ty: t, id: ast::ident) -> field {
alt check vec::find(get_fields(rec_ty), {|f| str::eq(f.ident, id) }) {
alt check vec::find(get_fields(rec_ty), {|f| str::eq(*f.ident, *id) }) {
some(f) { f }
}
}
@ -2490,8 +2490,8 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str {
}
terr_record_mutability { ret "record elements differ in mutability"; }
terr_record_fields(e_fld, a_fld) {
ret "expected a record with field `" + e_fld +
"` but found one with field `" + a_fld + "`";
ret "expected a record with field `" + *e_fld +
"` but found one with field `" + *a_fld + "`";
}
terr_arg_count { ret "incorrect number of function parameters"; }
terr_mode_mismatch(e_mode, a_mode) {
@ -2521,7 +2521,7 @@ fn type_err_to_str(cx: ctxt, err: type_err) -> str {
vstore_to_str(cx, a_vs));
}
terr_in_field(err, fname) {
ret #fmt("in field `%s`, %s", fname, type_err_to_str(cx, *err));
ret #fmt("in field `%s`, %s", *fname, type_err_to_str(cx, *err));
}
terr_sorts(exp, act) {
ret #fmt("%s vs %s", ty_sort_str(cx, exp), ty_sort_str(cx, act));
@ -2592,7 +2592,7 @@ fn ty_to_def_id(ty: t) -> option<ast::def_id> {
}
// Enum information
type variant_info = @{args: [t], ctor_ty: t, name: str,
type variant_info = @{args: [t], ctor_ty: t, name: ast::ident,
id: ast::def_id, disr_val: int};
fn substd_enum_variants(cx: ctxt,
@ -2667,7 +2667,7 @@ fn item_path(cx: ctxt, id: ast::def_id) -> ast_map::path {
*path + [ast_map::path_name(nm)]
}
ast_map::node_dtor(_, _, _, path) {
*path + [ast_map::path_name("dtor")]
*path + [ast_map::path_name(@"dtor")]
}
@ -2861,7 +2861,7 @@ fn lookup_class_method_by_name(cx:ctxt, did: ast::def_id, name: ident,
}
}
cx.sess.span_fatal(sp, #fmt("Class doesn't have a method \
named %s", name));
named %s", *name));
}
else {
csearch::get_class_method(cx.sess.cstore, did, name)

View File

@ -260,7 +260,7 @@ fn check_fn(ccx: @crate_ctxt,
vec::iter2(arg_tys, decl.inputs) {|arg_ty, input|
assign(input.id, some(arg_ty));
#debug["Argument %s is assigned to %s",
input.ident, fcx.locals.get(input.id).to_str()];
*input.ident, fcx.locals.get(input.id).to_str()];
}
// Add explicitly-declared locals.
@ -284,7 +284,7 @@ fn check_fn(ccx: @crate_ctxt,
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) {
assign(p.id, none);
#debug["Pattern binding %s is assigned to %s",
path.idents[0],
*path.idents[0],
fcx.locals.get(p.id).to_str()];
}
_ {}
@ -443,13 +443,13 @@ impl of region_scope for @fn_ctxt {
fn anon_region() -> result<ty::region, str> {
result::ok(self.infcx.next_region_var())
}
fn named_region(id: str) -> result<ty::region, str> {
fn named_region(id: ast::ident) -> result<ty::region, str> {
empty_rscope.named_region(id).chain_err { |_e|
alt self.in_scope_regions.find(ty::br_named(id)) {
some(r) { result::ok(r) }
none if id == "blk" { self.block_region() }
none if *id == "blk" { self.block_region() }
none {
result::err(#fmt["named region `%s` not in scope here", id])
result::err(#fmt["named region `%s` not in scope here", *id])
}
}
}
@ -937,7 +937,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
self_expr: self_ex,
borrow_scope: op_ex.id,
node_id: callee_id,
m_name: opname,
m_name: @opname,
self_ty: self_t,
supplied_tps: [],
include_private: false});
@ -1113,7 +1113,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
ast::expr_vstore(ev, vst) {
let typ = alt ev.node {
ast::expr_lit(@{node: ast::lit_str(s), span:_}) {
let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(s), vst);
let tt = ast_expr_vstore_to_vstore(fcx, ev, str::len(*s), vst);
ty::mk_estr(tcx, tt)
}
ast::expr_vec(args, mutbl) {
@ -1553,7 +1553,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
for fields_t.each {|f|
let mut found = false;
for base_fields.each {|bf|
if str::eq(f.node.ident, bf.ident) {
if str::eq(*f.node.ident, *bf.ident) {
demand::suptype(fcx, f.span, bf.mt.ty, f.node.mt.ty);
found = true;
}
@ -1561,7 +1561,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
if !found {
tcx.sess.span_fatal(f.span,
"unknown field in record update: " +
f.node.ident);
*f.node.ident);
}
}
}
@ -1645,7 +1645,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
let t_err = fcx.infcx.resolve_type_vars_if_possible(expr_t);
let msg = #fmt["attempted access of field %s on type %s, but \
no public field or method with that name was found",
field, ty_to_str(tcx, t_err)];
*field, ty_to_str(tcx, t_err)];
tcx.sess.span_err(expr.span, msg);
// NB: Adding a bogus type to allow typechecking to continue
fcx.write_ty(id, fcx.infcx.next_ty_var());
@ -1690,7 +1690,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt,
self_expr: p,
borrow_scope: expr.id,
node_id: alloc_id,
m_name: "alloc",
m_name: @"alloc",
self_ty: p_ty,
supplied_tps: [],
include_private: false});
@ -2310,7 +2310,7 @@ fn check_bounds_are_used(ccx: @crate_ctxt,
for tps_used.eachi { |i, b|
if !b {
ccx.tcx.sess.span_err(
span, #fmt["Type parameter %s is unused.", tps[i].ident]);
span, #fmt["Type parameter %s is unused.", *tps[i].ident]);
}
}
}
@ -2323,7 +2323,7 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
{mode: ast::expl(m), ty: ty}
}
let tcx = ccx.tcx;
let (n_tps, inputs, output) = alt it.ident {
let (n_tps, inputs, output) = alt *it.ident {
"size_of" |
"pref_align_of" | "min_align_of" { (1u, [], ty::mk_uint(ccx.tcx)) }
"get_tydesc" { (1u, [], ty::mk_nil_ptr(tcx)) }
@ -2337,8 +2337,8 @@ fn check_intrinsic_type(ccx: @crate_ctxt, it: @ast::native_item) {
"needs_drop" { (1u, [], ty::mk_bool(tcx)) }
"visit_ty" {
assert ccx.tcx.intrinsic_ifaces.contains_key("ty_visitor");
let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get("ty_visitor");
assert ccx.tcx.intrinsic_ifaces.contains_key(@"ty_visitor");
let (_, visitor_iface) = ccx.tcx.intrinsic_ifaces.get(@"ty_visitor");
(1u, [arg(ast::by_ref, visitor_iface)], ty::mk_nil(tcx))
}
"frame_address" {

View File

@ -191,8 +191,8 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
fields",
ex_f_count, f_count]);
}
fn matches(name: str, f: ty::field) -> bool {
ret str::eq(name, f.ident);
fn matches(name: ast::ident, f: ty::field) -> bool {
ret str::eq(*name, *f.ident);
}
for fields.each {|f|
alt vec::find(ex_fields, bind matches(f.ident, _)) {
@ -203,7 +203,7 @@ fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
tcx.sess.span_fatal(pat.span,
#fmt["mismatched types: did not \
expect a record with a field `%s`",
f.ident]);
*f.ident]);
}
}
}

View File

@ -19,7 +19,7 @@ impl methods for lookup {
// Entrypoint:
fn method() -> option<method_origin> {
#debug["method lookup(m_name=%s, self_ty=%s)",
self.m_name, self.fcx.infcx.ty_to_str(self.self_ty)];
*self.m_name, self.fcx.infcx.ty_to_str(self.self_ty)];
// First, see whether this is an interface-bounded parameter
let pass1 = alt ty::get(self.self_ty).struct {

View File

@ -65,7 +65,7 @@ fn visit_pat(p: @ast::pat, &&rcx: rcx, v: rvt) {
alt p.node {
ast::pat_ident(path, _)
if !pat_util::pat_is_variant(fcx.ccx.tcx.def_map, p) {
#debug["visit_pat binding=%s", path.idents[0]];
#debug["visit_pat binding=%s", *path.idents[0]];
visit_node(p.id, p.span, rcx);
}
_ {}

View File

@ -29,7 +29,7 @@ fn collect_item_types(ccx: @crate_ctxt, crate: @ast::crate) {
// there ought to be a better approach. Attributes?
for crate.node.module.items.each {|crate_item|
if crate_item.ident == "intrinsic" {
if *crate_item.ident == "intrinsic" {
alt crate_item.node {
ast::item_mod(m) {
for m.items.each {|intrinsic_item|
@ -170,7 +170,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
self_ty: ty::t) {
if impl_m.tps != if_m.tps {
tcx.sess.span_err(sp, "method `" + if_m.ident +
tcx.sess.span_err(sp, "method `" + *if_m.ident +
"` has an incompatible set of type parameters");
ret;
}
@ -178,7 +178,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
if vec::len(impl_m.fty.inputs) != vec::len(if_m.fty.inputs) {
tcx.sess.span_err(sp,#fmt["method `%s` has %u parameters \
but the iface has %u",
if_m.ident,
*if_m.ident,
vec::len(impl_m.fty.inputs),
vec::len(if_m.fty.inputs)]);
ret;
@ -211,7 +211,7 @@ fn compare_impl_method(tcx: ty::ctxt, sp: span,
};
require_same_types(
tcx, sp, impl_fty, if_fty,
{|| "method `" + if_m.ident + "` has an incompatible type"});
{|| "method `" + *if_m.ident + "` has an incompatible type"});
ret;
// Replaces bound references to the self region with `with_r`.
@ -242,7 +242,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt,
ccx.tcx.sess.span_err(
span, #fmt["method `%s`'s purity \
not match the iface method's \
purity", m.ident]);
purity", *m.ident]);
}
compare_impl_method(
ccx.tcx, span, m, vec::len(tps),
@ -251,7 +251,7 @@ fn check_methods_against_iface(ccx: @crate_ctxt,
none {
tcx.sess.span_err(
a_ifacety.path.span,
#fmt["missing method `%s`", if_m.ident]);
#fmt["missing method `%s`", *if_m.ident]);
}
} // alt
} // |if_m|
@ -511,7 +511,7 @@ fn ty_of_item(ccx: @crate_ctxt, it: @ast::item)
rp: ast::rp_none, // functions do not have a self
ty: ty::mk_fn(ccx.tcx, tofd)};
#debug["type of %s (id %d) is %s",
it.ident, it.id, ty_to_str(tcx, tpt.ty)];
*it.ident, it.id, ty_to_str(tcx, tpt.ty)];
ccx.tcx.tcache.insert(local_def(it.id), tpt);
ret tpt;
}

View File

@ -2,7 +2,7 @@ import result::result;
iface region_scope {
fn anon_region() -> result<ty::region, str>;
fn named_region(id: str) -> result<ty::region, str>;
fn named_region(id: ast::ident) -> result<ty::region, str>;
}
enum empty_rscope { empty_rscope }
@ -10,8 +10,8 @@ impl of region_scope for empty_rscope {
fn anon_region() -> result<ty::region, str> {
result::err("region types are not allowed here")
}
fn named_region(id: str) -> result<ty::region, str> {
if id == "static" { result::ok(ty::re_static) }
fn named_region(id: ast::ident) -> result<ty::region, str> {
if *id == "static" { result::ok(ty::re_static) }
else { result::err("only the static region is allowed here") }
}
}
@ -27,9 +27,9 @@ impl of region_scope for type_rscope {
}
}
}
fn named_region(id: str) -> result<ty::region, str> {
fn named_region(id: ast::ident) -> result<ty::region, str> {
empty_rscope.named_region(id).chain_err { |_e|
if id == "self" { self.anon_region() }
if *id == "self" { self.anon_region() }
else {
result::err("named regions other than `self` are not \
allowed as part of a type declaration")
@ -47,7 +47,7 @@ impl of region_scope for @anon_rscope {
fn anon_region() -> result<ty::region, str> {
result::ok(self.anon)
}
fn named_region(id: str) -> result<ty::region, str> {
fn named_region(id: ast::ident) -> result<ty::region, str> {
self.base.named_region(id)
}
}
@ -61,7 +61,7 @@ impl of region_scope for @binding_rscope {
fn anon_region() -> result<ty::region, str> {
result::ok(ty::re_bound(ty::br_anon))
}
fn named_region(id: str) -> result<ty::region, str> {
fn named_region(id: ast::ident) -> result<ty::region, str> {
self.base.named_region(id).chain_err {|_e|
result::ok(ty::re_bound(ty::br_named(id)))
}

View File

@ -72,7 +72,7 @@ fn local_rhs_span(l: @ast::local, def: span) -> span {
fn is_main_name(path: syntax::ast_map::path) -> bool {
// FIXME: path should be a constrained type, so we know
// the call to last doesn't fail
vec::last(path) == syntax::ast_map::path_name("main")
vec::last(path) == syntax::ast_map::path_name(@"main")
}
//

View File

@ -21,7 +21,7 @@ import driver::session::session;
fn bound_region_to_str(cx: ctxt, br: bound_region) -> str {
alt br {
br_anon { "&" }
br_named(str) { #fmt["&%s", str] }
br_named(str) { #fmt["&%s", *str] }
br_self if cx.sess.ppregions() { "&<self>" }
br_self { "&self" }
}
@ -130,7 +130,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
_ {purity_to_str(purity) + " "}
};
s += proto_to_str(proto);
alt ident { some(i) { s += " "; s += i; } _ { } }
alt ident { some(i) { s += " "; s += *i; } _ { } }
s += "(";
let mut strs = [];
for inputs.each {|a| strs += [fn_input_to_str(cx, a)]; }
@ -152,7 +152,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
m.fty.output, m.fty.ret_style, m.fty.constraints) + ";";
}
fn field_to_str(cx: ctxt, f: field) -> str {
ret f.ident + ": " + mt_to_str(cx, f.mt);
ret *f.ident + ": " + mt_to_str(cx, f.mt);
}
// if there is an id, print that instead of the structural type:

View File

@ -67,7 +67,8 @@ fn parse_crate(attrs: [ast::attribute]) -> crate_attrs {
let link_metas = attr::find_linkage_metas(attrs);
{
name: attr::last_meta_item_value_str_by_name(link_metas, "name")
name: attr::last_meta_item_value_str_by_name(
link_metas, "name").map({|x|*x})
}
}
@ -98,7 +99,7 @@ fn should_not_extract_crate_name_if_no_name_value_in_link_attribute() {
fn parse_desc(attrs: [ast::attribute]) -> option<str> {
alt doc_meta(attrs) {
some(meta) {
attr::get_meta_item_value_str(meta)
attr::get_meta_item_value_str(meta).map({|x|*x})
}
none { none }
}

View File

@ -151,7 +151,7 @@ fn fold_enum(
}, _) {
let ast_variant = option::get(
vec::find(ast_variants) {|v|
v.node.name == variant.name
*v.node.name == variant.name
});
attr_parser::parse_desc(ast_variant.node.attrs)
@ -207,14 +207,14 @@ fn merge_method_attrs(
node: ast::item_iface(_, _, methods), _
}, _) {
par::seqmap(methods) {|method|
(method.ident, attr_parser::parse_desc(method.attrs))
(*method.ident, attr_parser::parse_desc(method.attrs))
}
}
ast_map::node_item(@{
node: ast::item_impl(_, _, _, _, methods), _
}, _) {
par::seqmap(methods) {|method|
(method.ident, attr_parser::parse_desc(method.attrs))
(*method.ident, attr_parser::parse_desc(method.attrs))
}
}
_ { fail "unexpected item" }

View File

@ -33,14 +33,14 @@ fn top_moddoc_from_crate(
crate: @ast::crate,
default_name: str
) -> doc::moddoc {
moddoc_from_mod(mk_itemdoc(ast::crate_node_id, default_name),
moddoc_from_mod(mk_itemdoc(ast::crate_node_id, @default_name),
crate.node.module)
}
fn mk_itemdoc(id: ast::node_id, name: ast::ident) -> doc::itemdoc {
{
id: id,
name: name,
name: *name,
path: [],
brief: none,
desc: none,
@ -169,7 +169,7 @@ fn variantdocs_from_variants(
fn variantdoc_from_variant(variant: ast::variant) -> doc::variantdoc {
{
name: variant.node.name,
name: *variant.node.name,
desc: none,
sig: none
}
@ -210,7 +210,7 @@ fn ifacedoc_from_iface(
item: itemdoc,
methods: par::seqmap(methods) {|method|
{
name: method.ident,
name: *method.ident,
brief: none,
desc: none,
sections: [],
@ -242,7 +242,7 @@ fn impldoc_from_impl(
self_ty: none,
methods: par::seqmap(methods) {|method|
{
name: method.ident,
name: *method.ident,
brief: none,
desc: none,
sections: [],

View File

@ -114,7 +114,7 @@ fn is_exported_from_mod(
ast_map::node_item(item, _) {
alt item.node {
ast::item_mod(m) {
ast_util::is_exported(item_name, m)
ast_util::is_exported(@item_name, m)
}
_ {
fail "is_exported_from_mod: not a mod";
@ -131,7 +131,7 @@ fn is_exported_from_crate(
item_name: str
) -> bool {
astsrv::exec(srv) {|ctxt|
ast_util::is_exported(item_name, ctxt.ast.node.module)
ast_util::is_exported(@item_name, ctxt.ast.node.module)
}
}

View File

@ -187,7 +187,7 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
if !def.reexp { cont; }
alt def_map.find(def.id) {
some(itemtag) {
reexportdocs += [(name, itemtag)];
reexportdocs += [(*name, itemtag)];
}
_ {}
}
@ -231,9 +231,9 @@ fn find_reexport_impl_docs(
some(ast_map::node_item(item, path)) {
let path = ast_map::path_to_str(*path);
if str::is_empty(path) {
item.ident
*item.ident
} else {
path + "::" + item.ident
path + "::" + *item.ident
}
}
_ {
@ -241,7 +241,7 @@ fn find_reexport_impl_docs(
""
}
};
let ident = i.ident;
let ident = *i.ident;
let doc = alt check def_map.find(i.did) {
some(doc) { doc }
};

View File

@ -116,7 +116,7 @@ fn fold_enum(
}, _) {
let ast_variant = option::get(
vec::find(ast_variants) {|v|
v.node.name == variant.name
*v.node.name == variant.name
});
pprust::variant_to_str(ast_variant)
@ -151,7 +151,7 @@ fn fold_res(
ast_map::node_item(@{
node: ast::item_res(decl, tys, _, _, _, rp), _
}, _) {
pprust::res_to_str(decl, doc.name(), tys, rp)
pprust::res_to_str(decl, @doc.name(), tys, rp)
}
}
})
@ -200,7 +200,7 @@ fn get_method_sig(
node: ast::item_iface(_, _, methods), _
}, _) {
alt check vec::find(methods) {|method|
method.ident == method_name
*method.ident == method_name
} {
some(method) {
some(pprust::fun_to_str(
@ -215,7 +215,7 @@ fn get_method_sig(
node: ast::item_impl(_, _, _, _, methods), _
}, _) {
alt check vec::find(methods) {|method|
method.ident == method_name
*method.ident == method_name
} {
some(method) {
some(pprust::fun_to_str(
@ -307,7 +307,7 @@ fn fold_type(
}, _) {
some(#fmt(
"type %s%s = %s",
ident,
*ident,
pprust::typarams_to_str(params),
pprust::ty_to_str(ty)
))