Skip to content

Commit f8bc0d2

Browse files
committed
Revert "wip"
This reverts commit ca49fd4.
1 parent ca49fd4 commit f8bc0d2

File tree

23 files changed

+97
-93
lines changed

23 files changed

+97
-93
lines changed

src/libcore/cmath.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ pub extern mod c_double {
4040
#[link_name="fmax"] pure fn fmax(a: c_double, b: c_double) -> c_double;
4141
#[link_name="fmin"] pure fn fmin(a: c_double, b: c_double) -> c_double;
4242
pure fn nextafter(x: c_double, y: c_double) -> c_double;
43-
pure fn frexp(n: c_double, value: &mut c_int) -> c_double;
43+
pure fn frexp(n: c_double, &value: c_int) -> c_double;
4444
pure fn hypot(x: c_double, y: c_double) -> c_double;
4545
pure fn ldexp(x: c_double, n: c_int) -> c_double;
4646
#[cfg(unix)]
4747
#[link_name="lgamma_r"] pure fn lgamma(n: c_double,
48-
sign: &mut c_int) -> c_double;
48+
&sign: c_int) -> c_double;
4949
#[cfg(windows)]
5050
#[link_name="__lgamma_r"] pure fn lgamma(n: c_double,
51-
sign: &mut c_int) -> c_double;
51+
&sign: c_int) -> c_double;
5252
// renamed: log is a reserved keyword; ln seems more natural, too
5353
#[link_name="log"] pure fn ln(n: c_double) -> c_double;
5454
// renamed: "logb" /often/ is confused for log2 by beginners
@@ -58,7 +58,7 @@ pub extern mod c_double {
5858
pure fn log10(n: c_double) -> c_double;
5959
pure fn log2(n: c_double) -> c_double;
6060
#[link_name="ilogb"] pure fn ilog_radix(n: c_double) -> c_int;
61-
pure fn modf(n: c_double, iptr: &mut c_double) -> c_double;
61+
pure fn modf(n: c_double, &iptr: c_double) -> c_double;
6262
pure fn pow(n: c_double, e: c_double) -> c_double;
6363
// FIXME (#1379): enable when rounding modes become available
6464
// pure fn rint(n: c_double) -> c_double;
@@ -110,7 +110,7 @@ pub extern mod c_float {
110110
#[link_name="fdimf"] pure fn abs_sub(a: c_float, b: c_float) -> c_float;
111111
#[link_name="floorf"] pure fn floor(n: c_float) -> c_float;
112112
#[link_name="frexpf"] pure fn frexp(n: c_float,
113-
value: &mut c_int) -> c_float;
113+
&value: c_int) -> c_float;
114114
#[link_name="fmaf"] pure fn mul_add(a: c_float,
115115
b: c_float, c: c_float) -> c_float;
116116
#[link_name="fmaxf"] pure fn fmax(a: c_float, b: c_float) -> c_float;
@@ -122,11 +122,11 @@ pub extern mod c_float {
122122

123123
#[cfg(unix)]
124124
#[link_name="lgammaf_r"] pure fn lgamma(n: c_float,
125-
sign: &mut c_int) -> c_float;
125+
&sign: c_int) -> c_float;
126126

127127
#[cfg(windows)]
128128
#[link_name="__lgammaf_r"] pure fn lgamma(n: c_float,
129-
sign: &mut c_int) -> c_float;
129+
&sign: c_int) -> c_float;
130130

131131
#[link_name="logf"] pure fn ln(n: c_float) -> c_float;
132132
#[link_name="logbf"] pure fn log_radix(n: c_float) -> c_float;
@@ -135,7 +135,7 @@ pub extern mod c_float {
135135
#[link_name="log10f"] pure fn log10(n: c_float) -> c_float;
136136
#[link_name="ilogbf"] pure fn ilog_radix(n: c_float) -> c_int;
137137
#[link_name="modff"] pure fn modf(n: c_float,
138-
iptr: &mut c_float) -> c_float;
138+
&iptr: c_float) -> c_float;
139139
#[link_name="powf"] pure fn pow(n: c_float, e: c_float) -> c_float;
140140
// FIXME (#1379): enable when rounding modes become available
141141
// #[link_name="rintf"] pure fn rint(n: c_float) -> c_float;

src/libstd/time.rs

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,9 @@ use result::{Result, Ok, Err};
77

88
#[abi = "cdecl"]
99
extern mod rustrt {
10-
#[legacy_exports]
11-
#[cfg(stage0)]
10+
#[legacy_exports];
1211
fn get_time(&sec: i64, &nsec: i32);
13-
#[cfg(stage1)]
14-
#[cfg(stage2)]
15-
fn get_time(sec: &mut i64, nsec: &mut i32);
16-
17-
#[cfg(stage0)]
1812
fn precise_time_ns(&ns: u64);
19-
#[cfg(stage1)]
20-
#[cfg(stage2)]
21-
fn precise_time_ns(ns: &mut u64);
2213

2314
fn rust_tzset();
2415
// FIXME: The i64 values can be passed by-val when #2064 is fixed.
@@ -42,41 +33,22 @@ impl Timespec : Eq {
4233
* Returns the current time as a `timespec` containing the seconds and
4334
* nanoseconds since 1970-01-01T00:00:00Z.
4435
*/
45-
#[cfg(stage0)]
4636
pub fn get_time() -> Timespec {
4737
let mut sec = 0i64;
4838
let mut nsec = 0i32;
4939
rustrt::get_time(sec, nsec);
5040
return {sec: sec, nsec: nsec};
5141
}
52-
#[cfg(stage1)]
53-
#[cfg(stage2)]
54-
pub fn get_time() -> Timespec {
55-
let mut sec = 0i64;
56-
let mut nsec = 0i32;
57-
rustrt::get_time(&mut sec, &mut nsec);
58-
return {sec: sec, nsec: nsec};
59-
}
60-
6142

6243
/**
6344
* Returns the current value of a high-resolution performance counter
6445
* in nanoseconds since an unspecified epoch.
6546
*/
66-
#[cfg(stage0)]
6747
pub fn precise_time_ns() -> u64 {
6848
let mut ns = 0u64;
6949
rustrt::precise_time_ns(ns);
7050
ns
7151
}
72-
#[cfg(stage1)]
73-
#[cfg(stage2)]
74-
pub fn precise_time_ns() -> u64 {
75-
let mut ns = 0u64;
76-
rustrt::precise_time_ns(&mut ns);
77-
ns
78-
}
79-
8052

8153
/**
8254
* Returns the current value of a high-resolution performance counter

src/libsyntax/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ impl<T:cmp::Eq> inferable<T> : cmp::Eq {
574574

575575
// "resolved" mode: the real modes.
576576
#[auto_serialize]
577-
enum rmode { by_ref, by_val, by_move, by_copy }
577+
enum rmode { by_ref, by_val, by_mutbl_ref, by_move, by_copy }
578578

579579
impl rmode : to_bytes::IterBytes {
580580
pure fn iter_bytes(+lsb0: bool, f: to_bytes::Cb) {

src/libsyntax/parse/comments.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@ fn consume_non_eol_whitespace(rdr: string_reader) {
127127
}
128128
}
129129
130-
fn push_blank_line_comment(rdr: string_reader, comments: &mut ~[cmnt]) {
130+
fn push_blank_line_comment(rdr: string_reader, &comments: ~[cmnt]) {
131131
debug!(">>> blank-line comment");
132132
let v: ~[~str] = ~[];
133133
comments.push({style: blank_line, lines: v, pos: rdr.chpos});
134134
}
135135
136136
fn consume_whitespace_counting_blank_lines(rdr: string_reader,
137-
comments: &mut ~[cmnt]) {
137+
&comments: ~[cmnt]) {
138138
while is_whitespace(rdr.curr) && !is_eof(rdr) {
139139
if rdr.col == 0u && rdr.curr == '\n' {
140140
push_blank_line_comment(rdr, comments);
@@ -145,7 +145,7 @@ fn consume_whitespace_counting_blank_lines(rdr: string_reader,
145145
146146
147147
fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
148-
comments: &mut ~[cmnt]) {
148+
&comments: ~[cmnt]) {
149149
debug!(">>> shebang comment");
150150
let p = rdr.chpos;
151151
debug!("<<< shebang comment");
@@ -157,7 +157,7 @@ fn read_shebang_comment(rdr: string_reader, code_to_the_left: bool,
157157
}
158158
159159
fn read_line_comments(rdr: string_reader, code_to_the_left: bool,
160-
comments: &mut ~[cmnt]) {
160+
&comments: ~[cmnt]) {
161161
debug!(">>> line comments");
162162
let p = rdr.chpos;
163163
let mut lines: ~[~str] = ~[];
@@ -188,8 +188,8 @@ fn all_whitespace(s: ~str, begin: uint, end: uint) -> bool {
188188
return true;
189189
}
190190
191-
fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
192-
s: ~str, col: uint) {
191+
fn trim_whitespace_prefix_and_push_line(&lines: ~[~str],
192+
s: ~str, col: uint) unsafe {
193193
let mut s1;
194194
let len = str::len(s);
195195
if all_whitespace(s, 0u, uint::min(len, col)) {
@@ -202,7 +202,7 @@ fn trim_whitespace_prefix_and_push_line(lines: &mut ~[~str],
202202
}
203203
204204
fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
205-
comments: &mut ~[cmnt]) {
205+
&comments: ~[cmnt]) {
206206
debug!(">>> block comment");
207207
let p = rdr.chpos;
208208
let mut lines: ~[~str] = ~[];
@@ -228,7 +228,7 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
228228
debug!("=== block comment level %d", level);
229229
if is_eof(rdr) {(rdr as reader).fatal(~"unterminated block comment");}
230230
if rdr.curr == '\n' {
231-
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
231+
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
232232
curr_line = ~"";
233233
bump(rdr);
234234
} else {
@@ -248,8 +248,8 @@ fn read_block_comment(rdr: string_reader, code_to_the_left: bool,
248248
}
249249
}
250250
}
251-
if str::len(curr_line) != 0 {
252-
trim_whitespace_prefix_and_push_line(&mut lines, curr_line, col);
251+
if str::len(curr_line) != 0u {
252+
trim_whitespace_prefix_and_push_line(lines, curr_line, col);
253253
}
254254
let mut style = if code_to_the_left { trailing } else { isolated };
255255
consume_non_eol_whitespace(rdr);
@@ -267,7 +267,7 @@ fn peeking_at_comment(rdr: string_reader) -> bool {
267267
}
268268
269269
fn consume_comment(rdr: string_reader, code_to_the_left: bool,
270-
comments: &mut ~[cmnt]) {
270+
&comments: ~[cmnt]) {
271271
debug!(">>> consume comment");
272272
if rdr.curr == '/' && nextch(rdr) == '/' {
273273
read_line_comments(rdr, code_to_the_left, comments);
@@ -299,11 +299,11 @@ fn gather_comments_and_literals(span_diagnostic: diagnostic::span_handler,
299299
consume_non_eol_whitespace(rdr);
300300
if rdr.curr == '\n' {
301301
code_to_the_left = false;
302-
consume_whitespace_counting_blank_lines(rdr, &mut comments);
302+
consume_whitespace_counting_blank_lines(rdr, comments);
303303
}
304304
while peeking_at_comment(rdr) {
305-
consume_comment(rdr, code_to_the_left, &mut comments);
306-
consume_whitespace_counting_blank_lines(rdr, &mut comments);
305+
consume_comment(rdr, code_to_the_left, comments);
306+
consume_whitespace_counting_blank_lines(rdr, comments);
307307
}
308308
break;
309309
}

src/libsyntax/parse/eval.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ type ctx =
1010
fn eval_crate_directives(cx: ctx,
1111
cdirs: ~[@ast::crate_directive],
1212
prefix: &Path,
13-
view_items: &mut~[@ast::view_item],
14-
items: &mut~[@ast::item]) {
13+
&view_items: ~[@ast::view_item],
14+
&items: ~[@ast::item]) {
1515
for cdirs.each |sub_cdir| {
1616
eval_crate_directive(cx, *sub_cdir, prefix, view_items, items);
1717
}
@@ -24,7 +24,7 @@ fn eval_crate_directives_to_mod(cx: ctx, cdirs: ~[@ast::crate_directive],
2424
= parse_companion_mod(cx, prefix, suffix);
2525
let mut view_items: ~[@ast::view_item] = ~[];
2626
let mut items: ~[@ast::item] = ~[];
27-
eval_crate_directives(cx, cdirs, prefix, &mut view_items, &mut items);
27+
eval_crate_directives(cx, cdirs, prefix, view_items, items);
2828
return ({view_items: vec::append(view_items, cview_items),
2929
items: vec::append(items, citems)},
3030
cattrs);
@@ -82,8 +82,8 @@ fn cdir_path_opt(default: ~str, attrs: ~[ast::attribute]) -> ~str {
8282
}
8383

8484
fn eval_crate_directive(cx: ctx, cdir: @ast::crate_directive, prefix: &Path,
85-
view_items: &mut ~[@ast::view_item],
86-
items: &mut ~[@ast::item]) {
85+
&view_items: ~[@ast::view_item],
86+
&items: ~[@ast::item]) {
8787
match cdir.node {
8888
ast::cdir_src_mod(vis, id, attrs) => {
8989
let file_path = Path(cdir_path_opt(

src/libsyntax/parse/parser.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute,
2626
bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move,
2727
bitand, bitor, bitxor, blk, blk_check_mode, bound_const,
2828
bound_copy, bound_send, bound_trait, bound_owned, box, by_copy,
29-
by_move, by_ref, by_val, capture_clause,
29+
by_move, by_mutbl_ref, by_ref, by_val, capture_clause,
3030
capture_item, cdir_dir_mod, cdir_src_mod, cdir_view_item,
3131
class_immutable, class_mutable,
3232
crate, crate_cfg, crate_directive, decl, decl_item, decl_local,
@@ -571,7 +571,7 @@ impl parser {
571571
fn parse_arg_mode() -> mode {
572572
if self.eat(token::BINOP(token::AND)) {
573573
self.warn(~"Obsolete syntax has no effect");
574-
expl(by_val)
574+
expl(by_mutbl_ref)
575575
} else if self.eat(token::BINOP(token::MINUS)) {
576576
expl(by_move)
577577
} else if self.eat(token::ANDAND) {
@@ -1276,8 +1276,7 @@ impl parser {
12761276

12771277
return match self.token {
12781278
token::LPAREN | token::LBRACE | token::LBRACKET => {
1279-
// tjc: ??????
1280-
let ket = token::flip_delimiter(copy self.token);
1279+
let ket = token::flip_delimiter(self.token);
12811280
tt_delim(vec::append(
12821281
~[parse_tt_tok(self, true)],
12831282
vec::append(
@@ -1298,8 +1297,7 @@ impl parser {
12981297
return match self.token {
12991298
token::LBRACE | token::LPAREN | token::LBRACKET => {
13001299
self.parse_matcher_subseq(name_idx, copy self.token,
1301-
// tjc: not sure why we need a copy
1302-
token::flip_delimiter(copy self.token))
1300+
token::flip_delimiter(self.token))
13031301
}
13041302
_ => self.fatal(~"expected open delimiter")
13051303
}

src/libsyntax/parse/token.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pure fn can_begin_expr(t: token) -> bool {
230230
}
231231

232232
/// what's the opposite delimiter?
233-
fn flip_delimiter(t: token::token) -> token::token {
233+
fn flip_delimiter(&t: token::token) -> token::token {
234234
match t {
235235
token::LPAREN => token::RPAREN,
236236
token::LBRACE => token::RBRACE,

src/libsyntax/print/pprust.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,7 @@ fn print_fn_block_args(s: ps, decl: ast::fn_decl,
16881688
16891689
fn mode_to_str(m: ast::mode) -> ~str {
16901690
match m {
1691+
ast::expl(ast::by_mutbl_ref) => ~"&",
16911692
ast::expl(ast::by_move) => ~"-",
16921693
ast::expl(ast::by_ref) => ~"&&",
16931694
ast::expl(ast::by_val) => ~"++",

src/rustc/metadata/encoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn encode_mutability(ebml_w: ebml::Writer, mt: class_mutability) {
116116
type entry<T> = {val: T, pos: uint};
117117

118118
fn add_to_index(ecx: @encode_ctxt, ebml_w: ebml::Writer, path: &[ident],
119-
index: &mut ~[entry<~str>], name: ident) {
119+
&index: ~[entry<~str>], name: ident) {
120120
let mut full_path = ~[];
121121
full_path.push_all(path);
122122
full_path.push(name);

src/rustc/metadata/tydecode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ fn parse_arg(st: @pstate, conv: conv_did) -> ty::arg {
394394

395395
fn parse_mode(st: @pstate) -> ast::mode {
396396
let m = ast::expl(match next(st) {
397+
'&' => ast::by_mutbl_ref,
397398
'-' => ast::by_move,
398399
'+' => ast::by_copy,
399400
'=' => ast::by_ref,

src/rustc/metadata/tyencode.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ fn enc_arg(w: io::Writer, cx: @ctxt, arg: ty::arg) {
332332

333333
fn enc_mode(w: io::Writer, cx: @ctxt, m: mode) {
334334
match ty::resolved_mode(cx.tcx, m) {
335+
by_mutbl_ref => w.write_char('&'),
335336
by_move => w.write_char('-'),
336337
by_copy => w.write_char('+'),
337338
by_ref => w.write_char('='),

src/rustc/middle/borrowck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,10 @@ type req_maps = {
396396
pure_map: HashMap<ast::node_id, bckerr>
397397
};
398398

399-
fn save_and_restore<T:Copy,U>(save_and_restore_t: &mut T, f: fn() -> U) -> U {
400-
let old_save_and_restore_t = *save_and_restore_t;
399+
fn save_and_restore<T:Copy,U>(&save_and_restore_t: T, f: fn() -> U) -> U {
400+
let old_save_and_restore_t = save_and_restore_t;
401401
let u <- f();
402-
*save_and_restore_t = old_save_and_restore_t;
402+
save_and_restore_t = old_save_and_restore_t;
403403
move u
404404
}
405405

src/rustc/middle/borrowck/check_loans.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,8 @@ impl check_loan_ctxt {
529529
ast::by_move => {
530530
self.check_move_out(*arg);
531531
}
532-
ast::by_ref | ast::by_copy | ast::by_val => {
532+
ast::by_mutbl_ref | ast::by_ref |
533+
ast::by_copy | ast::by_val => {
533534
}
534535
}
535536
}
@@ -541,9 +542,9 @@ fn check_loans_in_fn(fk: visit::fn_kind, decl: ast::fn_decl, body: ast::blk,
541542
visitor: visit::vt<check_loan_ctxt>) {
542543

543544
debug!("purity on entry=%?", copy self.declared_purity);
544-
do save_and_restore(&mut(self.in_ctor)) {
545-
do save_and_restore(&mut(self.declared_purity)) {
546-
do save_and_restore(&mut(self.fn_args)) {
545+
do save_and_restore(self.in_ctor) {
546+
do save_and_restore(self.declared_purity) {
547+
do save_and_restore(self.fn_args) {
547548
let is_stack_closure = self.is_stack_closure(id);
548549
let fty = ty::node_id_to_type(self.tcx(), id);
549550
self.declared_purity = ty::determine_inherited_purity(
@@ -666,7 +667,7 @@ fn check_loans_in_expr(expr: @ast::expr,
666667
fn check_loans_in_block(blk: ast::blk,
667668
&&self: check_loan_ctxt,
668669
vt: visit::vt<check_loan_ctxt>) {
669-
do save_and_restore(&mut(self.declared_purity)) {
670+
do save_and_restore(self.declared_purity) {
670671
self.check_for_conflicting_loans(blk.node.id);
671672

672673
match blk.node.rules {

src/rustc/middle/borrowck/gather_loans.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ fn req_loans_in_expr(ex: @ast::expr,
115115
let scope_r = ty::re_scope(ex.id);
116116
for vec::each2(args, arg_tys) |arg, arg_ty| {
117117
match ty::resolved_mode(self.tcx(), arg_ty.mode) {
118+
ast::by_mutbl_ref => {
119+
let arg_cmt = self.bccx.cat_expr(*arg);
120+
self.guarantee_valid(arg_cmt, m_mutbl, scope_r);
121+
}
118122
ast::by_ref => {
119123
let arg_cmt = self.bccx.cat_expr(*arg);
120124
self.guarantee_valid(arg_cmt, m_imm, scope_r);

0 commit comments

Comments
 (0)