Skip to content

Commit ef25b38

Browse files
committed
---
yaml --- r: 277854 b: refs/heads/auto c: c0c08e2 h: refs/heads/master
1 parent cd51dea commit ef25b38

File tree

113 files changed

+3022
-1556
lines changed

Some content is hidden

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

113 files changed

+3022
-1556
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
88
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
99
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1010
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
11-
refs/heads/auto: 126e09e5e5f0eeb7098188126e57169c3a622563
11+
refs/heads/auto: c0c08e2d77a4dab0414b08c4e9008113bf3fee67
1212
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1313
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336
1414
refs/tags/0.2: 1754d02027f2924bed83b0160ee340c7f41d5ea1

branches/auto/mk/crates.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir
120120
log syntax serialize rustc_llvm rustc_platform_intrinsics \
121121
rustc_const_math rustc_const_eval rustc_incremental
122122
DEPS_rustc_incremental := rbml rustc serialize rustc_data_structures
123-
DEPS_rustc_save_analysis := rustc log syntax
123+
DEPS_rustc_save_analysis := rustc log syntax serialize
124124
DEPS_rustc_typeck := rustc syntax rustc_platform_intrinsics rustc_const_math \
125125
rustc_const_eval
126126

branches/auto/src/doc/book/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ enter the following commands:
412412

413413
```bash
414414
$ mkdir src
415-
$ mv main.rs src/main.rs
415+
$ mv main.rs src/main.rs # or 'move main.rs src/main.rs' on Windows
416416
$ rm main # or 'del main.exe' on Windows
417417
```
418418

branches/auto/src/doc/book/lifetimes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Lifetimes
22

3-
This guide is three of three presenting Rust’s ownership system. This is one of
4-
Rust’s most unique and compelling features, with which Rust developers should
3+
This is the last of three sections presenting Rust’s ownership system. This is one of
4+
Rust’s most distinct and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own chapter:
77

branches/auto/src/doc/book/ownership.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% Ownership
22

3-
This guide is one of three presenting Rust’s ownership system. This is one of
4-
Rust’s most unique and compelling features, with which Rust developers should
3+
This is the first of three sections presenting Rust’s ownership system. This is one of
4+
Rust’s most distinct and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own
77
chapter:

branches/auto/src/doc/book/references-and-borrowing.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
% References and Borrowing
22

3-
This guide is two of three presenting Rust’s ownership system. This is one of
4-
Rust’s most unique and compelling features, with which Rust developers should
3+
This is the second of three sections presenting Rust’s ownership system. This is one of
4+
Rust’s most distinct and compelling features, with which Rust developers should
55
become quite acquainted. Ownership is how Rust achieves its largest goal,
66
memory safety. There are a few distinct concepts, each with its own
77
chapter:
@@ -77,6 +77,32 @@ let answer = foo(&v1, &v2);
7777
// we can use v1 and v2 here!
7878
```
7979

80+
A more concrete example:
81+
82+
```rust
83+
fn main() {
84+
// Don't worry if you don't understand how `fold` works, the point here is that an immutable reference is borrowed.
85+
fn sum_vec(v: &Vec<i32>) -> i32 {
86+
return v.iter().fold(0, |a, &b| a + b);
87+
}
88+
// Borrow two vectors and and sum them.
89+
// This kind of borrowing does not allow mutation to the borrowed.
90+
fn foo(v1: &Vec<i32>, v2: &Vec<i32>) -> i32 {
91+
// do stuff with v1 and v2
92+
let s1 = sum_vec(v1);
93+
let s2 = sum_vec(v2);
94+
// return the answer
95+
s1 + s2
96+
}
97+
98+
let v1 = vec![1, 2, 3];
99+
let v2 = vec![4, 5, 6];
100+
101+
let answer = foo(&v1, &v2);
102+
println!("{}", answer);
103+
}
104+
```
105+
80106
Instead of taking `Vec<i32>`s as our arguments, we take a reference:
81107
`&Vec<i32>`. And instead of passing `v1` and `v2` directly, we pass `&v1` and
82108
`&v2`. We call the `&T` type a ‘reference’, and rather than owning the resource,

branches/auto/src/libcore/clone.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,17 @@ pub trait Clone : Sized {
7575
}
7676
}
7777

78+
// FIXME(aburka): this method is used solely by #[derive] to
79+
// assert that every component of a type implements Clone.
80+
//
81+
// This should never be called by user code.
82+
#[doc(hidden)]
83+
#[inline(always)]
84+
#[unstable(feature = "derive_clone_copy",
85+
reason = "deriving hack, should not be public",
86+
issue = "0")]
87+
pub fn assert_receiver_is_clone<T: Clone + ?Sized>(_: &T) {}
88+
7889
#[stable(feature = "rust1", since = "1.0.0")]
7990
impl<'a, T: ?Sized> Clone for &'a T {
8091
/// Returns a shallow copy of the reference.

branches/auto/src/libcore/ptr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,9 @@ impl<T: ?Sized> *mut T {
459459
/// ```
460460
/// let mut s = [1, 2, 3];
461461
/// let ptr: *mut u32 = s.as_mut_ptr();
462+
/// let first_value = unsafe { ptr.as_mut().unwrap() };
463+
/// *first_value = 4;
464+
/// println!("{:?}", s); // It'll print: "[4, 2, 3]".
462465
/// ```
463466
#[stable(feature = "ptr_as_ref", since = "1.9.0")]
464467
#[inline]

branches/auto/src/librustc/infer/error_reporting.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ impl<'tcx> TyCtxt<'tcx> {
157157
"scope of call-site for function"
158158
}
159159
region::CodeExtentData::ParameterScope { .. } => {
160-
"scope of parameters for function"
160+
"scope of function body"
161161
}
162162
region::CodeExtentData::DestructionScope(_) => {
163163
new_string = format!("destruction scope surrounding {}", tag);

branches/auto/src/librustc/session/config.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
618618
ls: bool = (false, parse_bool,
619619
"list the symbols defined by a library crate"),
620620
save_analysis: bool = (false, parse_bool,
621-
"write syntax and type analysis information in addition to normal output"),
621+
"write syntax and type analysis (in JSON format) information in addition to normal output"),
622+
save_analysis_csv: bool = (false, parse_bool,
623+
"write syntax and type analysis (in CSV format) information in addition to normal output"),
622624
print_move_fragments: bool = (false, parse_bool,
623625
"print out move-fragment data for every fn"),
624626
flowgraph_print_loans: bool = (false, parse_bool,

branches/auto/src/librustc/session/mod.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,19 @@ pub fn build_session(sopts: config::Options,
408408
registry: diagnostics::registry::Registry,
409409
cstore: Rc<for<'a> CrateStore<'a>>)
410410
-> Session {
411+
build_session_with_codemap(sopts,
412+
local_crate_source_file,
413+
registry,
414+
cstore,
415+
Rc::new(codemap::CodeMap::new()))
416+
}
417+
418+
pub fn build_session_with_codemap(sopts: config::Options,
419+
local_crate_source_file: Option<PathBuf>,
420+
registry: diagnostics::registry::Registry,
421+
cstore: Rc<for<'a> CrateStore<'a>>,
422+
codemap: Rc<codemap::CodeMap>)
423+
-> Session {
411424
// FIXME: This is not general enough to make the warning lint completely override
412425
// normal diagnostic warnings, since the warning lint can also be denied and changed
413426
// later via the source code.
@@ -419,7 +432,6 @@ pub fn build_session(sopts: config::Options,
419432
.unwrap_or(true);
420433
let treat_err_as_bug = sopts.treat_err_as_bug;
421434

422-
let codemap = Rc::new(codemap::CodeMap::new());
423435
let emitter: Box<Emitter> = match sopts.error_format {
424436
config::ErrorOutputType::HumanReadable(color_config) => {
425437
Box::new(EmitterWriter::stderr(color_config, Some(registry), codemap.clone()))

branches/auto/src/librustc_const_eval/eval.rs

Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -562,44 +562,51 @@ pub fn eval_const_expr_partial<'tcx>(tcx: &TyCtxt<'tcx>,
562562
let result = match e.node {
563563
hir::ExprUnary(hir::UnNeg, ref inner) => {
564564
// unary neg literals already got their sign during creation
565-
if let hir::ExprLit(ref lit) = inner.node {
566-
use syntax::ast::*;
567-
use syntax::ast::LitIntType::*;
568-
const I8_OVERFLOW: u64 = ::std::i8::MAX as u64 + 1;
569-
const I16_OVERFLOW: u64 = ::std::i16::MAX as u64 + 1;
570-
const I32_OVERFLOW: u64 = ::std::i32::MAX as u64 + 1;
571-
const I64_OVERFLOW: u64 = ::std::i64::MAX as u64 + 1;
572-
match (&lit.node, ety.map(|t| &t.sty)) {
573-
(&LitKind::Int(I8_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I8))) |
574-
(&LitKind::Int(I8_OVERFLOW, Signed(IntTy::I8)), _) => {
575-
return Ok(Integral(I8(::std::i8::MIN)))
576-
},
577-
(&LitKind::Int(I16_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I16))) |
578-
(&LitKind::Int(I16_OVERFLOW, Signed(IntTy::I16)), _) => {
579-
return Ok(Integral(I16(::std::i16::MIN)))
580-
},
581-
(&LitKind::Int(I32_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I32))) |
582-
(&LitKind::Int(I32_OVERFLOW, Signed(IntTy::I32)), _) => {
583-
return Ok(Integral(I32(::std::i32::MIN)))
584-
},
585-
(&LitKind::Int(I64_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I64))) |
586-
(&LitKind::Int(I64_OVERFLOW, Signed(IntTy::I64)), _) => {
587-
return Ok(Integral(I64(::std::i64::MIN)))
588-
},
589-
(&LitKind::Int(n, Unsuffixed), Some(&ty::TyInt(IntTy::Is))) |
590-
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {
591-
match tcx.sess.target.int_type {
592-
IntTy::I32 => if n == I32_OVERFLOW {
593-
return Ok(Integral(Isize(Is32(::std::i32::MIN))));
594-
},
595-
IntTy::I64 => if n == I64_OVERFLOW {
596-
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
597-
},
598-
_ => bug!(),
599-
}
600-
},
601-
_ => {},
602-
}
565+
match inner.node {
566+
hir::ExprLit(ref lit) => {
567+
use syntax::ast::*;
568+
use syntax::ast::LitIntType::*;
569+
const I8_OVERFLOW: u64 = ::std::i8::MAX as u64 + 1;
570+
const I16_OVERFLOW: u64 = ::std::i16::MAX as u64 + 1;
571+
const I32_OVERFLOW: u64 = ::std::i32::MAX as u64 + 1;
572+
const I64_OVERFLOW: u64 = ::std::i64::MAX as u64 + 1;
573+
match (&lit.node, ety.map(|t| &t.sty)) {
574+
(&LitKind::Int(I8_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I8))) |
575+
(&LitKind::Int(I8_OVERFLOW, Signed(IntTy::I8)), _) => {
576+
return Ok(Integral(I8(::std::i8::MIN)))
577+
},
578+
(&LitKind::Int(I16_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I16))) |
579+
(&LitKind::Int(I16_OVERFLOW, Signed(IntTy::I16)), _) => {
580+
return Ok(Integral(I16(::std::i16::MIN)))
581+
},
582+
(&LitKind::Int(I32_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I32))) |
583+
(&LitKind::Int(I32_OVERFLOW, Signed(IntTy::I32)), _) => {
584+
return Ok(Integral(I32(::std::i32::MIN)))
585+
},
586+
(&LitKind::Int(I64_OVERFLOW, Unsuffixed), Some(&ty::TyInt(IntTy::I64))) |
587+
(&LitKind::Int(I64_OVERFLOW, Signed(IntTy::I64)), _) => {
588+
return Ok(Integral(I64(::std::i64::MIN)))
589+
},
590+
(&LitKind::Int(n, Unsuffixed), Some(&ty::TyInt(IntTy::Is))) |
591+
(&LitKind::Int(n, Signed(IntTy::Is)), _) => {
592+
match tcx.sess.target.int_type {
593+
IntTy::I32 => if n == I32_OVERFLOW {
594+
return Ok(Integral(Isize(Is32(::std::i32::MIN))));
595+
},
596+
IntTy::I64 => if n == I64_OVERFLOW {
597+
return Ok(Integral(Isize(Is64(::std::i64::MIN))));
598+
},
599+
_ => bug!(),
600+
}
601+
},
602+
_ => {},
603+
}
604+
},
605+
hir::ExprUnary(hir::UnNeg, ref inner) => {
606+
// skip `--$expr`
607+
return eval_const_expr_partial(tcx, inner, ty_hint, fn_args);
608+
},
609+
_ => {},
603610
}
604611
match eval_const_expr_partial(tcx, &inner, ty_hint, fn_args)? {
605612
Float(f) => Float(-f),

branches/auto/src/librustc_const_math/int.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ impl ::std::ops::Shr<ConstInt> for ConstInt {
503503
I8(a) => Ok(I8(overflowing!(a.overflowing_shr(b), Op::Shr))),
504504
I16(a) => Ok(I16(overflowing!(a.overflowing_shr(b), Op::Shr))),
505505
I32(a) => Ok(I32(overflowing!(a.overflowing_shr(b), Op::Shr))),
506-
I64(a) => Ok(I64(overflowing!(a.overflowing_shr(b), Op::Shl))),
506+
I64(a) => Ok(I64(overflowing!(a.overflowing_shr(b), Op::Shr))),
507507
Isize(Is32(a)) => Ok(Isize(Is32(overflowing!(a.overflowing_shr(b), Op::Shr)))),
508508
Isize(Is64(a)) => Ok(Isize(Is64(overflowing!(a.overflowing_shr(b), Op::Shr)))),
509509
U8(a) => Ok(U8(overflowing!(a.overflowing_shr(b), Op::Shr))),

branches/auto/src/librustc_const_math/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ mod err;
4040
pub use int::*;
4141
pub use us::*;
4242
pub use is::*;
43-
pub use err::ConstMathErr;
43+
pub use err::{ConstMathErr, Op};

branches/auto/src/librustc_data_structures/bitvec.rs

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,8 @@ impl BitVector {
5252

5353
pub fn grow(&mut self, num_bits: usize) {
5454
let num_words = u64s(num_bits);
55-
let extra_words = self.data.len() - num_words;
56-
if extra_words > 0 {
57-
self.data.extend((0..extra_words).map(|_| 0));
55+
if self.data.len() < num_words {
56+
self.data.resize(num_words, 0)
5857
}
5958
}
6059

@@ -284,15 +283,27 @@ fn union_two_vecs() {
284283
#[test]
285284
fn grow() {
286285
let mut vec1 = BitVector::new(65);
287-
assert!(vec1.insert(3));
288-
assert!(!vec1.insert(3));
289-
assert!(vec1.insert(5));
290-
assert!(vec1.insert(64));
286+
for index in 0 .. 65 {
287+
assert!(vec1.insert(index));
288+
assert!(!vec1.insert(index));
289+
}
291290
vec1.grow(128);
292-
assert!(vec1.contains(3));
293-
assert!(vec1.contains(5));
294-
assert!(vec1.contains(64));
295-
assert!(!vec1.contains(126));
291+
292+
// Check if the bits set before growing are still set
293+
for index in 0 .. 65 {
294+
assert!(vec1.contains(index));
295+
}
296+
297+
// Check if the new bits are all un-set
298+
for index in 65 .. 128 {
299+
assert!(!vec1.contains(index));
300+
}
301+
302+
// Check that we can set all new bits without running out of bounds
303+
for index in 65 .. 128 {
304+
assert!(vec1.insert(index));
305+
assert!(!vec1.insert(index));
306+
}
296307
}
297308

298309
#[test]

branches/auto/src/librustc_driver/driver.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,7 @@ pub fn compile_input(sess: &Session,
141141
dep_graph));
142142

143143
// Discard MTWT tables that aren't required past lowering to HIR.
144-
if !sess.opts.debugging_opts.keep_mtwt_tables &&
145-
!sess.opts.debugging_opts.save_analysis {
144+
if !keep_mtwt_tables(sess) {
146145
syntax::ext::mtwt::clear_tables();
147146
}
148147

@@ -179,8 +178,7 @@ pub fn compile_input(sess: &Session,
179178
"early lint checks",
180179
|| lint::check_ast_crate(sess, &expanded_crate));
181180

182-
let opt_crate = if sess.opts.debugging_opts.keep_ast ||
183-
sess.opts.debugging_opts.save_analysis {
181+
let opt_crate = if keep_ast(sess) {
184182
Some(&expanded_crate)
185183
} else {
186184
drop(expanded_crate);
@@ -249,6 +247,18 @@ pub fn compile_input(sess: &Session,
249247
Ok(())
250248
}
251249

250+
fn keep_mtwt_tables(sess: &Session) -> bool {
251+
sess.opts.debugging_opts.keep_mtwt_tables ||
252+
sess.opts.debugging_opts.save_analysis ||
253+
sess.opts.debugging_opts.save_analysis_csv
254+
}
255+
256+
fn keep_ast(sess: &Session) -> bool {
257+
sess.opts.debugging_opts.keep_ast ||
258+
sess.opts.debugging_opts.save_analysis ||
259+
sess.opts.debugging_opts.save_analysis_csv
260+
}
261+
252262
/// The name used for source code that doesn't originate in a file
253263
/// (e.g. source from stdin or a string)
254264
pub fn anon_src() -> String {
@@ -528,19 +538,13 @@ pub fn phase_2_configure_and_expand(sess: &Session,
528538
middle::recursion_limit::update_recursion_limit(sess, &krate);
529539
});
530540

531-
time(time_passes, "gated macro checking", || {
532-
sess.track_errors(|| {
533-
let features =
534-
syntax::feature_gate::check_crate_macros(sess.codemap(),
535-
&sess.parse_sess.span_diagnostic,
536-
&krate);
537-
538-
// these need to be set "early" so that expansion sees `quote` if enabled.
539-
*sess.features.borrow_mut() = features;
540-
})
541+
// these need to be set "early" so that expansion sees `quote` if enabled.
542+
sess.track_errors(|| {
543+
*sess.features.borrow_mut() =
544+
syntax::feature_gate::get_features(&sess.parse_sess.span_diagnostic,
545+
&krate);
541546
})?;
542547

543-
544548
krate = time(time_passes, "crate injection", || {
545549
syntax::std_inject::maybe_inject_crates_ref(krate, sess.opts.alt_std_name.clone())
546550
});

0 commit comments

Comments
 (0)