Skip to content

Commit d9bc0a3

Browse files
committed
---
yaml --- r: 131034 b: refs/heads/try c: 7ab58f6 h: refs/heads/master v: v3
1 parent cca9113 commit d9bc0a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+2599
-2502
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 9c68679f2ebd5b165694e9346e4ad96a3e32aceb
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 6faa4f33a42de32579e02a8d030db920d360e2b5
5-
refs/heads/try: 1ee099da36f6ac647747806558e555c5fe8dcd12
5+
refs/heads/try: 7ab58f67d1014c07859cb23eabacc2e23c2765f0
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/doc/rust.md

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,34 +3564,36 @@ let (a, b) = p;
35643564
assert!(b != "world");
35653565
~~~~
35663566

3567-
### Vector types
3567+
### Vector, Array, and Slice types
35683568

3569-
The vector type constructor represents a homogeneous array of values of a given type.
3570-
A vector has a fixed size.
3571-
(Operations like `vec.push` operate solely on owned vectors.)
3572-
A vector type can be annotated with a _definite_ size, such as `[int, ..10]`.
3573-
Such a definite-sized vector type is a first-class type, since its size is known statically.
3574-
A vector without such a size is said to be of _indefinite_ size,
3575-
and is therefore not a _first-class_ type.
3576-
An indefinite-size vector can only be instantiated through a pointer type,
3577-
such as `&[T]` or `Vec<T>`.
3578-
The kind of a vector type depends on the kind of its element type,
3579-
as with other simple structural types.
3569+
Rust has three different types for a list of items:
35803570

3581-
Expressions producing vectors of definite size cannot be evaluated in a
3582-
context expecting a vector of indefinite size; one must copy the
3583-
definite-sized vector contents into a distinct vector of indefinite size.
3571+
* `Vec<T>`, a 'vector'
3572+
* `[T ..N]`, an 'array'
3573+
* `&[T]`, a 'slice'.
35843574

3585-
An example of a vector type and its use:
3575+
A vector is a heap-allocated list of `T`. A vector has ownership over the data
3576+
inside of it. It is also able to grow and change in size. It's important to note
3577+
that `Vec<T>` is a library type, it's not actually part of the core language.
35863578

3587-
~~~~
3588-
let v: &[int] = &[7, 5, 3];
3589-
let i: int = v[2];
3590-
assert!(i == 3);
3591-
~~~~
3579+
An array has a fixed size, and can be allocated on either the stack or the heap.
3580+
3581+
A slice is a 'view' into a vector or array. It doesn't own the data it points
3582+
to, it borrows it.
3583+
3584+
An example of each kind:
3585+
3586+
```{rust}
3587+
let vec: Vec<int> = vec![1, 2, 3];
3588+
let arr: [int, ..3] = [1, 2, 3];
3589+
let s: &[int] = vec.as_slice();
3590+
```
3591+
3592+
As you can see, the `vec!` macro allows you to create a `Vec<T>` easily. The
3593+
`vec!` macro is also part of the standard library, rather than the language.
35923594

3593-
All in-bounds elements of a vector are always initialized,
3594-
and access to a vector is always bounds-checked.
3595+
All in-bounds elements of vectors, arrays, and slices are always initialized,
3596+
and access to a vector, array, or slice is always bounds-checked.
35953597

35963598
### Structure types
35973599

branches/try/src/libcollections/vec.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,19 @@ pub struct MoveItems<T> {
16181618
iter: Items<'static, T>
16191619
}
16201620

1621+
impl<T> MoveItems<T> {
1622+
#[inline]
1623+
/// Drops all items that have not yet been moved and returns the empty vector.
1624+
pub fn unwrap(mut self) -> Vec<T> {
1625+
unsafe {
1626+
for _x in self { }
1627+
let MoveItems { allocation, cap, iter: _iter } = self;
1628+
mem::forget(self);
1629+
Vec { ptr: allocation, cap: cap, len: 0 }
1630+
}
1631+
}
1632+
}
1633+
16211634
impl<T> Iterator<T> for MoveItems<T> {
16221635
#[inline]
16231636
fn next<'a>(&'a mut self) -> Option<T> {
@@ -2016,6 +2029,18 @@ mod tests {
20162029
assert_eq!(vec.swap_remove(0), None);
20172030
}
20182031

2032+
#[test]
2033+
fn test_move_iter_unwrap() {
2034+
let mut vec: Vec<uint> = Vec::with_capacity(7);
2035+
vec.push(1);
2036+
vec.push(2);
2037+
let ptr = vec.as_ptr();
2038+
vec = vec.move_iter().unwrap();
2039+
assert_eq!(vec.as_ptr(), ptr);
2040+
assert_eq!(vec.capacity(), 7);
2041+
assert_eq!(vec.len(), 0);
2042+
}
2043+
20192044
#[bench]
20202045
fn bench_new(b: &mut Bencher) {
20212046
b.iter(|| {

branches/try/src/libnative/io/net.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -959,7 +959,7 @@ pub fn read<T>(fd: sock_t,
959959
// wait for the socket to become readable again.
960960
let _guard = lock();
961961
match retry(|| read(deadline.is_some())) {
962-
-1 if util::wouldblock() => { assert!(deadline.is_some()); }
962+
-1 if util::wouldblock() => {}
963963
-1 => return Err(os::last_error()),
964964
n => { ret = n; break }
965965
}

branches/try/src/librustc/back/link.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use util::ppaux;
2828
use util::sha2::{Digest, Sha256};
2929

3030
use std::char;
31-
use std::collections::HashSet;
3231
use std::io::{fs, TempDir, Command};
3332
use std::io;
3433
use std::mem;
@@ -570,10 +569,7 @@ fn link_binary_output(sess: &Session,
570569
fn archive_search_paths(sess: &Session) -> Vec<Path> {
571570
let mut rustpath = filesearch::rust_path();
572571
rustpath.push(sess.target_filesearch().get_lib_path());
573-
// FIXME: Addl lib search paths are an unordered HashSet?
574-
// Shouldn't this search be done in some order?
575-
let addl_lib_paths: HashSet<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
576-
let mut search: Vec<Path> = addl_lib_paths.move_iter().collect();
572+
let mut search: Vec<Path> = sess.opts.addl_lib_search_paths.borrow().clone();
577573
search.push_all(rustpath.as_slice());
578574
return search;
579575
}
@@ -1019,6 +1015,12 @@ fn link_args(cmd: &mut Command,
10191015

10201016
// Mark all dynamic libraries and executables as compatible with ASLR
10211017
cmd.arg("-Wl,--dynamicbase");
1018+
1019+
// Mark all dynamic libraries and executables as compatible with the larger 4GiB address
1020+
// space available to x86 Windows binaries on x86_64.
1021+
if sess.targ_cfg.arch == abi::X86 {
1022+
cmd.arg("-Wl,--large-address-aware");
1023+
}
10221024
}
10231025

10241026
if sess.targ_cfg.os == abi::OsAndroid {

branches/try/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,5 +169,6 @@ register_diagnostics!(
169169
E0157,
170170
E0158,
171171
E0159,
172-
E0160
172+
E0160,
173+
E0161
173174
)

branches/try/src/librustc/driver/config.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use syntax::diagnostic::{ColorConfig, Auto, Always, Never};
3030
use syntax::parse;
3131
use syntax::parse::token::InternedString;
3232

33-
use std::collections::{HashSet, HashMap};
33+
use std::collections::HashMap;
3434
use getopts::{optopt, optmulti, optflag, optflagopt};
3535
use getopts;
3636
use std::cell::{RefCell};
@@ -76,7 +76,7 @@ pub struct Options {
7676
// This was mutable for rustpkg, which updates search paths based on the
7777
// parsed code. It remains mutable in case its replacements wants to use
7878
// this.
79-
pub addl_lib_search_paths: RefCell<HashSet<Path>>,
79+
pub addl_lib_search_paths: RefCell<Vec<Path>>,
8080
pub maybe_sysroot: Option<Path>,
8181
pub target_triple: String,
8282
// User-specified cfg meta items. The compiler itself will add additional
@@ -113,7 +113,7 @@ pub fn basic_options() -> Options {
113113
lint_opts: Vec::new(),
114114
describe_lints: false,
115115
output_types: Vec::new(),
116-
addl_lib_search_paths: RefCell::new(HashSet::new()),
116+
addl_lib_search_paths: RefCell::new(Vec::new()),
117117
maybe_sysroot: None,
118118
target_triple: driver::host_triple().to_string(),
119119
cfg: Vec::new(),

branches/try/src/librustc/driver/driver.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use serialize::{json, Encodable};
3232

3333
use std::io;
3434
use std::io::fs;
35+
use arena::TypedArena;
3536
use syntax::ast;
3637
use syntax::attr;
3738
use syntax::attr::{AttrMetaMethods};
@@ -86,8 +87,9 @@ pub fn compile_input(sess: Session,
8687

8788
if stop_after_phase_2(&sess) { return; }
8889

90+
let type_arena = TypedArena::new();
8991
let analysis = phase_3_run_analysis_passes(sess, &expanded_crate,
90-
ast_map, id);
92+
ast_map, &type_arena, id);
9193
phase_save_analysis(&analysis.ty_cx.sess, &expanded_crate, &analysis, outdir);
9294
if stop_after_phase_3(&analysis.ty_cx.sess) { return; }
9395
let (tcx, trans) = phase_4_translate_to_llvm(expanded_crate, analysis);
@@ -299,11 +301,11 @@ pub fn phase_2_configure_and_expand(sess: &Session,
299301
Some((krate, map))
300302
}
301303

302-
pub struct CrateAnalysis {
304+
pub struct CrateAnalysis<'tcx> {
303305
pub exp_map2: middle::resolve::ExportMap2,
304306
pub exported_items: middle::privacy::ExportedItems,
305307
pub public_items: middle::privacy::PublicItems,
306-
pub ty_cx: ty::ctxt,
308+
pub ty_cx: ty::ctxt<'tcx>,
307309
pub reachable: NodeSet,
308310
pub name: String,
309311
}
@@ -312,10 +314,11 @@ pub struct CrateAnalysis {
312314
/// Run the resolution, typechecking, region checking and other
313315
/// miscellaneous analysis passes on the crate. Return various
314316
/// structures carrying the results of the analysis.
315-
pub fn phase_3_run_analysis_passes(sess: Session,
316-
krate: &ast::Crate,
317-
ast_map: syntax::ast_map::Map,
318-
name: String) -> CrateAnalysis {
317+
pub fn phase_3_run_analysis_passes<'tcx>(sess: Session,
318+
krate: &ast::Crate,
319+
ast_map: syntax::ast_map::Map,
320+
type_arena: &'tcx TypedArena<ty::t_box_>,
321+
name: String) -> CrateAnalysis<'tcx> {
319322
let time_passes = sess.time_passes();
320323

321324
time(time_passes, "external crate/lib resolution", (), |_|
@@ -362,6 +365,7 @@ pub fn phase_3_run_analysis_passes(sess: Session,
362365
stability::Index::build(krate));
363366

364367
let ty_cx = ty::mk_ctxt(sess,
368+
type_arena,
365369
def_map,
366370
named_region_map,
367371
ast_map,
@@ -404,6 +408,9 @@ pub fn phase_3_run_analysis_passes(sess: Session,
404408
time(time_passes, "borrow checking", (), |_|
405409
middle::borrowck::check_crate(&ty_cx, krate));
406410

411+
time(time_passes, "rvalue checking", (), |_|
412+
middle::check_rvalues::check_crate(&ty_cx, krate));
413+
407414
time(time_passes, "kind checking", (), |_|
408415
kind::check_crate(&ty_cx, krate));
409416

branches/try/src/librustc/driver/pretty.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use graphviz as dot;
3333
use std::io::{mod, MemReader};
3434
use std::from_str::FromStr;
3535
use std::option;
36-
36+
use arena::TypedArena;
3737

3838
#[deriving(PartialEq, Show)]
3939
pub enum PpSourceMode {
@@ -114,7 +114,9 @@ impl PpSourceMode {
114114
}
115115
PpmTyped => {
116116
let ast_map = ast_map.expect("--pretty=typed missing ast_map");
117-
let analysis = driver::phase_3_run_analysis_passes(sess, krate, ast_map, id);
117+
let type_arena = TypedArena::new();
118+
let analysis = driver::phase_3_run_analysis_passes(sess, krate, ast_map,
119+
&type_arena, id);
118120
let annotation = TypedAnnotation { analysis: analysis };
119121
f(&annotation, payload)
120122
}
@@ -260,25 +262,25 @@ impl pprust::PpAnn for HygieneAnnotation {
260262
}
261263

262264

263-
struct TypedAnnotation {
264-
analysis: CrateAnalysis,
265+
struct TypedAnnotation<'tcx> {
266+
analysis: CrateAnalysis<'tcx>,
265267
}
266268

267-
impl PrinterSupport for TypedAnnotation {
269+
impl<'tcx> PrinterSupport for TypedAnnotation<'tcx> {
268270
fn pp_ann<'a>(&'a self) -> &'a pprust::PpAnn { self as &pprust::PpAnn }
269271
}
270272

271-
impl SessionCarrier for TypedAnnotation {
273+
impl<'tcx> SessionCarrier for TypedAnnotation<'tcx> {
272274
fn sess<'a>(&'a self) -> &'a Session { &self.analysis.ty_cx.sess }
273275
}
274276

275-
impl AstMapCarrier for TypedAnnotation {
277+
impl<'tcx> AstMapCarrier for TypedAnnotation<'tcx> {
276278
fn ast_map<'a>(&'a self) -> Option<&'a ast_map::Map> {
277279
Some(&self.analysis.ty_cx.map)
278280
}
279281
}
280282

281-
impl pprust::PpAnn for TypedAnnotation {
283+
impl<'tcx> pprust::PpAnn for TypedAnnotation<'tcx> {
282284
fn pre(&self,
283285
s: &mut pprust::State,
284286
node: pprust::AnnNode) -> io::IoResult<()> {
@@ -531,8 +533,9 @@ pub fn pretty_print_input(sess: Session,
531533
match code {
532534
Some(code) => {
533535
let variants = gather_flowgraph_variants(&sess);
536+
let type_arena = TypedArena::new();
534537
let analysis = driver::phase_3_run_analysis_passes(sess, &krate,
535-
ast_map, id);
538+
ast_map, &type_arena, id);
536539
print_flowgraph(variants, analysis, code, out)
537540
}
538541
None => {

branches/try/src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ pub mod middle {
8080
pub mod check_const;
8181
pub mod check_loop;
8282
pub mod check_match;
83+
pub mod check_rvalues;
8384
pub mod check_static;
8485
pub mod const_eval;
8586
pub mod dataflow;

branches/try/src/librustc/lint/builtin.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ impl LintPass for TypeLimits {
340340
declare_lint!(CTYPES, Warn,
341341
"proper use of libc types in foreign modules")
342342

343-
struct CTypesVisitor<'a> {
344-
cx: &'a Context<'a>
343+
struct CTypesVisitor<'a, 'tcx: 'a> {
344+
cx: &'a Context<'a, 'tcx>
345345
}
346346

347-
impl<'a> CTypesVisitor<'a> {
347+
impl<'a, 'tcx> CTypesVisitor<'a, 'tcx> {
348348
fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
349349
match self.cx.tcx.def_map.borrow().get_copy(&path_id) {
350350
def::DefPrimTy(ast::TyInt(ast::TyI)) => {
@@ -375,7 +375,7 @@ impl<'a> CTypesVisitor<'a> {
375375
}
376376
}
377377

378-
impl<'a> Visitor<()> for CTypesVisitor<'a> {
378+
impl<'a, 'tcx> Visitor<()> for CTypesVisitor<'a, 'tcx> {
379379
fn visit_ty(&mut self, ty: &ast::Ty, _: ()) {
380380
match ty.node {
381381
ast::TyPath(_, _, id) => self.check_def(ty.span, ty.id, id),
@@ -505,11 +505,11 @@ impl LintPass for HeapMemory {
505505
declare_lint!(RAW_POINTER_DERIVING, Warn,
506506
"uses of #[deriving] with raw pointers are rarely correct")
507507

508-
struct RawPtrDerivingVisitor<'a> {
509-
cx: &'a Context<'a>
508+
struct RawPtrDerivingVisitor<'a, 'tcx: 'a> {
509+
cx: &'a Context<'a, 'tcx>
510510
}
511511

512-
impl<'a> Visitor<()> for RawPtrDerivingVisitor<'a> {
512+
impl<'a, 'tcx> Visitor<()> for RawPtrDerivingVisitor<'a, 'tcx> {
513513
fn visit_ty(&mut self, ty: &ast::Ty, _: ()) {
514514
static MSG: &'static str = "use of `#[deriving]` with a raw pointer";
515515
match ty.node {

0 commit comments

Comments
 (0)