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

+1-2
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

+3-4
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

+1-1
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

+3
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

+3
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

+1-1
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

-24
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

+1-1
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

+70-5
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

+1-1
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;

src/librustc_borrowck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#![feature(staged_api)]
2727
#![feature(associated_consts)]
2828
#![feature(nonzero)]
29-
#![feature(question_mark)]
29+
#![cfg_attr(stage0, feature(question_mark))]
3030
#[macro_use] extern crate log;
3131
#[macro_use] extern crate syntax;
3232
extern crate syntax_pos;

src/librustc_const_eval/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#![feature(staged_api)]
2828
#![feature(rustc_diagnostic_macros)]
2929
#![feature(slice_patterns)]
30-
#![feature(question_mark)]
30+
#![cfg_attr(stage0, feature(question_mark))]
3131
#![feature(box_patterns)]
3232
#![feature(box_syntax)]
3333

src/librustc_const_math/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#![feature(rustc_private)]
2727
#![feature(staged_api)]
28-
#![feature(question_mark)]
28+
#![cfg_attr(stage0, feature(question_mark))]
2929

3030
#[macro_use] extern crate log;
3131
#[macro_use] extern crate syntax;

src/librustc_driver/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#![feature(rustc_private)]
3232
#![feature(set_stdio)]
3333
#![feature(staged_api)]
34-
#![feature(question_mark)]
34+
#![cfg_attr(stage0, feature(question_mark))]
3535

3636
extern crate arena;
3737
extern crate flate;

src/librustc_errors/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![allow(unused_attributes)]
2222
#![feature(rustc_private)]
2323
#![feature(staged_api)]
24-
#![feature(question_mark)]
24+
#![cfg_attr(stage0, feature(question_mark))]
2525
#![feature(range_contains)]
2626
#![feature(libc)]
2727
#![feature(unicode)]

src/librustc_incremental/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#![cfg_attr(not(stage0), deny(warnings))]
2121

2222
#![feature(dotdot_in_tuple_patterns)]
23-
#![feature(question_mark)]
23+
#![cfg_attr(stage0, feature(question_mark))]
2424
#![feature(rustc_private)]
2525
#![feature(staged_api)]
2626
#![feature(rand)]

src/librustc_metadata/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#![feature(core_intrinsics)]
2222
#![feature(box_patterns)]
2323
#![feature(dotdot_in_tuple_patterns)]
24-
#![feature(question_mark)]
24+
#![cfg_attr(stage0, feature(question_mark))]
2525
#![feature(quote)]
2626
#![feature(rustc_diagnostic_macros)]
2727
#![feature(rustc_macro_lib)]

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
2626
#![feature(rustc_diagnostic_macros)]
2727
#![feature(rustc_private)]
2828
#![feature(staged_api)]
29-
#![feature(question_mark)]
29+
#![cfg_attr(stage0, feature(question_mark))]
3030

3131
#[macro_use] extern crate log;
3232
extern crate graphviz as dot;

src/librustc_resolve/resolve_imports.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,8 @@ impl<'a> Resolver<'a> {
197197
// If the resolution doesn't depend on glob definability, check privacy and return.
198198
if let Some(result) = self.try_result(&resolution, ns) {
199199
return result.and_then(|binding| {
200-
if self.is_accessible(binding.vis) && !is_disallowed_private_import(binding) {
200+
if self.is_accessible(binding.vis) && !is_disallowed_private_import(binding) ||
201+
binding.is_extern_crate() { // c.f. issue #37020
201202
Success(binding)
202203
} else {
203204
Failed(None)

src/librustc_trans/back/symbol_names.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -152,17 +152,17 @@ fn get_symbol_hash<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>,
152152
let mut hash_state = scx.symbol_hasher().borrow_mut();
153153
record_time(&tcx.sess.perf_stats.symbol_hash_time, || {
154154
hash_state.reset();
155-
let mut hasher = Sha256Hasher(&mut hash_state);
155+
let hasher = Sha256Hasher(&mut hash_state);
156+
let mut hasher = ty::util::TypeIdHasher::new(tcx, hasher);
156157

157158
// the main symbol name is not necessarily unique; hash in the
158159
// compiler's internal def-path, guaranteeing each symbol has a
159160
// truly unique path
160-
def_path.deterministic_hash_to(tcx, &mut hasher);
161+
hasher.def_path(def_path);
161162

162163
// Include the main item-type. Note that, in this case, the
163164
// assertions about `needs_subst` may not hold, but this item-type
164165
// ought to be the same for every reference anyway.
165-
let mut hasher = ty::util::TypeIdHasher::new(tcx, hasher);
166166
assert!(!item_type.has_erasable_regions());
167167
hasher.visit_ty(item_type);
168168

src/librustc_trans/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#![feature(slice_patterns)]
3737
#![feature(staged_api)]
3838
#![feature(unicode)]
39-
#![feature(question_mark)]
39+
#![cfg_attr(stage0, feature(question_mark))]
4040

4141
use rustc::dep_graph::WorkProduct;
4242

src/librustc_typeck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ This API is completely unstable and subject to change.
8282
#![feature(rustc_diagnostic_macros)]
8383
#![feature(rustc_private)]
8484
#![feature(staged_api)]
85-
#![feature(question_mark)]
85+
#![cfg_attr(stage0, feature(question_mark))]
8686

8787
#[macro_use] extern crate log;
8888
#[macro_use] extern crate syntax;

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#![feature(staged_api)]
2929
#![feature(test)]
3030
#![feature(unicode)]
31-
#![feature(question_mark)]
31+
#![cfg_attr(stage0, feature(question_mark))]
3232

3333
extern crate arena;
3434
extern crate getopts;

src/libserialize/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Core encoding and decoding interfaces.
3535
#![feature(specialization)]
3636
#![feature(staged_api)]
3737
#![feature(unicode)]
38-
#![feature(question_mark)]
38+
#![cfg_attr(stage0, feature(question_mark))]
3939
#![cfg_attr(test, feature(test))]
4040

4141
// test harness access

src/libstd/error.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,14 @@ use any::TypeId;
5151
use cell;
5252
use char;
5353
use fmt::{self, Debug, Display};
54-
use marker::Reflect;
5554
use mem::transmute;
5655
use num;
5756
use str;
5857
use string;
5958

6059
/// Base functionality for all errors in Rust.
6160
#[stable(feature = "rust1", since = "1.0.0")]
62-
pub trait Error: Debug + Display + Reflect {
61+
pub trait Error: Debug + Display {
6362
/// A short description of the error.
6463
///
6564
/// The description should not contain newlines or sentence-ending

0 commit comments

Comments
 (0)