Skip to content

Commit 3dee1dd

Browse files
committed
---
yaml --- r: 218323 b: refs/heads/tmp c: 9f26f14 h: refs/heads/master i: 218321: 15dfc99 218319: d00df14 v: v3
1 parent 19778e4 commit 3dee1dd

File tree

20 files changed

+170
-78
lines changed

20 files changed

+170
-78
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
2525
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
2626
refs/heads/beta: ebf0c83cb9c6508e9564cb58337df2ad52b56430
2727
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28-
refs/heads/tmp: 9bc8e6d1472a57441afe3592078838d2bc767996
28+
refs/heads/tmp: 9f26f14dc9b1e152a79e0999556f09f4ca952658
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: d0fdfbfb0d34f196f52b9d15215723c4785c4afa
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828

branches/tmp/src/compiletest/runtest.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1702,8 +1702,11 @@ fn run_codegen_test(config: &Config, props: &TestProps, testfile: &Path) {
17021702
}
17031703

17041704
fn charset() -> &'static str {
1705-
if cfg!(any(target_os = "bitrig", target_os = "freebsd")) {
1705+
// FreeBSD 10.1 defaults to GDB 6.1.1 which doesn't support "auto" charset
1706+
if cfg!(target_os = "bitrig") {
17061707
"auto"
1708+
} else if cfg!(target_os = "freebsd") {
1709+
"ISO-8859-1"
17071710
} else {
17081711
"UTF-8"
17091712
}

branches/tmp/src/doc/complement-design-faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Second, it makes cost explicit. In general, the only safe way to have a
9999
non-exhaustive match would be to panic the thread if nothing is matched, though
100100
it could fall through if the type of the `match` expression is `()`. This sort
101101
of hidden cost and special casing is against the language's philosophy. It's
102-
easy to ignore certain cases by using the `_` wildcard:
102+
easy to ignore all unspecified cases by using the `_` wildcard:
103103

104104
```rust,ignore
105105
match val.do_something() {

branches/tmp/src/doc/trpl/guessing-game.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,10 +360,12 @@ rand="0.3.0"
360360
The `[dependencies]` section of `Cargo.toml` is like the `[package]` section:
361361
everything that follows it is part of it, until the next section starts.
362362
Cargo uses the dependencies section to know what dependencies on external
363-
crates you have, and what versions you require. In this case, we’ve used version `0.3.0`.
363+
crates you have, and what versions you require. In this case, we’ve specified version `0.3.0`,
364+
which Cargo understands to be any release that’s compatible with this specific version.
364365
Cargo understands [Semantic Versioning][semver], which is a standard for writing version
365-
numbers. If we wanted to use the latest version we could use `*` or we could use a range
366-
of versions. [Cargo’s documentation][cargodoc] contains more details.
366+
numbers. If we wanted to use only `0.3.0` exactly, we could use `=0.3.0`. If we
367+
wanted to use the latest version we could use `*`; We could use a range of
368+
versions. [Cargo’s documentation][cargodoc] contains more details.
367369

368370
[semver]: http://semver.org
369371
[cargodoc]: http://doc.crates.io/crates-io.html

branches/tmp/src/libcollections/vec.rs

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ use core::cmp::Ordering;
6767
use core::fmt;
6868
use core::hash::{self, Hash};
6969
use core::intrinsics::{arith_offset, assume};
70-
use core::iter::{repeat, FromIterator};
70+
use core::iter::FromIterator;
7171
use core::marker::PhantomData;
7272
use core::mem;
7373
use core::ops::{Index, IndexMut, Deref};
@@ -1106,12 +1106,35 @@ impl<T: Clone> Vec<T> {
11061106
let len = self.len();
11071107

11081108
if new_len > len {
1109-
self.extend(repeat(value).take(new_len - len));
1109+
self.extend_with_element(new_len - len, value);
11101110
} else {
11111111
self.truncate(new_len);
11121112
}
11131113
}
11141114

1115+
/// Extend the vector by `n` additional clones of `value`.
1116+
fn extend_with_element(&mut self, n: usize, value: T) {
1117+
self.reserve(n);
1118+
1119+
unsafe {
1120+
let len = self.len();
1121+
let mut ptr = self.as_mut_ptr().offset(len as isize);
1122+
// Write all elements except the last one
1123+
for i in 1..n {
1124+
ptr::write(ptr, value.clone());
1125+
ptr = ptr.offset(1);
1126+
// Increment the length in every step in case clone() panics
1127+
self.set_len(len + i);
1128+
}
1129+
1130+
if n > 0 {
1131+
// We can write the last element directly without cloning needlessly
1132+
ptr::write(ptr, value);
1133+
self.set_len(len + n);
1134+
}
1135+
}
1136+
}
1137+
11151138
/// Appends all elements in a slice to the `Vec`.
11161139
///
11171140
/// Iterates over the slice `other`, clones each element, and then appends
@@ -1294,25 +1317,9 @@ unsafe fn dealloc<T>(ptr: *mut T, len: usize) {
12941317
#[doc(hidden)]
12951318
#[stable(feature = "rust1", since = "1.0.0")]
12961319
pub fn from_elem<T: Clone>(elem: T, n: usize) -> Vec<T> {
1297-
unsafe {
1298-
let mut v = Vec::with_capacity(n);
1299-
let mut ptr = v.as_mut_ptr();
1300-
1301-
// Write all elements except the last one
1302-
for i in 1..n {
1303-
ptr::write(ptr, Clone::clone(&elem));
1304-
ptr = ptr.offset(1);
1305-
v.set_len(i); // Increment the length in every step in case Clone::clone() panics
1306-
}
1307-
1308-
if n > 0 {
1309-
// We can write the last element directly without cloning needlessly
1310-
ptr::write(ptr, elem);
1311-
v.set_len(n);
1312-
}
1313-
1314-
v
1315-
}
1320+
let mut v = Vec::with_capacity(n);
1321+
v.extend_with_element(n, elem);
1322+
v
13161323
}
13171324

13181325
////////////////////////////////////////////////////////////////////////////////

branches/tmp/src/libcore/fmt/mod.rs

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ impl<'a> Display for Arguments<'a> {
273273
///
274274
/// Generally speaking, you should just `derive` a `Debug` implementation.
275275
///
276+
/// When used with the alternate format specifier `#?`, the output is pretty-printed.
277+
///
276278
/// For more information on formatters, see [the module-level documentation][module].
277279
///
278280
/// [module]: ../index.html
@@ -314,13 +316,42 @@ impl<'a> Display for Arguments<'a> {
314316
/// println!("The origin is: {:?}", origin);
315317
/// ```
316318
///
319+
/// This outputs:
320+
///
321+
/// ```text
322+
/// The origin is: Point { x: 0, y: 0 }
323+
/// ```
324+
///
317325
/// There are a number of `debug_*` methods on `Formatter` to help you with manual
318326
/// implementations, such as [`debug_struct`][debug_struct].
319327
///
320328
/// `Debug` implementations using either `derive` or the debug builder API
321329
/// on `Formatter` support pretty printing using the alternate flag: `{:#?}`.
322330
///
323331
/// [debug_struct]: ../std/fmt/struct.Formatter.html#method.debug_struct
332+
///
333+
/// Pretty printing with `#?`:
334+
///
335+
/// ```
336+
/// #[derive(Debug)]
337+
/// struct Point {
338+
/// x: i32,
339+
/// y: i32,
340+
/// }
341+
///
342+
/// let origin = Point { x: 0, y: 0 };
343+
///
344+
/// println!("The origin is: {:#?}", origin);
345+
/// ```
346+
///
347+
/// This outputs:
348+
///
349+
/// ```text
350+
/// The origin is: Point {
351+
/// x: 0,
352+
/// y: 0
353+
/// }
354+
/// ```
324355
#[stable(feature = "rust1", since = "1.0.0")]
325356
#[rustc_on_unimplemented = "`{Self}` cannot be formatted using `:?`; if it is \
326357
defined in your crate, add `#[derive(Debug)]` or \
@@ -379,6 +410,8 @@ pub trait Display {
379410
///
380411
/// The `Octal` trait should format its output as a number in base-8.
381412
///
413+
/// The alternate flag, `#`, adds a `0o` in front of the output.
414+
///
382415
/// For more information on formatters, see [the module-level documentation][module].
383416
///
384417
/// [module]: ../index.html
@@ -391,6 +424,7 @@ pub trait Display {
391424
/// let x = 42; // 42 is '52' in octal
392425
///
393426
/// assert_eq!(format!("{:o}", x), "52");
427+
/// assert_eq!(format!("{:#o}", x), "0o52");
394428
/// ```
395429
///
396430
/// Implementing `Octal` on a type:
@@ -423,6 +457,8 @@ pub trait Octal {
423457
///
424458
/// The `Binary` trait should format its output as a number in binary.
425459
///
460+
/// The alternate flag, `#`, adds a `0b` in front of the output.
461+
///
426462
/// For more information on formatters, see [the module-level documentation][module].
427463
///
428464
/// [module]: ../index.html
@@ -435,6 +471,7 @@ pub trait Octal {
435471
/// let x = 42; // 42 is '101010' in binary
436472
///
437473
/// assert_eq!(format!("{:b}", x), "101010");
474+
/// assert_eq!(format!("{:#b}", x), "0b101010");
438475
/// ```
439476
///
440477
/// Implementing `Binary` on a type:
@@ -468,6 +505,8 @@ pub trait Binary {
468505
/// The `LowerHex` trait should format its output as a number in hexidecimal, with `a` through `f`
469506
/// in lower case.
470507
///
508+
/// The alternate flag, `#`, adds a `0x` in front of the output.
509+
///
471510
/// For more information on formatters, see [the module-level documentation][module].
472511
///
473512
/// [module]: ../index.html
@@ -480,6 +519,7 @@ pub trait Binary {
480519
/// let x = 42; // 42 is '2a' in hex
481520
///
482521
/// assert_eq!(format!("{:x}", x), "2a");
522+
/// assert_eq!(format!("{:#x}", x), "0x2a");
483523
/// ```
484524
///
485525
/// Implementing `LowerHex` on a type:
@@ -513,6 +553,8 @@ pub trait LowerHex {
513553
/// The `UpperHex` trait should format its output as a number in hexidecimal, with `A` through `F`
514554
/// in upper case.
515555
///
556+
/// The alternate flag, `#`, adds a `0x` in front of the output.
557+
///
516558
/// For more information on formatters, see [the module-level documentation][module].
517559
///
518560
/// [module]: ../index.html
@@ -525,6 +567,7 @@ pub trait LowerHex {
525567
/// let x = 42; // 42 is '2A' in hex
526568
///
527569
/// assert_eq!(format!("{:X}", x), "2A");
570+
/// assert_eq!(format!("{:#X}", x), "0x2A");
528571
/// ```
529572
///
530573
/// Implementing `UpperHex` on a type:

branches/tmp/src/libcore/slice.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,10 +1368,14 @@ pub fn mut_ref_slice<'a, A>(s: &'a mut A) -> &'a mut [A] {
13681368
///
13691369
/// The `len` argument is the number of **elements**, not the number of bytes.
13701370
///
1371+
/// # Unsafety
1372+
///
13711373
/// This function is unsafe as there is no guarantee that the given pointer is
13721374
/// valid for `len` elements, nor whether the lifetime inferred is a suitable
13731375
/// lifetime for the returned slice.
13741376
///
1377+
/// `p` must be non-null, even for zero-length slices.
1378+
///
13751379
/// # Caveat
13761380
///
13771381
/// The lifetime for the returned slice is inferred from its usage. To

branches/tmp/src/librustc/diagnostics.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1237,5 +1237,6 @@ register_diagnostics! {
12371237
E0314, // closure outlives stack frame
12381238
E0315, // cannot invoke closure outside of its lifetime
12391239
E0316, // nested quantification of lifetimes
1240-
E0370 // discriminant overflow
1240+
E0370, // discriminant overflow
1241+
E0400 // overloaded derefs are not allowed in constants
12411242
}

branches/tmp/src/librustc/middle/cfg/construct.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
332332
}
333333

334334
ast::ExprIndex(ref l, ref r) |
335-
ast::ExprBinary(_, ref l, ref r) if self.is_method_call(expr) => {
335+
ast::ExprBinary(_, ref l, ref r) if self.tcx.is_method_call(expr.id) => {
336336
self.call(expr, pred, &**l, Some(&**r).into_iter())
337337
}
338338

@@ -342,7 +342,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
342342
self.straightline(expr, pred, fields)
343343
}
344344

345-
ast::ExprUnary(_, ref e) if self.is_method_call(expr) => {
345+
ast::ExprUnary(_, ref e) if self.tcx.is_method_call(expr.id) => {
346346
self.call(expr, pred, &**e, None::<ast::Expr>.iter())
347347
}
348348

@@ -631,9 +631,4 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> {
631631
}
632632
}
633633
}
634-
635-
fn is_method_call(&self, expr: &ast::Expr) -> bool {
636-
let method_call = ty::MethodCall::expr(expr.id);
637-
self.tcx.tables.borrow().method_map.contains_key(&method_call)
638-
}
639634
}

branches/tmp/src/librustc/middle/check_const.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for CheckCrateVisitor<'a, 'tcx> {
405405

406406
let node_ty = self.tcx.node_id_to_type(ex.id);
407407
check_expr(self, ex, node_ty);
408+
check_adjustments(self, ex);
408409

409410
// Special-case some expressions to avoid certain flags bubbling up.
410411
match ex.node {
@@ -777,6 +778,25 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>,
777778
}
778779
}
779780

781+
/// Check the adjustments of an expression
782+
fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &ast::Expr) {
783+
match v.tcx.tables.borrow().adjustments.get(&e.id) {
784+
None | Some(&ty::AdjustReifyFnPointer) | Some(&ty::AdjustUnsafeFnPointer) => {}
785+
Some(&ty::AdjustDerefRef(ty::AutoDerefRef { autoderefs, .. })) => {
786+
if (0..autoderefs as u32).any(|autoderef| {
787+
v.tcx.is_overloaded_autoderef(e.id, autoderef)
788+
}) {
789+
v.add_qualif(ConstQualif::NOT_CONST);
790+
if v.mode != Mode::Var {
791+
span_err!(v.tcx.sess, e.span, E0400,
792+
"user-defined dereference operators are not allowed in {}s",
793+
v.msg());
794+
}
795+
}
796+
}
797+
}
798+
}
799+
780800
pub fn check_crate(tcx: &ty::ctxt) {
781801
visit::walk_crate(&mut CheckCrateVisitor {
782802
tcx: tcx,

branches/tmp/src/librustc/middle/ty.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6631,6 +6631,11 @@ impl<'tcx> ctxt<'tcx> {
66316631
self.tables.borrow().method_map.contains_key(&MethodCall::expr(expr_id))
66326632
}
66336633

6634+
pub fn is_overloaded_autoderef(&self, expr_id: ast::NodeId, autoderefs: u32) -> bool {
6635+
self.tables.borrow().method_map.contains_key(&MethodCall::autoderef(expr_id,
6636+
autoderefs))
6637+
}
6638+
66346639
pub fn upvar_capture(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarCapture> {
66356640
Some(self.tables.borrow().upvar_capture_map.get(&upvar_id).unwrap().clone())
66366641
}

branches/tmp/src/librustc_driver/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,6 @@ pub fn commit_date_str() -> Option<&'static str> {
479479
option_env!("CFG_VER_DATE")
480480
}
481481

482-
/// Returns a stage string, such as "stage0".
483-
pub fn stage_str() -> Option<&'static str> {
484-
if cfg!(stage0) {
485-
Some("stage0")
486-
} else if cfg!(stage1) {
487-
Some("stage1")
488-
} else {
489-
None
490-
}
491-
}
492-
493482
/// Prints version information
494483
pub fn version(binary: &str, matches: &getopts::Matches) {
495484
let verbose = matches.opt_present("verbose");
@@ -502,9 +491,6 @@ pub fn version(binary: &str, matches: &getopts::Matches) {
502491
println!("commit-date: {}", unw(commit_date_str()));
503492
println!("host: {}", config::host_triple());
504493
println!("release: {}", unw(release_str()));
505-
if let Some(stage) = stage_str() {
506-
println!("stage: {}", stage);
507-
}
508494
}
509495
}
510496

branches/tmp/src/librustc_resolve/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,11 +1844,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18441844
visit::walk_ty_param_bounds_helper(this, bounds);
18451845

18461846
for trait_item in trait_items {
1847-
// Create a new rib for the trait_item-specific type
1848-
// parameters.
1849-
//
1850-
// FIXME #4951: Do we need a node ID here?
1851-
18521847
match trait_item.node {
18531848
ast::ConstTraitItem(_, ref default) => {
18541849
// Only impose the restrictions of

0 commit comments

Comments
 (0)