Skip to content

Commit ad35cf8

Browse files
authored
Merge pull request #37266 from brson/beta-next
[beta] backports
2 parents 64d498a + 3c4a53d commit ad35cf8

File tree

58 files changed

+139
-128
lines changed

Some content is hidden

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

58 files changed

+139
-128
lines changed

src/doc/reference.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2472,8 +2472,7 @@ The currently implemented features of the reference compiler are:
24722472
* - `default_type_parameter_fallback` - Allows type parameter defaults to
24732473
influence type inference.
24742474

2475-
* - `stmt_expr_attributes` - Allows attributes on expressions and
2476-
non-item statements.
2475+
* - `stmt_expr_attributes` - Allows attributes on expressions.
24772476

24782477
* - `type_ascription` - Allows type ascription expressions `expr: Type`.
24792478

src/libcore/any.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373

7474
use fmt;
7575
use intrinsics;
76-
use marker::Reflect;
7776

7877
///////////////////////////////////////////////////////////////////////////////
7978
// Any trait
@@ -86,7 +85,7 @@ use marker::Reflect;
8685
///
8786
/// [mod]: index.html
8887
#[stable(feature = "rust1", since = "1.0.0")]
89-
pub trait Any: Reflect + 'static {
88+
pub trait Any: 'static {
9089
/// Gets the `TypeId` of `self`.
9190
///
9291
/// # Examples
@@ -112,7 +111,7 @@ pub trait Any: Reflect + 'static {
112111
}
113112

114113
#[stable(feature = "rust1", since = "1.0.0")]
115-
impl<T: Reflect + 'static + ?Sized > Any for T {
114+
impl<T: 'static + ?Sized > Any for T {
116115
fn get_type_id(&self) -> TypeId { TypeId::of::<T>() }
117116
}
118117

@@ -366,7 +365,7 @@ impl TypeId {
366365
/// }
367366
/// ```
368367
#[stable(feature = "rust1", since = "1.0.0")]
369-
pub fn of<T: ?Sized + Reflect + 'static>() -> TypeId {
368+
pub fn of<T: ?Sized + 'static>() -> TypeId {
370369
TypeId {
371370
t: unsafe { intrinsics::type_id::<T>() },
372371
}

src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
#![feature(specialization)]
9090
#![feature(staged_api)]
9191
#![feature(unboxed_closures)]
92-
#![feature(question_mark)]
92+
#![cfg_attr(stage0, feature(question_mark))]
9393
#![feature(never_type)]
9494
#![feature(prelude_import)]
9595

src/libcore/macros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ macro_rules! debug_assert_ne {
255255
/// Helper macro for reducing boilerplate code for matching `Result` together
256256
/// with converting downstream errors.
257257
///
258+
/// Prefer using `?` syntax to `try!`. `?` is built in to the language and is
259+
/// more succinct than `try!`. It is the standard method for error propagation.
260+
///
258261
/// `try!` matches the given `Result`. In case of the `Ok` variant, the
259262
/// expression has the value of the wrapped value.
260263
///

src/libcore/marker.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,14 @@ mod impls {
587587
#[unstable(feature = "reflect_marker",
588588
reason = "requires RFC and more experience",
589589
issue = "27749")]
590+
#[rustc_deprecated(since = "1.14.0", reason = "Specialization makes parametricity impossible")]
590591
#[rustc_on_unimplemented = "`{Self}` does not implement `Any`; \
591592
ensure all type parameters are bounded by `Any`"]
592593
pub trait Reflect {}
593594

594595
#[unstable(feature = "reflect_marker",
595596
reason = "requires RFC and more experience",
596597
issue = "27749")]
598+
#[rustc_deprecated(since = "1.14.0", reason = "Specialization makes parametricity impossible")]
599+
#[allow(deprecated)]
597600
impl Reflect for .. { }

src/libgraphviz/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@
295295
#![cfg_attr(not(stage0), deny(warnings))]
296296

297297
#![feature(str_escape)]
298-
#![feature(question_mark)]
298+
#![cfg_attr(stage0, feature(question_mark))]
299299

300300
use self::LabelText::*;
301301

src/librustc/diagnostics.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,30 +1327,6 @@ let x: i32 = "I am not a number!";
13271327
// |
13281328
// type `i32` assigned to variable `x`
13291329
```
1330-
1331-
Another situation in which this occurs is when you attempt to use the `try!`
1332-
macro inside a function that does not return a `Result<T, E>`:
1333-
1334-
```compile_fail,E0308
1335-
use std::fs::File;
1336-
1337-
fn main() {
1338-
let mut f = try!(File::create("foo.txt"));
1339-
}
1340-
```
1341-
1342-
This code gives an error like this:
1343-
1344-
```text
1345-
<std macros>:5:8: 6:42 error: mismatched types:
1346-
expected `()`,
1347-
found `core::result::Result<_, _>`
1348-
(expected (),
1349-
found enum `core::result::Result`) [E0308]
1350-
```
1351-
1352-
`try!` returns a `Result<T, E>`, and so the function must. But `main()` has
1353-
`()` as its return type, hence the error.
13541330
"##,
13551331

13561332
E0309: r##"

src/librustc/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#![feature(rustc_private)]
4141
#![feature(slice_patterns)]
4242
#![feature(staged_api)]
43-
#![feature(question_mark)]
43+
#![cfg_attr(stage0, feature(question_mark))]
4444
#![cfg_attr(test, feature(test))]
4545

4646
extern crate arena;

src/librustc/ty/util.rs

Lines changed: 70 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use hir::def_id::DefId;
1414
use infer::InferCtxt;
15+
use hir::map as ast_map;
1516
use hir::pat_util;
1617
use traits::{self, Reveal};
1718
use ty::{self, Ty, AdtKind, TyCtxt, TypeAndMut, TypeFlags, TypeFoldable};
@@ -389,16 +390,77 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
389390
}
390391
}
391392

393+
// When hashing a type this ends up affecting properties like symbol names. We
394+
// want these symbol names to be calculated independent of other factors like
395+
// what architecture you're compiling *from*.
396+
//
397+
// The hashing just uses the standard `Hash` trait, but the implementations of
398+
// `Hash` for the `usize` and `isize` types are *not* architecture independent
399+
// (e.g. they has 4 or 8 bytes). As a result we want to avoid `usize` and
400+
// `isize` completely when hashing. To ensure that these don't leak in we use a
401+
// custom hasher implementation here which inflates the size of these to a `u64`
402+
// and `i64`.
403+
struct WidenUsizeHasher<H> {
404+
inner: H,
405+
}
406+
407+
impl<H> WidenUsizeHasher<H> {
408+
fn new(inner: H) -> WidenUsizeHasher<H> {
409+
WidenUsizeHasher { inner: inner }
410+
}
411+
}
412+
413+
impl<H: Hasher> Hasher for WidenUsizeHasher<H> {
414+
fn write(&mut self, bytes: &[u8]) {
415+
self.inner.write(bytes)
416+
}
417+
418+
fn finish(&self) -> u64 {
419+
self.inner.finish()
420+
}
421+
422+
fn write_u8(&mut self, i: u8) {
423+
self.inner.write_u8(i)
424+
}
425+
fn write_u16(&mut self, i: u16) {
426+
self.inner.write_u16(i)
427+
}
428+
fn write_u32(&mut self, i: u32) {
429+
self.inner.write_u32(i)
430+
}
431+
fn write_u64(&mut self, i: u64) {
432+
self.inner.write_u64(i)
433+
}
434+
fn write_usize(&mut self, i: usize) {
435+
self.inner.write_u64(i as u64)
436+
}
437+
fn write_i8(&mut self, i: i8) {
438+
self.inner.write_i8(i)
439+
}
440+
fn write_i16(&mut self, i: i16) {
441+
self.inner.write_i16(i)
442+
}
443+
fn write_i32(&mut self, i: i32) {
444+
self.inner.write_i32(i)
445+
}
446+
fn write_i64(&mut self, i: i64) {
447+
self.inner.write_i64(i)
448+
}
449+
fn write_isize(&mut self, i: isize) {
450+
self.inner.write_i64(i as i64)
451+
}
452+
}
453+
392454
pub struct TypeIdHasher<'a, 'gcx: 'a+'tcx, 'tcx: 'a, H> {
393455
tcx: TyCtxt<'a, 'gcx, 'tcx>,
394-
state: H
456+
state: WidenUsizeHasher<H>,
395457
}
396458

397459
impl<'a, 'gcx, 'tcx, H: Hasher> TypeIdHasher<'a, 'gcx, 'tcx, H> {
398460
pub fn new(tcx: TyCtxt<'a, 'gcx, 'tcx>, state: H) -> Self {
399461
TypeIdHasher {
400462
tcx: tcx,
401-
state: state
463+
state: WidenUsizeHasher::new(state),
402464
}
403465
}
404466

@@ -422,9 +484,12 @@ impl<'a, 'gcx, 'tcx, H: Hasher> TypeIdHasher<'a, 'gcx, 'tcx, H> {
422484
fn def_id(&mut self, did: DefId) {
423485
// Hash the DefPath corresponding to the DefId, which is independent
424486
// of compiler internal state.
425-
let tcx = self.tcx;
426-
let def_path = tcx.def_path(did);
427-
def_path.deterministic_hash_to(tcx, &mut self.state);
487+
let path = self.tcx.def_path(did);
488+
self.def_path(&path)
489+
}
490+
491+
pub fn def_path(&mut self, def_path: &ast_map::DefPath) {
492+
def_path.deterministic_hash_to(self.tcx, &mut self.state);
428493
}
429494
}
430495

src/librustc_back/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#![feature(rustc_private)]
3838
#![feature(staged_api)]
3939
#![feature(step_by)]
40-
#![feature(question_mark)]
40+
#![cfg_attr(stage0, feature(question_mark))]
4141
#![cfg_attr(test, feature(test, rand))]
4242

4343
extern crate syntax;

0 commit comments

Comments
 (0)