Skip to content

Commit 6cb49d2

Browse files
committedOct 13, 2017
Auto merge of #45261 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests - Successful merges: #44855, #45110, #45122, #45133, #45173, #45178, #45189, #45203, #45209, #45221, #45236, #45240, #45245, #45253 - Failed merges:
2 parents 305e022 + 8ea6790 commit 6cb49d2

File tree

28 files changed

+819
-180
lines changed

28 files changed

+819
-180
lines changed
 

‎src/bootstrap/check.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,11 @@ impl Step for Rls {
246246
let compiler = builder.compiler(stage, host);
247247

248248
builder.ensure(tool::Rls { compiler, target: self.host });
249-
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
250-
cargo.arg("--manifest-path").arg(build.src.join("src/tools/rls/Cargo.toml"));
249+
let mut cargo = tool::prepare_tool_cargo(builder,
250+
compiler,
251+
host,
252+
"test",
253+
"src/tools/rls");
251254

252255
// Don't build tests dynamically, just a pain to work with
253256
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");
@@ -291,8 +294,11 @@ impl Step for Rustfmt {
291294
let compiler = builder.compiler(stage, host);
292295

293296
builder.ensure(tool::Rustfmt { compiler, target: self.host });
294-
let mut cargo = builder.cargo(compiler, Mode::Tool, host, "test");
295-
cargo.arg("--manifest-path").arg(build.src.join("src/tools/rustfmt/Cargo.toml"));
297+
let mut cargo = tool::prepare_tool_cargo(builder,
298+
compiler,
299+
host,
300+
"test",
301+
"src/tools/rustfmt");
296302

297303
// Don't build tests dynamically, just a pain to work with
298304
cargo.env("RUSTC_NO_PREFER_DYNAMIC", "1");

‎src/bootstrap/native.rs

+37-20
Original file line numberDiff line numberDiff line change
@@ -352,34 +352,51 @@ impl Step for Openssl {
352352
// originally from https://www.openssl.org/source/...
353353
let url = format!("https://s3-us-west-1.amazonaws.com/rust-lang-ci2/rust-ci-mirror/{}",
354354
name);
355-
let mut ok = false;
355+
let mut last_error = None;
356356
for _ in 0..3 {
357357
let status = Command::new("curl")
358358
.arg("-o").arg(&tmp)
359+
.arg("-f") // make curl fail if the URL does not return HTTP 200
359360
.arg(&url)
360361
.status()
361362
.expect("failed to spawn curl");
362-
if status.success() {
363-
ok = true;
364-
break
363+
364+
// Retry if download failed.
365+
if !status.success() {
366+
last_error = Some(status.to_string());
367+
continue;
365368
}
369+
370+
// Ensure the hash is correct.
371+
let mut shasum = if target.contains("apple") || build.build.contains("netbsd") {
372+
let mut cmd = Command::new("shasum");
373+
cmd.arg("-a").arg("256");
374+
cmd
375+
} else {
376+
Command::new("sha256sum")
377+
};
378+
let output = output(&mut shasum.arg(&tmp));
379+
let found = output.split_whitespace().next().unwrap();
380+
381+
// If the hash is wrong, probably the download is incomplete or S3 served an error
382+
// page. In any case, retry.
383+
if found != OPENSSL_SHA256 {
384+
last_error = Some(format!(
385+
"downloaded openssl sha256 different\n\
386+
expected: {}\n\
387+
found: {}\n",
388+
OPENSSL_SHA256,
389+
found
390+
));
391+
continue;
392+
}
393+
394+
// Everything is fine, so exit the retry loop.
395+
last_error = None;
396+
break;
366397
}
367-
if !ok {
368-
panic!("failed to download openssl source")
369-
}
370-
let mut shasum = if target.contains("apple") || build.build.contains("netbsd") {
371-
let mut cmd = Command::new("shasum");
372-
cmd.arg("-a").arg("256");
373-
cmd
374-
} else {
375-
Command::new("sha256sum")
376-
};
377-
let output = output(&mut shasum.arg(&tmp));
378-
let found = output.split_whitespace().next().unwrap();
379-
if found != OPENSSL_SHA256 {
380-
panic!("downloaded openssl sha256 different\n\
381-
expected: {}\n\
382-
found: {}\n", OPENSSL_SHA256, found);
398+
if let Some(error) = last_error {
399+
panic!("failed to download openssl source: {}", error);
383400
}
384401
t!(fs::rename(&tmp, &tarball));
385402
}

‎src/liballoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@
121121
#![feature(unique)]
122122
#![feature(unsize)]
123123
#![feature(allocator_internals)]
124+
#![feature(on_unimplemented)]
124125

125126
#![cfg_attr(not(test), feature(fused, fn_traits, placement_new_protocol, swap_with_slice, i128))]
126127
#![cfg_attr(test, feature(test, box_heap))]

‎src/liballoc/vec.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,7 @@ impl<T: Hash> Hash for Vec<T> {
15431543
}
15441544

15451545
#[stable(feature = "rust1", since = "1.0.0")]
1546+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15461547
impl<T> Index<usize> for Vec<T> {
15471548
type Output = T;
15481549

@@ -1554,6 +1555,7 @@ impl<T> Index<usize> for Vec<T> {
15541555
}
15551556

15561557
#[stable(feature = "rust1", since = "1.0.0")]
1558+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15571559
impl<T> IndexMut<usize> for Vec<T> {
15581560
#[inline]
15591561
fn index_mut(&mut self, index: usize) -> &mut T {
@@ -1562,8 +1564,8 @@ impl<T> IndexMut<usize> for Vec<T> {
15621564
}
15631565
}
15641566

1565-
15661567
#[stable(feature = "rust1", since = "1.0.0")]
1568+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15671569
impl<T> ops::Index<ops::Range<usize>> for Vec<T> {
15681570
type Output = [T];
15691571

@@ -1572,7 +1574,9 @@ impl<T> ops::Index<ops::Range<usize>> for Vec<T> {
15721574
Index::index(&**self, index)
15731575
}
15741576
}
1577+
15751578
#[stable(feature = "rust1", since = "1.0.0")]
1579+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15761580
impl<T> ops::Index<ops::RangeTo<usize>> for Vec<T> {
15771581
type Output = [T];
15781582

@@ -1581,7 +1585,9 @@ impl<T> ops::Index<ops::RangeTo<usize>> for Vec<T> {
15811585
Index::index(&**self, index)
15821586
}
15831587
}
1588+
15841589
#[stable(feature = "rust1", since = "1.0.0")]
1590+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15851591
impl<T> ops::Index<ops::RangeFrom<usize>> for Vec<T> {
15861592
type Output = [T];
15871593

@@ -1590,7 +1596,9 @@ impl<T> ops::Index<ops::RangeFrom<usize>> for Vec<T> {
15901596
Index::index(&**self, index)
15911597
}
15921598
}
1599+
15931600
#[stable(feature = "rust1", since = "1.0.0")]
1601+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
15941602
impl<T> ops::Index<ops::RangeFull> for Vec<T> {
15951603
type Output = [T];
15961604

@@ -1599,7 +1607,9 @@ impl<T> ops::Index<ops::RangeFull> for Vec<T> {
15991607
self
16001608
}
16011609
}
1610+
16021611
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
1612+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16031613
impl<T> ops::Index<ops::RangeInclusive<usize>> for Vec<T> {
16041614
type Output = [T];
16051615

@@ -1608,7 +1618,9 @@ impl<T> ops::Index<ops::RangeInclusive<usize>> for Vec<T> {
16081618
Index::index(&**self, index)
16091619
}
16101620
}
1621+
16111622
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
1623+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16121624
impl<T> ops::Index<ops::RangeToInclusive<usize>> for Vec<T> {
16131625
type Output = [T];
16141626

@@ -1619,41 +1631,52 @@ impl<T> ops::Index<ops::RangeToInclusive<usize>> for Vec<T> {
16191631
}
16201632

16211633
#[stable(feature = "rust1", since = "1.0.0")]
1634+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16221635
impl<T> ops::IndexMut<ops::Range<usize>> for Vec<T> {
16231636
#[inline]
16241637
fn index_mut(&mut self, index: ops::Range<usize>) -> &mut [T] {
16251638
IndexMut::index_mut(&mut **self, index)
16261639
}
16271640
}
1641+
16281642
#[stable(feature = "rust1", since = "1.0.0")]
1643+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16291644
impl<T> ops::IndexMut<ops::RangeTo<usize>> for Vec<T> {
16301645
#[inline]
16311646
fn index_mut(&mut self, index: ops::RangeTo<usize>) -> &mut [T] {
16321647
IndexMut::index_mut(&mut **self, index)
16331648
}
16341649
}
1650+
16351651
#[stable(feature = "rust1", since = "1.0.0")]
1652+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16361653
impl<T> ops::IndexMut<ops::RangeFrom<usize>> for Vec<T> {
16371654
#[inline]
16381655
fn index_mut(&mut self, index: ops::RangeFrom<usize>) -> &mut [T] {
16391656
IndexMut::index_mut(&mut **self, index)
16401657
}
16411658
}
1659+
16421660
#[stable(feature = "rust1", since = "1.0.0")]
1661+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16431662
impl<T> ops::IndexMut<ops::RangeFull> for Vec<T> {
16441663
#[inline]
16451664
fn index_mut(&mut self, _index: ops::RangeFull) -> &mut [T] {
16461665
self
16471666
}
16481667
}
1668+
16491669
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
1670+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16501671
impl<T> ops::IndexMut<ops::RangeInclusive<usize>> for Vec<T> {
16511672
#[inline]
16521673
fn index_mut(&mut self, index: ops::RangeInclusive<usize>) -> &mut [T] {
16531674
IndexMut::index_mut(&mut **self, index)
16541675
}
16551676
}
1677+
16561678
#[unstable(feature = "inclusive_range", reason = "recently added, follows RFC", issue = "28237")]
1679+
#[rustc_on_unimplemented = "vector indices are of type `usize` or ranges of `usize`"]
16571680
impl<T> ops::IndexMut<ops::RangeToInclusive<usize>> for Vec<T> {
16581681
#[inline]
16591682
fn index_mut(&mut self, index: ops::RangeToInclusive<usize>) -> &mut [T] {

‎src/libcore/mem.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -429,9 +429,11 @@ pub fn align_of_val<T: ?Sized>(val: &T) -> usize {
429429

430430
/// Returns whether dropping values of type `T` matters.
431431
///
432-
/// This is purely an optimization hint, and may be implemented conservatively.
433-
/// For instance, always returning `true` would be a valid implementation of
434-
/// this function.
432+
/// This is purely an optimization hint, and may be implemented conservatively:
433+
/// it may return `true` for types that don't actually need to be dropped.
434+
/// As such always returning `true` would be a valid implementation of
435+
/// this function. However if this function actually returns `false`, then you
436+
/// can be certain dropping `T` has no side effect.
435437
///
436438
/// Low level implementations of things like collections, which need to manually
437439
/// drop their data, should use this function to avoid unnecessarily

‎src/librustc/middle/reachable.rs

+6
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ struct CollectPrivateImplItemsVisitor<'a, 'tcx: 'a> {
336336

337337
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a, 'tcx> {
338338
fn visit_item(&mut self, item: &hir::Item) {
339+
// Anything which has custom linkage gets thrown on the worklist no
340+
// matter where it is in the crate.
341+
if attr::contains_name(&item.attrs, "linkage") {
342+
self.worklist.push(item.id);
343+
}
344+
339345
// We need only trait impls here, not inherent impls, and only non-exported ones
340346
if let hir::ItemImpl(.., Some(ref trait_ref), _, ref impl_item_refs) = item.node {
341347
if !self.access_levels.is_reachable(item.id) {

‎src/librustc/mir/mod.rs

+13-8
Original file line numberDiff line numberDiff line change
@@ -415,9 +415,11 @@ pub enum BorrowKind {
415415
///////////////////////////////////////////////////////////////////////////
416416
// Variables and temps
417417

418-
newtype_index!(Local, "_");
419-
420-
pub const RETURN_POINTER: Local = Local(0);
418+
newtype_index!(Local
419+
{
420+
DEBUG_NAME = "_",
421+
const RETURN_POINTER = 0,
422+
});
421423

422424
/// Classifies locals into categories. See `Mir::local_kind`.
423425
#[derive(PartialEq, Eq, Debug)]
@@ -551,7 +553,7 @@ pub struct UpvarDecl {
551553
///////////////////////////////////////////////////////////////////////////
552554
// BasicBlock
553555

554-
newtype_index!(BasicBlock, "bb");
556+
newtype_index!(BasicBlock { DEBUG_NAME = "bb" });
555557

556558
///////////////////////////////////////////////////////////////////////////
557559
// BasicBlockData and Terminator
@@ -1131,7 +1133,7 @@ pub type LvalueProjection<'tcx> = Projection<'tcx, Lvalue<'tcx>, Local, Ty<'tcx>
11311133
/// and the index is a local.
11321134
pub type LvalueElem<'tcx> = ProjectionElem<'tcx, Local, Ty<'tcx>>;
11331135

1134-
newtype_index!(Field, "field");
1136+
newtype_index!(Field { DEBUG_NAME = "field" });
11351137

11361138
impl<'tcx> Lvalue<'tcx> {
11371139
pub fn field(self, f: Field, ty: Ty<'tcx>) -> Lvalue<'tcx> {
@@ -1196,8 +1198,11 @@ impl<'tcx> Debug for Lvalue<'tcx> {
11961198
///////////////////////////////////////////////////////////////////////////
11971199
// Scopes
11981200

1199-
newtype_index!(VisibilityScope, "scope");
1200-
pub const ARGUMENT_VISIBILITY_SCOPE : VisibilityScope = VisibilityScope(0);
1201+
newtype_index!(VisibilityScope
1202+
{
1203+
DEBUG_NAME = "scope",
1204+
const ARGUMENT_VISIBILITY_SCOPE = 0,
1205+
});
12011206

12021207
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
12031208
pub struct VisibilityScopeData {
@@ -1522,7 +1527,7 @@ pub struct Constant<'tcx> {
15221527
pub literal: Literal<'tcx>,
15231528
}
15241529

1525-
newtype_index!(Promoted, "promoted");
1530+
newtype_index!(Promoted { DEBUG_NAME = "promoted" });
15261531

15271532
#[derive(Clone, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
15281533
pub enum Literal<'tcx> {

‎src/librustc_borrowck/borrowck/mod.rs

+15-1
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,21 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
759759

760760
let mut db = match err.cause {
761761
MutabilityViolation => {
762-
self.cannot_assign(error_span, &descr, Origin::Ast)
762+
let mut db = self.cannot_assign(error_span, &descr, Origin::Ast);
763+
if let mc::NoteClosureEnv(upvar_id) = err.cmt.note {
764+
let node_id = self.tcx.hir.hir_to_node_id(upvar_id.var_id);
765+
let sp = self.tcx.hir.span(node_id);
766+
match self.tcx.sess.codemap().span_to_snippet(sp) {
767+
Ok(snippet) => {
768+
let msg = &format!("consider making `{}` mutable", snippet);
769+
db.span_suggestion(sp, msg, format!("mut {}", snippet));
770+
}
771+
_ => {
772+
db.span_help(sp, "consider making this binding mutable");
773+
}
774+
}
775+
}
776+
db
763777
}
764778
BorrowViolation(euv::ClosureCapture(_)) => {
765779
struct_span_err!(self.tcx.sess, error_span, E0595,

0 commit comments

Comments
 (0)
Please sign in to comment.