Skip to content

Commit aa3505d

Browse files
committed
Merge remote-tracking branch 'remotes/origin/incoming' into incoming
2 parents 85fecd0 + 0fd1b58 commit aa3505d

33 files changed

+370
-166
lines changed

src/libcore/comm.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use vec;
1717

1818
use pipes::{recv, try_recv, wait_many, peek, PacketHeader};
1919

20-
// NOTE Making this public exposes some plumbing from pipes. Needs
21-
// some refactoring
20+
// FIXME #5160: Making this public exposes some plumbing from
21+
// pipes. Needs some refactoring
2222
pub use pipes::Selectable;
2323

2424
/// A trait for things that can send multiple messages.

src/libcore/core.rc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -41,7 +41,7 @@ Implicitly, all crates behave as if they included the following prologue:
4141
url = "https://github.com/mozilla/rust/tree/master/src/libcore")];
4242

4343
#[comment = "The Rust core library"];
44-
#[license = "MIT"];
44+
#[license = "MIT/ASL2"];
4545
#[crate_type = "lib"];
4646

4747

src/libcore/num/strconv.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,16 @@ pub pure fn from_str_bytes_common<T:NumCast+Zero+One+Ord+Copy+Div<T,T>+
478478
}
479479
}
480480

481-
// XXX: Bytevector constant from str
482481
if special {
483-
if buf == str::to_bytes("inf") || buf == str::to_bytes("+inf") {
482+
if buf == str::inf_buf || buf == str::positive_inf_buf {
484483
return NumStrConv::inf();
485-
} else if buf == str::to_bytes("-inf") {
484+
} else if buf == str::negative_inf_buf {
486485
if negative {
487486
return NumStrConv::neg_inf();
488487
} else {
489488
return None;
490489
}
491-
} else if buf == str::to_bytes("NaN") {
490+
} else if buf == str::nan_buf {
492491
return NumStrConv::NaN();
493492
}
494493
}

src/libcore/str.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,13 @@ const tag_five_b: uint = 248u;
18321832
const max_five_b: uint = 67108864u;
18331833
const tag_six_b: uint = 252u;
18341834

1835+
// Constants used for converting strs to floats
1836+
pub const inf_buf: [u8*3] = ['i' as u8, 'n' as u8, 'f' as u8];
1837+
pub const positive_inf_buf: [u8*4] = ['+' as u8, 'i' as u8,
1838+
'n' as u8, 'f' as u8];
1839+
pub const negative_inf_buf: [u8*4] = ['-' as u8, 'i' as u8,
1840+
'n' as u8, 'f' as u8];
1841+
pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8];
18351842

18361843
/**
18371844
* Work with the byte buffer of a string.

src/libfuzzer/fuzzer.rc

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
1+
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
22
// file at the top-level directory of this distribution and at
33
// http://rust-lang.org/COPYRIGHT.
44
//
@@ -15,7 +15,7 @@
1515
url = "https://github.com/mozilla/rust/tree/master/src/libfuzzer")];
1616

1717
#[comment = "The Rust fuzzer library"];
18-
#[license = "MIT"];
18+
#[license = "MIT/ASL2"];
1919
#[crate_type = "lib"];
2020
#[no_core];
2121

src/librust/rust.rc

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
uuid = "4a24da33-5cc8-4037-9352-2cbe9bd9d27c",
1818
url = "https://github.com/mozilla/rust/tree/master/src/rust")];
1919

20+
#[license = "MIT/ASL2"];
2021
#[crate_type = "lib"];
2122

2223
extern mod core(vers = "0.6");

src/librustc/middle/astencode.rs

+11-3
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,17 @@ impl tr for ast::def {
451451
452452
impl tr for ty::AutoAdjustment {
453453
fn tr(&self, xcx: @ExtendedDecodeContext) -> ty::AutoAdjustment {
454-
ty::AutoAdjustment {
455-
autoderefs: self.autoderefs,
456-
autoref: self.autoref.map(|ar| ar.tr(xcx)),
454+
match self {
455+
&ty::AutoAddEnv(r, s) => {
456+
ty::AutoAddEnv(r.tr(xcx), s)
457+
}
458+
459+
&ty::AutoDerefRef(ref adr) => {
460+
ty::AutoDerefRef(ty::AutoDerefRef {
461+
autoderefs: adr.autoderefs,
462+
autoref: adr.autoref.map(|ar| ar.tr(xcx)),
463+
})
464+
}
457465
}
458466
}
459467
}

src/librustc/middle/borrowck/gather_loans.rs

+14-4
Original file line numberDiff line numberDiff line change
@@ -299,17 +299,27 @@ pub impl GatherLoanCtxt {
299299
expr_repr(self.tcx(), expr), adjustment);
300300
let _i = indenter();
301301

302-
match adjustment.autoref {
303-
None => {
302+
match *adjustment {
303+
ty::AutoAddEnv(*) => {
304+
debug!("autoaddenv -- no autoref");
305+
return;
306+
}
307+
308+
ty::AutoDerefRef(
309+
ty::AutoDerefRef {
310+
autoref: None, _ }) => {
304311
debug!("no autoref");
305312
return;
306313
}
307314

308-
Some(ref autoref) => {
315+
ty::AutoDerefRef(
316+
ty::AutoDerefRef {
317+
autoref: Some(ref autoref),
318+
autoderefs: autoderefs}) => {
309319
let mcx = &mem_categorization_ctxt {
310320
tcx: self.tcx(),
311321
method_map: self.bccx.method_map};
312-
let mut cmt = mcx.cat_expr_autoderefd(expr, adjustment);
322+
let mut cmt = mcx.cat_expr_autoderefd(expr, autoderefs);
313323
debug!("after autoderef, cmt=%s", self.bccx.cmt_to_repr(cmt));
314324

315325
match autoref.kind {

src/librustc/middle/borrowck/mod.rs

+14-3
Original file line numberDiff line numberDiff line change
@@ -480,9 +480,20 @@ pub impl BorrowckCtxt {
480480
}
481481

482482
fn cat_expr_autoderefd(&self, expr: @ast::expr,
483-
adj: @ty::AutoAdjustment)
484-
-> cmt {
485-
cat_expr_autoderefd(self.tcx, self.method_map, expr, adj)
483+
adj: @ty::AutoAdjustment) -> cmt {
484+
match *adj {
485+
ty::AutoAddEnv(*) => {
486+
// no autoderefs
487+
cat_expr_unadjusted(self.tcx, self.method_map, expr)
488+
}
489+
490+
ty::AutoDerefRef(
491+
ty::AutoDerefRef {
492+
autoderefs: autoderefs, _}) => {
493+
cat_expr_autoderefd(self.tcx, self.method_map, expr,
494+
autoderefs)
495+
}
496+
}
486497
}
487498

488499
fn cat_def(&self,

src/librustc/middle/mem_categorization.rs

+28-18
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ pub fn cat_expr_autoderefd(
241241
tcx: ty::ctxt,
242242
method_map: typeck::method_map,
243243
expr: @ast::expr,
244-
adj: @ty::AutoAdjustment) -> cmt {
245-
244+
autoderefs: uint) -> cmt
245+
{
246246
let mcx = &mem_categorization_ctxt {
247247
tcx: tcx, method_map: method_map
248248
};
249-
return mcx.cat_expr_autoderefd(expr, adj);
249+
return mcx.cat_expr_autoderefd(expr, autoderefs);
250250
}
251251

252252
pub fn cat_def(
@@ -361,28 +361,38 @@ pub impl mem_categorization_ctxt {
361361
self.cat_expr_unadjusted(expr)
362362
}
363363

364-
Some(adjustment) => {
365-
match adjustment.autoref {
366-
Some(_) => {
367-
// Equivalent to &*expr or something similar.
368-
// This is an rvalue, effectively.
369-
let expr_ty = ty::expr_ty(self.tcx, expr);
370-
self.cat_rvalue(expr, expr_ty)
371-
}
372-
None => {
373-
// Equivalent to *expr or something similar.
374-
self.cat_expr_autoderefd(expr, adjustment)
375-
}
376-
}
364+
Some(@ty::AutoAddEnv(*)) => {
365+
// Convert a bare fn to a closure by adding NULL env.
366+
// Result is an rvalue.
367+
let expr_ty = ty::expr_ty_adjusted(self.tcx, expr);
368+
self.cat_rvalue(expr, expr_ty)
369+
}
370+
371+
Some(
372+
@ty::AutoDerefRef(
373+
ty::AutoDerefRef {
374+
autoref: Some(_), _})) => {
375+
// Equivalent to &*expr or something similar.
376+
// Result is an rvalue.
377+
let expr_ty = ty::expr_ty_adjusted(self.tcx, expr);
378+
self.cat_rvalue(expr, expr_ty)
379+
}
380+
381+
Some(
382+
@ty::AutoDerefRef(
383+
ty::AutoDerefRef {
384+
autoref: None, autoderefs: autoderefs})) => {
385+
// Equivalent to *expr or something similar.
386+
self.cat_expr_autoderefd(expr, autoderefs)
377387
}
378388
}
379389
}
380390

381391
fn cat_expr_autoderefd(&self,
382392
expr: @ast::expr,
383-
adjustment: &ty::AutoAdjustment) -> cmt {
393+
autoderefs: uint) -> cmt {
384394
let mut cmt = self.cat_expr_unadjusted(expr);
385-
for uint::range(1, adjustment.autoderefs+1) |deref| {
395+
for uint::range(1, autoderefs+1) |deref| {
386396
cmt = self.cat_deref(expr, cmt, deref);
387397
}
388398
return cmt;

src/librustc/middle/moves.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,9 @@ pub impl VisitContext {
410410
// those adjustments is to take a reference, then it's only
411411
// reading the underlying expression, not moving it.
412412
let comp_mode = match self.tcx.adjustments.find(&expr.id) {
413-
Some(adj) if adj.autoref.is_some() => Read,
413+
Some(@ty::AutoDerefRef(
414+
ty::AutoDerefRef {
415+
autoref: Some(_), _})) => Read,
414416
_ => expr_mode.component_mode(expr)
415417
};
416418

src/librustc/middle/trans/callee.rs

+23-6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use middle::trans::inline;
3939
use middle::trans::meth;
4040
use middle::trans::monomorphize;
4141
use middle::trans::type_of;
42+
use middle::ty::ty_to_str;
4243
use middle::ty;
4344
use middle::typeck;
4445
use util::common::indenter;
@@ -94,10 +95,25 @@ pub fn trans(bcx: block, expr: @ast::expr) -> Callee {
9495
}
9596

9697
// any other expressions are closures:
97-
return closure_callee(&expr::trans_to_datum(bcx, expr));
98-
99-
fn closure_callee(db: &DatumBlock) -> Callee {
100-
return Callee {bcx: db.bcx, data: Closure(db.datum)};
98+
return datum_callee(bcx, expr);
99+
100+
fn datum_callee(bcx: block, expr: @ast::expr) -> Callee {
101+
let DatumBlock {bcx, datum} = expr::trans_to_datum(bcx, expr);
102+
match ty::get(datum.ty).sty {
103+
ty::ty_bare_fn(*) => {
104+
let llval = datum.to_appropriate_llval(bcx);
105+
return Callee {bcx: bcx, data: Fn(FnData {llfn: llval})};
106+
}
107+
ty::ty_closure(*) => {
108+
return Callee {bcx: bcx, data: Closure(datum)};
109+
}
110+
_ => {
111+
bcx.tcx().sess.span_bug(
112+
expr.span,
113+
fmt!("Type of callee is neither bare-fn nor closure: %s",
114+
bcx.ty_to_str(datum.ty)));
115+
}
116+
}
101117
}
102118

103119
fn fn_callee(bcx: block, fd: FnData) -> Callee {
@@ -129,7 +145,7 @@ pub fn trans(bcx: block, expr: @ast::expr) -> Callee {
129145
ast::def_binding(*) |
130146
ast::def_upvar(*) |
131147
ast::def_self(*) => {
132-
closure_callee(&expr::trans_to_datum(bcx, ref_expr))
148+
datum_callee(bcx, ref_expr)
133149
}
134150
ast::def_mod(*) | ast::def_foreign_mod(*) |
135151
ast::def_const(*) | ast::def_ty(*) | ast::def_prim_ty(*) |
@@ -392,7 +408,6 @@ pub fn trans_lang_call_with_type_params(bcx: block,
392408
fty);
393409
let mut llfnty = type_of::type_of(callee.bcx.ccx(),
394410
substituted);
395-
llfnty = lib::llvm::struct_tys(llfnty)[0];
396411
new_llval = PointerCast(callee.bcx, fn_data.llfn, llfnty);
397412
}
398413
_ => fail!()
@@ -715,6 +730,8 @@ pub fn trans_arg_expr(bcx: block,
715730
}
716731

717732
ast::by_copy => {
733+
debug!("by copy arg with type %s, storing to scratch",
734+
bcx.ty_to_str(arg_datum.ty));
718735
let scratch = scratch_datum(bcx, arg_datum.ty, false);
719736

720737
arg_datum.store_to_datum(bcx, arg_expr.id,

src/librustc/middle/trans/common.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1344,6 +1344,12 @@ pub fn expr_ty(bcx: block, ex: @ast::expr) -> ty::t {
13441344
node_id_type(bcx, ex.id)
13451345
}
13461346
1347+
pub fn expr_ty_adjusted(bcx: block, ex: @ast::expr) -> ty::t {
1348+
let tcx = bcx.tcx();
1349+
let t = ty::expr_ty_adjusted(tcx, ex);
1350+
monomorphize_type(bcx, t)
1351+
}
1352+
13471353
pub fn node_id_type_params(bcx: block, id: ast::node_id) -> ~[ty::t] {
13481354
let tcx = bcx.tcx();
13491355
let params = ty::node_id_to_type_params(tcx, id);

0 commit comments

Comments
 (0)