diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 58c7edd33cdf..09f822e0e388 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -141,7 +141,7 @@ priv impl DList { // Link two nodes together. If either of them are 'none', also sets // the head and/or tail pointers appropriately. #[inline(always)] - fn link(+before: DListLink, +after: DListLink) { + fn link_nodes(+before: DListLink, +after: DListLink) { match before { Some(neighbour) => neighbour.next = after, None => self.hd = after @@ -155,7 +155,7 @@ priv impl DList { fn unlink(nobe: DListNode) { self.assert_mine(nobe); assert self.size > 0; - self.link(nobe.prev, nobe.next); + self.link_nodes(nobe.prev, nobe.next); nobe.prev = None; // Release extraneous references. nobe.next = None; nobe.linked = false; @@ -163,27 +163,27 @@ priv impl DList { } fn add_head(+nobe: DListLink) { - self.link(nobe, self.hd); // Might set tail too. + self.link_nodes(nobe, self.hd); // Might set tail too. self.hd = nobe; self.size += 1; } fn add_tail(+nobe: DListLink) { - self.link(self.tl, nobe); // Might set head too. + self.link_nodes(self.tl, nobe); // Might set head too. self.tl = nobe; self.size += 1; } fn insert_left(nobe: DListLink, neighbour: DListNode) { self.assert_mine(neighbour); assert self.size > 0; - self.link(neighbour.prev, nobe); - self.link(nobe, Some(neighbour)); + self.link_nodes(neighbour.prev, nobe); + self.link_nodes(nobe, Some(neighbour)); self.size += 1; } fn insert_right(neighbour: DListNode, nobe: DListLink) { self.assert_mine(neighbour); assert self.size > 0; - self.link(nobe, neighbour.next); - self.link(Some(neighbour), nobe); + self.link_nodes(nobe, neighbour.next); + self.link_nodes(Some(neighbour), nobe); self.size += 1; } } @@ -315,7 +315,7 @@ impl DList { fail ~"Cannot append a dlist to itself!" } if them.len() > 0 { - self.link(self.tl, them.hd); + self.link_nodes(self.tl, them.hd); self.tl = them.tl; self.size += them.size; them.size = 0; @@ -332,7 +332,7 @@ impl DList { fail ~"Cannot prepend a dlist to itself!" } if them.len() > 0 { - self.link(them.tl, self.hd); + self.link_nodes(them.tl, self.hd); self.hd = them.hd; self.size += them.size; them.size = 0; @@ -366,11 +366,11 @@ impl DList { /// Iterate over nodes. pure fn each_node(f: fn(DListNode) -> bool) { - let mut link = self.peek_n(); - while link.is_some() { - let nobe = link.get(); + let mut link_node = self.peek_n(); + while link_node.is_some() { + let nobe = link_node.get(); if !f(nobe) { break; } - link = nobe.next_link(); + link_node = nobe.next_link(); } } @@ -381,10 +381,10 @@ impl DList { } // iterate forwards let mut count = 0; - let mut link = self.peek_n(); - let mut rabbit = link; - while option::is_some(link) { - let nobe = option::get(link); + let mut link_node = self.peek_n(); + let mut rabbit = link_node; + while option::is_some(link_node) { + let nobe = option::get(link_node); assert nobe.linked; // check cycle if option::is_some(rabbit) { rabbit = option::get(rabbit).next; } @@ -393,15 +393,15 @@ impl DList { assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance - link = nobe.next_link(); + link_node = nobe.next_link(); count += 1; } assert count == self.len(); // iterate backwards - some of this is probably redundant. - link = self.peek_tail_n(); - rabbit = link; - while option::is_some(link) { - let nobe = option::get(link); + link_node = self.peek_tail_n(); + rabbit = link_node; + while option::is_some(link_node) { + let nobe = option::get(link_node); assert nobe.linked; // check cycle if option::is_some(rabbit) { rabbit = option::get(rabbit).prev; } @@ -410,7 +410,7 @@ impl DList { assert !box::ptr_eq(*option::get(rabbit), *nobe); } // advance - link = nobe.prev_link(); + link_node = nobe.prev_link(); count -= 1; } assert count == 0; diff --git a/src/libcore/iter-trait/dlist.rs b/src/libcore/iter-trait/dlist.rs index ae6265409cae..966cd138d4cd 100644 --- a/src/libcore/iter-trait/dlist.rs +++ b/src/libcore/iter-trait/dlist.rs @@ -9,9 +9,9 @@ type IMPL_T = dlist::DList; * node is forbidden. */ pure fn EACH(self: IMPL_T, f: fn(A) -> bool) { - let mut link = self.peek_n(); - while option::is_some(link) { - let nobe = option::get(link); + let mut link_node = self.peek_n(); + while option::is_some(link_node) { + let nobe = option::get(link_node); assert nobe.linked; if !f(nobe.data) { break; } // Check (weakly) that the user didn't do a remove. @@ -25,7 +25,7 @@ pure fn EACH(self: IMPL_T, f: fn(A) -> bool) { || box::ptr_eq(*self.tl.expect(~"tailless dlist?"), *nobe)))) { fail ~"Removing a dlist node during iteration is forbidden!" } - link = nobe.next_link(); + link_node = nobe.next_link(); } } diff --git a/src/libcore/libc.rs b/src/libcore/libc.rs index 491fe02ec31f..f06a2c758893 100644 --- a/src/libcore/libc.rs +++ b/src/libcore/libc.rs @@ -1033,7 +1033,8 @@ mod funcs { fn getppid() -> pid_t; fn getuid() -> uid_t; fn isatty(fd: c_int) -> c_int; - fn link(src: *c_char, dst: *c_char) -> c_int; + #[link_name="link"] + fn lnk(src: *c_char, dst: *c_char) -> c_int; fn lseek(fd: c_int, offset: off_t, whence: c_int) -> off_t; fn pathconf(path: *c_char, name: c_int) -> c_long; fn pause() -> c_int; diff --git a/src/rustc/back/link.rs b/src/rustc/back/linkage.rs similarity index 100% rename from src/rustc/back/link.rs rename to src/rustc/back/linkage.rs diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 44d62e8d9269..b476fa5217b2 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -7,7 +7,7 @@ use syntax::attr; use middle::{trans, freevars, kind, ty, typeck, lint}; use syntax::print::{pp, pprust}; use util::ppaux; -use back::link; +use back::linkage; use result::{Ok, Err}; use std::getopts; use io::WriterUtil; @@ -258,20 +258,20 @@ fn compile_upto(sess: session, cfg: ast::crate_cfg, exp_map, exp_map2, maps)); time(time_passes, ~"LLVM passes", || - link::write::run_passes(sess, llmod, - &outputs.obj_filename)); + linkage::write::run_passes(sess, llmod, + &outputs.obj_filename)); let stop_after_codegen = - sess.opts.output_type != link::output_type_exe || - (sess.opts.static && sess.building_library) || + sess.opts.output_type != linkage::output_type_exe || + (sess.opts.static && sess.building_library) || sess.opts.jit; if stop_after_codegen { return {crate: crate, tcx: Some(ty_cx)}; } time(time_passes, ~"linking", || - link::link_binary(sess, - &outputs.obj_filename, - &outputs.out_filename, link_meta)); + linkage::link_binary(sess, + &outputs.obj_filename, + &outputs.out_filename, link_meta)); return {crate: crate, tcx: Some(ty_cx)}; } @@ -492,17 +492,19 @@ fn build_session_options(binary: ~str, let jit = opt_present(matches, ~"jit"); let output_type = if parse_only || no_trans { - link::output_type_none + linkage::output_type_none } else if opt_present(matches, ~"S") && opt_present(matches, ~"emit-llvm") { - link::output_type_llvm_assembly + linkage::output_type_llvm_assembly } else if opt_present(matches, ~"S") { - link::output_type_assembly + linkage::output_type_assembly } else if opt_present(matches, ~"c") { - link::output_type_object + linkage::output_type_object } else if opt_present(matches, ~"emit-llvm") { - link::output_type_bitcode - } else { link::output_type_exe }; + linkage::output_type_bitcode + } else { + linkage::output_type_exe + }; let extra_debuginfo = opt_present(matches, ~"xg"); let debuginfo = opt_present(matches, ~"g") || extra_debuginfo; let sysroot_opt = getopts::opt_maybe_str(matches, ~"sysroot"); @@ -511,7 +513,8 @@ fn build_session_options(binary: ~str, let save_temps = getopts::opt_present(matches, ~"save-temps"); match output_type { // unless we're emitting huamn-readable assembly, omit comments. - link::output_type_llvm_assembly | link::output_type_assembly => (), + linkage::output_type_llvm_assembly | + linkage::output_type_assembly => (), _ => debugging_opts |= session::no_asm_comments } let opt_level = { @@ -657,18 +660,18 @@ fn build_output_filenames(input: input, let out_path; let sopts = sess.opts; let stop_after_codegen = - sopts.output_type != link::output_type_exe || + sopts.output_type != linkage::output_type_exe || sopts.static && sess.building_library; let obj_suffix = match sopts.output_type { - link::output_type_none => ~"none", - link::output_type_bitcode => ~"bc", - link::output_type_assembly => ~"s", - link::output_type_llvm_assembly => ~"ll", + linkage::output_type_none => ~"none", + linkage::output_type_bitcode => ~"bc", + linkage::output_type_assembly => ~"s", + linkage::output_type_llvm_assembly => ~"ll", // Object and exe output both use the '.o' extension here - link::output_type_object | link::output_type_exe => ~"o" + linkage::output_type_object | linkage::output_type_exe => ~"o" }; match *ofile { diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 70e717aa6d9e..c4dde985bdba 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -6,7 +6,7 @@ use syntax::ast::{int_ty, uint_ty, float_ty}; use syntax::parse::parse_sess; use metadata::filesearch; use back::target_strs; -use back::link; +use back::linkage; use middle::lint; @@ -113,7 +113,7 @@ type options = lint_opts: ~[(lint::lint, lint::level)], save_temps: bool, jit: bool, - output_type: back::link::output_type, + output_type: back::linkage::output_type, addl_lib_search_paths: ~[Path], maybe_sysroot: Option, target_triple: ~str, @@ -256,7 +256,7 @@ fn basic_options() -> @options { lint_opts: ~[], save_temps: false, jit: false, - output_type: link::output_type_exe, + output_type: linkage::output_type_exe, addl_lib_search_paths: ~[], maybe_sysroot: None, target_triple: driver::host_triple(), diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index ef791cd5020b..f72b4214abe6 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -20,7 +20,7 @@ use std::map::{int_hash, str_hash}; use driver::session; use session::session; use syntax::attr; -use back::{link, abi, upcall}; +use back::{linkage, abi, upcall}; use syntax::{ast, ast_util, codemap, ast_map}; use ast_util::{local_def, path_to_ident}; use syntax::visit; @@ -32,7 +32,7 @@ use util::common::is_main_name; use lib::llvm::{llvm, mk_target_data, mk_type_names}; use lib::llvm::{ModuleRef, ValueRef, TypeRef, BasicBlockRef}; use lib::llvm::{True, False}; -use link::{mangle_internal_name_by_type_only, +use linkage::{mangle_internal_name_by_type_only, mangle_internal_name_by_seq, mangle_internal_name_by_path, mangle_internal_name_by_path_and_seq, @@ -2571,7 +2571,7 @@ fn trans_crate(sess: session::session, let symbol_hasher = @hash::default_state(); let link_meta = - link::build_link_meta(sess, *crate, output, symbol_hasher); + linkage::build_link_meta(sess, *crate, output, symbol_hasher); let reachable = reachable::find_reachable(crate.node.module, emap, tcx, maps.method_map); diff --git a/src/rustc/middle/trans/closure.rs b/src/rustc/middle/trans/closure.rs index 1ba8e22607a1..abc9cfecfd67 100644 --- a/src/rustc/middle/trans/closure.rs +++ b/src/rustc/middle/trans/closure.rs @@ -10,7 +10,7 @@ use type_of::*; use back::abi; use syntax::codemap::span; use syntax::print::pprust::expr_to_str; -use back::link::{ +use back::linkage::{ mangle_internal_name_by_path, mangle_internal_name_by_path_and_seq}; use util::ppaux::ty_to_str; diff --git a/src/rustc/middle/trans/common.rs b/src/rustc/middle/trans/common.rs index b0ac8d920bc8..f3fc4bfaa26a 100644 --- a/src/rustc/middle/trans/common.rs +++ b/src/rustc/middle/trans/common.rs @@ -10,7 +10,7 @@ use syntax::{ast, ast_map}; use driver::session; use session::session; use middle::ty; -use back::{link, abi, upcall}; +use back::{linkage, abi, upcall}; use syntax::codemap::span; use lib::llvm::{llvm, target_data, type_names, associate_type, name_has_type}; diff --git a/src/rustc/middle/trans/controlflow.rs b/src/rustc/middle/trans/controlflow.rs index 1affa18a6832..7eda33fb2fb0 100644 --- a/src/rustc/middle/trans/controlflow.rs +++ b/src/rustc/middle/trans/controlflow.rs @@ -165,7 +165,7 @@ fn trans_log(log_ex: @ast::expr, let global = if ccx.module_data.contains_key(modname) { ccx.module_data.get(modname) } else { - let s = link::mangle_internal_name_by_path_and_seq( + let s = linkage::mangle_internal_name_by_path_and_seq( ccx, modpath, ~"loglevel"); let global = str::as_c_str(s, |buf| { llvm::LLVMAddGlobal(ccx.llmod, T_i32(), buf) diff --git a/src/rustc/middle/trans/foreign.rs b/src/rustc/middle/trans/foreign.rs index b97fa54588c6..d267599095ab 100644 --- a/src/rustc/middle/trans/foreign.rs +++ b/src/rustc/middle/trans/foreign.rs @@ -10,7 +10,7 @@ use lib::llvm::{ llvm, TypeRef, ValueRef, Integer, Pointer, Float, Double, StructRetAttribute, ByValAttribute, SequentiallyConsistent, Acquire, Release, Xchg }; use syntax::{ast, ast_util}; -use back::{link, abi}; +use back::{linkage, abi}; use common::*; use build::*; use base::*; @@ -1007,7 +1007,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, id: ast::node_id) -> ValueRef { let _icx = ccx.insn_ctxt("foreign::foreign::build_rust_fn"); let t = ty::node_id_to_type(ccx.tcx, id); - let ps = link::mangle_internal_name_by_path( + let ps = linkage::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( syntax::parse::token::special_idents::clownshoe_abi ))); @@ -1046,7 +1046,7 @@ fn trans_foreign_fn(ccx: @crate_ctxt, path: ast_map::path, decl: ast::fn_decl, // is wired directly into the return slot in the shim struct } - let shim_name = link::mangle_internal_name_by_path( + let shim_name = linkage::mangle_internal_name_by_path( ccx, vec::append_one(path, ast_map::path_name( syntax::parse::token::special_idents::clownshoe_stack_shim ))); diff --git a/src/rustc/middle/trans/meth.rs b/src/rustc/middle/trans/meth.rs index a87ae02f8d28..ddb79f8cd4a7 100644 --- a/src/rustc/middle/trans/meth.rs +++ b/src/rustc/middle/trans/meth.rs @@ -8,7 +8,7 @@ use syntax::{ast, ast_map}; use ast_map::{path, path_mod, path_name, node_id_to_str}; use syntax::ast_util::local_def; use metadata::csearch; -use back::{link, abi}; +use back::abi; use lib::llvm::llvm; use lib::llvm::{ValueRef, TypeRef}; use lib::llvm::llvm::LLVMGetParam; diff --git a/src/rustc/middle/trans/monomorphize.rs b/src/rustc/middle/trans/monomorphize.rs index 243b0b96fa30..239988c06e55 100644 --- a/src/rustc/middle/trans/monomorphize.rs +++ b/src/rustc/middle/trans/monomorphize.rs @@ -9,7 +9,7 @@ use base::{trans_item, get_item_val, no_self, self_arg, trans_fn, get_insn_ctxt}; use syntax::parse::token::special_idents; use type_of::type_of_fn_from_ty; -use back::link::mangle_exported_name; +use back::linkage::mangle_exported_name; use middle::ty::{FnTyBase, FnMeta, FnSig}; fn monomorphic_fn(ccx: @crate_ctxt, diff --git a/src/rustc/rustc.rc b/src/rustc/rustc.rc index 501192d3ced1..46b2ff1fa509 100644 --- a/src/rustc/rustc.rc +++ b/src/rustc/rustc.rc @@ -121,7 +121,7 @@ mod front { } mod back { - mod link; + mod linkage; mod abi; mod upcall; mod x86; diff --git a/src/rustdoc/astsrv.rs b/src/rustdoc/astsrv.rs index cda89e3b0833..1f6ba5ed9075 100644 --- a/src/rustdoc/astsrv.rs +++ b/src/rustdoc/astsrv.rs @@ -17,7 +17,6 @@ use syntax::diagnostic::handler; use syntax::ast; use syntax::codemap; use syntax::ast_map; -use rustc::back::link; use rustc::metadata::filesearch; use rustc::front; diff --git a/src/rustdoc/doc.rs b/src/rustdoc/doc.rs index 5161fdff270a..154a7f1c6d0a 100644 --- a/src/rustdoc/doc.rs +++ b/src/rustdoc/doc.rs @@ -334,13 +334,13 @@ impl index : cmp::Eq { * * kind - The type of thing being indexed, e.g. 'Module' * * name - The name of the thing * * brief - The brief description - * * link - A format-specific string representing the link target + * * lnk - A format-specific string representing the link target */ type index_entry = { kind: ~str, name: ~str, brief: Option<~str>, - link: ~str + lnk: ~str }; impl index_entry : cmp::Eq { @@ -348,7 +348,7 @@ impl index_entry : cmp::Eq { self.kind == other.kind && self.name == other.name && self.brief == other.brief && - self.link == other.link + self.lnk == other.lnk } pure fn ne(&&other: index_entry) -> bool { !self.eq(other) } } diff --git a/src/rustdoc/markdown_index_pass.rs b/src/rustdoc/markdown_index_pass.rs index 172147b1f24a..067951ef6f9f 100644 --- a/src/rustdoc/markdown_index_pass.rs +++ b/src/rustdoc/markdown_index_pass.rs @@ -78,7 +78,7 @@ fn item_to_entry( doc: doc::itemtag, config: config::config ) -> doc::index_entry { - let link = match doc { + let lnk = match doc { doc::modtag(_) | doc::nmodtag(_) if config.output_style == config::doc_per_mod => { markdown_writer::make_filename(config, doc::itempage(doc)).to_str() @@ -92,7 +92,7 @@ fn item_to_entry( kind: markdown_pass::header_kind(doc), name: markdown_pass::header_name(doc), brief: doc.brief(), - link: link + lnk: lnk } } @@ -156,13 +156,13 @@ fn should_index_mod_contents() { kind: ~"Module", name: ~"a", brief: None, - link: ~"#module-a" + lnk: ~"#module-a" }; assert option::get(doc.cratemod().index).entries[1] == { kind: ~"Function", name: ~"b", brief: None, - link: ~"#function-b" + lnk: ~"#function-b" }; } @@ -176,13 +176,13 @@ fn should_index_mod_contents_multi_page() { kind: ~"Module", name: ~"a", brief: None, - link: ~"a.html" + lnk: ~"a.html" }; assert option::get(doc.cratemod().index).entries[1] == { kind: ~"Function", name: ~"b", brief: None, - link: ~"#function-b" + lnk: ~"#function-b" }; } @@ -196,7 +196,7 @@ fn should_index_foreign_mod_pages() { kind: ~"Foreign module", name: ~"a", brief: None, - link: ~"a.html" + lnk: ~"a.html" }; } @@ -220,7 +220,7 @@ fn should_index_foreign_mod_contents() { kind: ~"Function", name: ~"b", brief: None, - link: ~"#function-b" + lnk: ~"#function-b" }; } diff --git a/src/rustdoc/markdown_pass.rs b/src/rustdoc/markdown_pass.rs index 03726ca0188f..726bbc562377 100644 --- a/src/rustdoc/markdown_pass.rs +++ b/src/rustdoc/markdown_pass.rs @@ -398,7 +398,7 @@ fn write_index(ctxt: ctxt, index: doc::index) { for index.entries.each |entry| { let header = header_text_(entry.kind, entry.name); - let id = entry.link; + let id = entry.lnk; if option::is_some(entry.brief) { ctxt.w.write_line(fmt!("* [%s](%s) - %s", header, id, option::get(entry.brief))); diff --git a/src/test/run-pass/mlist-cycle.rs b/src/test/run-pass/mlist-cycle.rs index 0fcb95fb73ba..e07c066f9c99 100644 --- a/src/test/run-pass/mlist-cycle.rs +++ b/src/test/run-pass/mlist-cycle.rs @@ -2,14 +2,14 @@ // -*- rust -*- extern mod std; -type cell = {mut c: @list}; +type Cell = {mut c: @List}; -enum list { link(@cell), nil, } +enum List { Link(@Cell), Nil, } fn main() { - let first: @cell = @{mut c: @nil()}; - let second: @cell = @{mut c: @link(first)}; - first._0 = @link(second); + let first: @Cell = @{mut c: @Nil()}; + let second: @Cell = @{mut c: @Link(first)}; + first._0 = @Link(second); sys.rustrt.gc(); - let third: @cell = @{mut c: @nil()}; -} \ No newline at end of file + let third: @Cell = @{mut c: @Nil()}; +}