Skip to content

Partial work making libsyntax free of vecs_implicitly_copyable #4999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Feb 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -466,14 +466,14 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
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" {
match attr::get_meta_item_value_str(*meta) {
// Changing attr would avoid the need for the copy
// here
Some(v) => { name = Some(v.to_managed()); }
None => cmh_items.push(*meta)
}
} else if attr::get_meta_item_name(*meta) == ~"vers" {
} else if *attr::get_meta_item_name(*meta) == ~"vers" {
match attr::get_meta_item_value_str(*meta) {
Some(v) => { vers = Some(v.to_managed()); }
None => cmh_items.push(*meta)
Expand All @@ -487,27 +487,27 @@ pub fn build_link_meta(sess: Session, c: &ast::crate, output: &Path,
fn crate_meta_extras_hash(symbol_hasher: &hash::State,
-cmh_items: ~[@ast::meta_item],
dep_hashes: ~[~str]) -> @str {
fn len_and_str(s: ~str) -> ~str {
return fmt!("%u_%s", str::len(s), s);
fn len_and_str(s: &str) -> ~str {
fmt!("%u_%s", s.len(), s)
}

fn len_and_str_lit(l: ast::lit) -> ~str {
return len_and_str(pprust::lit_to_str(@l));
len_and_str(pprust::lit_to_str(@l))
}

let cmh_items = attr::sort_meta_items(cmh_items);

fn hash(symbol_hasher: &hash::State, m: &@ast::meta_item) {
match m.node {
ast::meta_name_value(ref key, value) => {
symbol_hasher.write_str(len_and_str((*key)));
ast::meta_name_value(key, value) => {
symbol_hasher.write_str(len_and_str(*key));
symbol_hasher.write_str(len_and_str_lit(value));
}
ast::meta_word(ref name) => {
symbol_hasher.write_str(len_and_str((*name)));
ast::meta_word(name) => {
symbol_hasher.write_str(len_and_str(*name));
}
ast::meta_list(ref name, ref mis) => {
symbol_hasher.write_str(len_and_str((*name)));
ast::meta_list(name, ref mis) => {
symbol_hasher.write_str(len_and_str(*name));
for mis.each |m_| {
hash(symbol_hasher, m_);
}
Expand Down Expand Up @@ -615,7 +615,7 @@ pub fn get_symbol_hash(ccx: @crate_ctxt, t: ty::t) -> @str {

// Name sanitation. LLVM will happily accept identifiers with weird names, but
// gas doesn't!
pub fn sanitize(s: ~str) -> ~str {
pub fn sanitize(s: &str) -> ~str {
let mut result = ~"";
for str::chars_each(s) |c| {
match c {
Expand All @@ -629,10 +629,10 @@ pub fn sanitize(s: ~str) -> ~str {
'a' .. 'z'
| 'A' .. 'Z'
| '0' .. '9'
| '_' => str::push_char(&mut result, c),
| '_' => result.push_char(c),
_ => {
if c > 'z' && char::is_XID_continue(c) {
str::push_char(&mut result, c);
result.push_char(c);
}
}
}
Expand All @@ -655,7 +655,7 @@ pub fn mangle(sess: Session, ss: path) -> ~str {

for ss.each |s| {
match *s { path_name(s) | path_mod(s) => {
let sani = sanitize(sess.str_of(s));
let sani = sanitize(*sess.str_of(s));
n += fmt!("%u%s", str::len(sani), sani);
} }
}
Expand Down
30 changes: 15 additions & 15 deletions src/librustc/driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn anon_src() -> ~str { ~"<anon>" }

pub fn source_name(input: input) -> ~str {
match input {
file_input(ref ifile) => (*ifile).to_str(),
file_input(ref ifile) => ifile.to_str(),
str_input(_) => anon_src()
}
}
Expand Down Expand Up @@ -97,24 +97,24 @@ pub fn default_configuration(sess: Session, +argv0: ~str, input: input) ->
};

return ~[ // Target bindings.
attr::mk_word_item(str::from_slice(os::FAMILY)),
mk(~"target_os", tos),
mk(~"target_family", str::from_slice(os::FAMILY)),
mk(~"target_arch", arch),
mk(~"target_endian", end),
mk(~"target_word_size", wordsz),
mk(~"target_libc", libc),
attr::mk_word_item(@str::from_slice(os::FAMILY)),
mk(@~"target_os", @tos),
mk(@~"target_family", @str::from_slice(os::FAMILY)),
mk(@~"target_arch", @arch),
mk(@~"target_endian", @end),
mk(@~"target_word_size", @wordsz),
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))];
}

pub fn append_configuration(+cfg: ast::crate_cfg, +name: ~str)
-> ast::crate_cfg {
if attr::contains_name(cfg, name) {
return cfg;
cfg
} else {
return vec::append_one(cfg, attr::mk_word_item(name));
vec::append_one(cfg, attr::mk_word_item(@name))
}
}

Expand Down Expand Up @@ -142,7 +142,7 @@ pub fn parse_cfgspecs(cfgspecs: ~[~str]) -> ast::crate_cfg {
// meta_word variant.
let mut words = ~[];
for cfgspecs.each |s| {
words.push(attr::mk_word_item(/*bad*/copy *s));
words.push(attr::mk_word_item(@/*bad*/copy *s));
}
return words;
}
Expand Down Expand Up @@ -541,11 +541,11 @@ pub fn build_session_options(+binary: ~str,
let flags = vec::append(getopts::opt_strs(matches, level_short),
getopts::opt_strs(matches, level_name));
for flags.each |lint_name| {
let lint_name = str::replace(*lint_name, ~"-", ~"_");
let lint_name = @str::replace(*lint_name, ~"-", ~"_");
match lint_dict.find(&lint_name) {
None => {
early_error(demitter, fmt!("unknown %s flag: %s",
level_name, lint_name));
level_name, *lint_name));
}
Some(lint) => {
lint_opts.push((lint.lint, *level));
Expand Down
8 changes: 4 additions & 4 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ pub impl Session {
self.debugging_opt(no_monomorphic_collapse)
}

fn str_of(id: ast::ident) -> ~str {
/*bad*/copy *self.parse_sess.interner.get(id)
fn str_of(id: ast::ident) -> @~str {
self.parse_sess.interner.get(id)
}
fn ident_of(+st: ~str) -> ast::ident {
self.parse_sess.interner.intern(@st)
Expand Down Expand Up @@ -310,7 +310,7 @@ pub fn building_library(req_crate_type: crate_type,
match syntax::attr::first_attr_value_str_by_name(
crate.node.attrs,
~"crate_type") {
option::Some(~"lib") => true,
Some(@~"lib") => true,
_ => false
}
}
Expand Down Expand Up @@ -346,7 +346,7 @@ pub mod test {
style: ast::attr_outer,
value: codemap::respan(codemap::dummy_sp(),
ast::meta_name_value(
~"crate_type",
@~"crate_type",
codemap::respan(codemap::dummy_sp(),
ast::lit_str(@t)))),
is_sugared_doc: false
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/front/core_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn inject_libcore_ref(sess: Session,
spanned(ast::attribute_ {
style: ast::attr_inner,
value: spanned(ast::meta_name_value(
~"vers",
@~"vers",
spanned(ast::lit_str(@CORE_VERSION.to_str()))
)),
is_sugared_doc: false
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn modify_for_testing(sess: session::Session,
// configuration, either with the '--test' or '--cfg test'
// command line options.
let should_test = attr::contains(crate.node.config,
attr::mk_word_item(~"test"));
attr::mk_word_item(@~"test"));

if should_test {
generate_test_harness(sess, crate)
Expand Down Expand Up @@ -111,7 +111,7 @@ fn fold_mod(cx: @mut TestCtxt,
fn nomain(cx: @mut TestCtxt, item: @ast::item) -> @ast::item {
if !*cx.sess.building_library {
@ast::item{attrs: item.attrs.filtered(|attr| {
attr::get_attr_name(*attr) != ~"main"
*attr::get_attr_name(attr) != ~"main"
}),.. copy *item}
} else { item }
}
Expand Down Expand Up @@ -262,7 +262,7 @@ mod __test {
fn mk_std(cx: &TestCtxt) -> @ast::view_item {
let vers = ast::lit_str(@~"0.6");
let vers = nospan(vers);
let mi = ast::meta_name_value(~"vers", vers);
let mi = ast::meta_name_value(@~"vers", vers);
let mi = nospan(mi);
let id_std = cx.sess.ident_of(~"std");
let vi = if is_std(cx) {
Expand Down Expand Up @@ -310,7 +310,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {

// 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: cx.sess.ident_of(~"__test"),
Expand Down Expand Up @@ -366,7 +366,7 @@ fn is_std(cx: &TestCtxt) -> bool {
let is_std = {
let items = attr::find_linkage_metas(cx.crate.node.attrs);
match attr::last_meta_item_value_str_by_name(items, ~"name") {
Some(~"std") => true,
Some(@~"std") => true,
_ => false
}
};
Expand Down
Loading