Remove uses of mutable ref mode.
It's still in the compiler right now, but warned about
This commit is contained in:
parent
04497ea7b9
commit
45345bda6a
@ -40,15 +40,15 @@
|
||||
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
|
||||
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
|
||||
pure fn nextafter(x: c_double, y: c_double) -> c_double;
|
||||
pure fn frexp(n: c_double, &value: c_int) -> c_double;
|
||||
pure fn frexp(n: c_double, value: &mut c_int) -> c_double;
|
||||
pure fn hypot(x: c_double, y: c_double) -> c_double;
|
||||
pure fn ldexp(x: c_double, n: c_int) -> c_double;
|
||||
#[cfg(unix)]
|
||||
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
|
||||
&sign: c_int) -> c_double;
|
||||
sign: &mut c_int) -> c_double;
|
||||
#[cfg(windows)]
|
||||
#[link_name="__lgamma_r"] pure fn lgamma(n: c_double,
|
||||
&sign: c_int) -> c_double;
|
||||
sign: &mut c_int) -> c_double;
|
||||
// renamed: log is a reserved keyword; ln seems more natural, too
|
||||
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
|
||||
// renamed: "logb" /often/ is confused for log2 by beginners
|
||||
@ -58,7 +58,7 @@
|
||||
pure fn log10(n: c_double) -> c_double;
|
||||
pure fn log2(n: c_double) -> c_double;
|
||||
#[link_name="ilogb"] pure fn ilog_radix(n: c_double) -> c_int;
|
||||
pure fn modf(n: c_double, &iptr: c_double) -> c_double;
|
||||
pure fn modf(n: c_double, iptr: &mut c_double) -> c_double;
|
||||
pure fn pow(n: c_double, e: c_double) -> c_double;
|
||||
// FIXME (#1379): enable when rounding modes become available
|
||||
// pure fn rint(n: c_double) -> c_double;
|
||||
@ -110,7 +110,7 @@
|
||||
#[link_name="fdimf"] pure fn abs_sub(a: c_float, b: c_float) -> c_float;
|
||||
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
|
||||
#[link_name="frexpf"] pure fn frexp(n: c_float,
|
||||
&value: c_int) -> c_float;
|
||||
value: &mut c_int) -> c_float;
|
||||
#[link_name="fmaf"] pure fn mul_add(a: c_float,
|
||||
b: c_float, c: c_float) -> c_float;
|
||||
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
|
||||
@ -122,11 +122,11 @@
|
||||
|
||||
#[cfg(unix)]
|
||||
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
|
||||
&sign: c_int) -> c_float;
|
||||
sign: &mut c_int) -> c_float;
|
||||
|
||||
#[cfg(windows)]
|
||||
#[link_name="__lgammaf_r"] pure fn lgamma(n: c_float,
|
||||
&sign: c_int) -> c_float;
|
||||
sign: &mut c_int) -> c_float;
|
||||
|
||||
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
|
||||
#[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
|
||||
@ -135,7 +135,7 @@
|
||||
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
|
||||
#[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
|
||||
#[link_name="modff"] pure fn modf(n: c_float,
|
||||
&iptr: c_float) -> c_float;
|
||||
iptr: &mut c_float) -> c_float;
|
||||
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
|
||||
// FIXME (#1379): enable when rounding modes become available
|
||||
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;
|
||||
|
@ -7,9 +7,18 @@
|
||||
|
||||
#[abi = "cdecl"]
|
||||
extern mod rustrt {
|
||||
#[legacy_exports];
|
||||
#[legacy_exports]
|
||||
#[cfg(stage0)]
|
||||
fn get_time(&sec: i64, &nsec: i32);
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
fn get_time(sec: &mut i64, nsec: &mut i32);
|
||||
|
||||
#[cfg(stage0)]
|
||||
fn precise_time_ns(&ns: u64);
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
fn precise_time_ns(ns: &mut u64);
|
||||
|
||||
fn rust_tzset();
|
||||
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
|
||||
@ -33,22 +42,41 @@ impl Timespec : Eq {
|
||||
* Returns the current time as a `timespec` containing the seconds and
|
||||
* nanoseconds since 1970-01-01T00:00:00Z.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn get_time() -> Timespec {
|
||||
let mut sec = 0i64;
|
||||
let mut nsec = 0i32;
|
||||
rustrt::get_time(sec, nsec);
|
||||
return {sec: sec, nsec: nsec};
|
||||
}
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
pub fn get_time() -> Timespec {
|
||||
let mut sec = 0i64;
|
||||
let mut nsec = 0i32;
|
||||
rustrt::get_time(&mut sec, &mut nsec);
|
||||
return {sec: sec, nsec: nsec};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current value of a high-resolution performance counter
|
||||
* in nanoseconds since an unspecified epoch.
|
||||
*/
|
||||
#[cfg(stage0)]
|
||||
pub fn precise_time_ns() -> u64 {
|
||||
let mut ns = 0u64;
|
||||
rustrt::precise_time_ns(ns);
|
||||
ns
|
||||
}
|
||||
#[cfg(stage1)]
|
||||
#[cfg(stage2)]
|
||||
pub fn precise_time_ns() -> u64 {
|
||||
let mut ns = 0u64;
|
||||
rustrt::precise_time_ns(&mut ns);
|
||||
ns
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the current value of a high-resolution performance counter
|
||||
|
@ -127,14 +127,14 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
|
||||
}
|
||||
}
|
||||
|
||||
fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) {
|
||||
fn push_blank_line_comment(rdr: string_reader, comments: &mut ~[cmnt]) {
|
||||
debug!(">>> blank-line comment");
|
||||
let v: ~[~str] = ~[];
|
||||
comments.push({style: blank_line, lines: v, pos: rdr.chpos});
|
||||
}
|
||||
|
||||
fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
||||
&comments: ~[cmnt]) {
|
||||
comments: &mut ~[cmnt]) {
|
||||
while is_whitespace(rdr.curr) && !is_eof(rdr) {
|
||||
if rdr.col == 0u && rdr.curr == '\n' {
|
||||
push_blank_line_comment(rdr, comments);
|
||||
@ -145,7 +145,7 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
|
||||
|
||||
|
||||
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: ~[cmnt]) {
|
||||
comments: &mut ~[cmnt]) {
|
||||
debug!(">>> shebang comment");
|
||||
let p = rdr.chpos;
|
||||
debug!("<<< shebang comment");
|
||||
@ -157,7 +157,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
}
|
||||
|
||||
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: ~[cmnt]) {
|
||||
comments: &mut ~[cmnt]) {
|
||||
debug!(">>> line comments");
|
||||
let p = rdr.chpos;
|
||||
let mut lines: ~[~str] = ~[];
|
||||
@ -188,8 +188,8 @@ fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
|
||||
return true;
|
||||
}
|
||||
|
||||
fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
|
||||
s: ~str, col: uint) unsafe {
|
||||
fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
|
||||
s: ~str, col: uint) {
|
||||
let mut s1;
|
||||
let len = str::len(s);
|
||||
if all_whitespace(s, 0u, uint::min(len, col)) {
|
||||
@ -202,7 +202,7 @@ fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
|
||||
}
|
||||
|
||||
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: ~[cmnt]) {
|
||||
comments: &mut ~[cmnt]) {
|
||||
debug!(">>> block comment");
|
||||
let p = rdr.chpos;
|
||||
let mut lines: ~[~str] = ~[];
|
||||
@ -228,7 +228,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
debug!("=== block comment level %d", level);
|
||||
if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
|
||||
if rdr.curr == '\n' {
|
||||
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
||||
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
|
||||
curr_line = ~"";
|
||||
bump(rdr);
|
||||
} else {
|
||||
@ -248,8 +248,8 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
}
|
||||
}
|
||||
}
|
||||
if str::len(curr_line) != 0u {
|
||||
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
|
||||
if str::len(curr_line) != 0 {
|
||||
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
|
||||
}
|
||||
let mut style = if code_to_the_left { trailing } else { isolated };
|
||||
consume_non_eol_whitespace(rdr);
|
||||
@ -267,7 +267,7 @@ fn peeking_at_comment(rdr: string_reader) -> bool {
|
||||
}
|
||||
|
||||
fn consume_comment(rdr: string_reader, code_to_the_left: bool,
|
||||
&comments: ~[cmnt]) {
|
||||
comments: &mut ~[cmnt]) {
|
||||
debug!(">>> consume comment");
|
||||
if rdr.curr == '/' && nextch(rdr) == '/' {
|
||||
read_line_comments(rdr, code_to_the_left, comments);
|
||||
@ -299,11 +299,11 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
|
||||
consume_non_eol_whitespace(rdr);
|
||||
if rdr.curr == '\n' {
|
||||
code_to_the_left = false;
|
||||
consume_whitespace_counting_blank_lines(rdr, comments);
|
||||
consume_whitespace_counting_blank_lines(rdr, &mut comments);
|
||||
}
|
||||
while peeking_at_comment(rdr) {
|
||||
consume_comment(rdr, code_to_the_left, comments);
|
||||
consume_whitespace_counting_blank_lines(rdr, comments);
|
||||
consume_comment(rdr, code_to_the_left, &mut comments);
|
||||
consume_whitespace_counting_blank_lines(rdr, &mut comments);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -10,8 +10,8 @@
|
||||
fn eval_crate_directives(cx: ctx,
|
||||
cdirs: ~[@ast::crate_directive],
|
||||
prefix: &Path,
|
||||
&view_items: ~[@ast::view_item],
|
||||
&items: ~[@ast::item]) {
|
||||
view_items: &mut~[@ast::view_item],
|
||||
items: &mut~[@ast::item]) {
|
||||
for cdirs.each |sub_cdir| {
|
||||
eval_crate_directive(cx, *sub_cdir, prefix, view_items, items);
|
||||
}
|
||||
@ -24,7 +24,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
|
||||
= parse_companion_mod(cx, prefix, suffix);
|
||||
let mut view_items: ~[@ast::view_item] = ~[];
|
||||
let mut items: ~[@ast::item] = ~[];
|
||||
eval_crate_directives(cx, cdirs, prefix, view_items, items);
|
||||
eval_crate_directives(cx, cdirs, prefix, &mut view_items, &mut items);
|
||||
return ({view_items: vec::append(view_items, cview_items),
|
||||
items: vec::append(items, citems)},
|
||||
cattrs);
|
||||
@ -82,8 +82,8 @@ fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
|
||||
}
|
||||
|
||||
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path,
|
||||
&view_items: ~[@ast::view_item],
|
||||
&items: ~[@ast::item]) {
|
||||
view_items: &mut ~[@ast::view_item],
|
||||
items: &mut ~[@ast::item]) {
|
||||
match cdir.node {
|
||||
ast::cdir_src_mod(vis, id, attrs) => {
|
||||
let file_path = Path(cdir_path_opt(
|
||||
|
@ -1276,7 +1276,8 @@ fn parse_tt_tok(p: parser, delim_ok: bool) -> token_tree {
|
||||
|
||||
return match self.token {
|
||||
token::LPAREN | token::LBRACE | token::LBRACKET => {
|
||||
let ket = token::flip_delimiter(self.token);
|
||||
// tjc: ??????
|
||||
let ket = token::flip_delimiter(copy self.token);
|
||||
tt_delim(vec::append(
|
||||
~[parse_tt_tok(self, true)],
|
||||
vec::append(
|
||||
@ -1297,7 +1298,8 @@ fn parse_matchers() -> ~[matcher] {
|
||||
return match self.token {
|
||||
token::LBRACE | token::LPAREN | token::LBRACKET => {
|
||||
self.parse_matcher_subseq(name_idx, copy self.token,
|
||||
token::flip_delimiter(self.token))
|
||||
// tjc: not sure why we need a copy
|
||||
token::flip_delimiter(copy self.token))
|
||||
}
|
||||
_ => self.fatal(~"expected open delimiter")
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ fn to_str(in: @ident_interner, t: token) -> ~str {
|
||||
}
|
||||
|
||||
/// what's the opposite delimiter?
|
||||
fn flip_delimiter(&t: token::token) -> token::token {
|
||||
fn flip_delimiter(t: token::token) -> token::token {
|
||||
match t {
|
||||
token::LPAREN => token::RPAREN,
|
||||
token::LBRACE => token::RBRACE,
|
||||
|
@ -117,7 +117,7 @@ fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
|
||||
type entry<T> = {val: T, pos: uint};
|
||||
|
||||
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
|
||||
&index: ~[entry<~str>], name: ident) {
|
||||
index: &mut ~[entry<~str>], name: ident) {
|
||||
let mut full_path = ~[];
|
||||
full_path.push_all(path);
|
||||
full_path.push(name);
|
||||
|
@ -396,10 +396,10 @@ impl bckerr : cmp::Eq {
|
||||
pure_map: HashMap<ast::node_id, bckerr>
|
||||
};
|
||||
|
||||
fn save_and_restore<T:Copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
|
||||
let old_save_and_restore_t = save_and_restore_t;
|
||||
fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
|
||||
let old_save_and_restore_t = *save_and_restore_t;
|
||||
let u <- f();
|
||||
save_and_restore_t = old_save_and_restore_t;
|
||||
*save_and_restore_t = old_save_and_restore_t;
|
||||
move u
|
||||
}
|
||||
|
||||
|
@ -542,9 +542,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
|
||||
visitor: visit::vt<check_loan_ctxt>) {
|
||||
|
||||
debug!("purity on entry=%?", copy self.declared_purity);
|
||||
do save_and_restore(self.in_ctor) {
|
||||
do save_and_restore(self.declared_purity) {
|
||||
do save_and_restore(self.fn_args) {
|
||||
do save_and_restore(&mut(self.in_ctor)) {
|
||||
do save_and_restore(&mut(self.declared_purity)) {
|
||||
do save_and_restore(&mut(self.fn_args)) {
|
||||
let is_stack_closure = self.is_stack_closure(id);
|
||||
let fty = ty::node_id_to_type(self.tcx(), id);
|
||||
self.declared_purity = ty::determine_inherited_purity(
|
||||
@ -667,7 +667,7 @@ fn check_loans_in_expr(expr: @ast::expr,
|
||||
fn check_loans_in_block(blk: ast::blk,
|
||||
&&self: check_loan_ctxt,
|
||||
vt: visit::vt<check_loan_ctxt>) {
|
||||
do save_and_restore(self.declared_purity) {
|
||||
do save_and_restore(&mut(self.declared_purity)) {
|
||||
self.check_for_conflicting_loans(blk.node.id);
|
||||
|
||||
match blk.node.rules {
|
||||
|
@ -831,9 +831,9 @@ fn merge_from_succ(ln: LiveNode, succ_ln: LiveNode,
|
||||
let mut changed = false;
|
||||
do self.indices2(ln, succ_ln) |idx, succ_idx| {
|
||||
changed |= copy_if_invalid(copy self.users[succ_idx].reader,
|
||||
self.users[idx].reader);
|
||||
&mut self.users[idx].reader);
|
||||
changed |= copy_if_invalid(copy self.users[succ_idx].writer,
|
||||
self.users[idx].writer);
|
||||
&mut self.users[idx].writer);
|
||||
if self.users[succ_idx].used && !self.users[idx].used {
|
||||
self.users[idx].used = true;
|
||||
changed = true;
|
||||
@ -844,10 +844,10 @@ fn merge_from_succ(ln: LiveNode, succ_ln: LiveNode,
|
||||
ln.to_str(), self.ln_str(succ_ln), first_merge, changed);
|
||||
return changed;
|
||||
|
||||
fn copy_if_invalid(src: LiveNode, &dst: LiveNode) -> bool {
|
||||
fn copy_if_invalid(src: LiveNode, dst: &mut LiveNode) -> bool {
|
||||
if src.is_valid() {
|
||||
if !dst.is_valid() {
|
||||
dst = src;
|
||||
*dst = src;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
use common::*;
|
||||
use build::*;
|
||||
use base::*;
|
||||
use shape::llsize_of;
|
||||
use datum::immediate_rvalue;
|
||||
|
||||
export make_free_glue, autoderef, duplicate;
|
||||
|
Loading…
Reference in New Issue
Block a user