Skip to content

Commit 7ef9eb3

Browse files
authored
Merge pull request #4 from rust-lang/master
update from origin 2020-06-18
2 parents 395256a + e55d3f9 commit 7ef9eb3

File tree

37 files changed

+223
-133
lines changed

37 files changed

+223
-133
lines changed

RELEASES.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ Compatibility Notes
912912
[`Duration::mul_f32`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f32
913913
[`Duration::mul_f64`]: https://doc.rust-lang.org/std/time/struct.Duration.html#method.mul_f64
914914
[`any::type_name`]: https://doc.rust-lang.org/std/any/fn.type_name.html
915-
[forge-platform-support]: https://forge.rust-lang.org/platform-support.html
915+
[forge-platform-support]: https://forge.rust-lang.org/release/platform-support.html
916916
[pipeline-internals]: https://internals.rust-lang.org/t/evaluating-pipelined-rustc-compilation/10199
917917

918918
Version 1.37.0 (2019-08-15)

src/bootstrap/compile.rs

+10
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ pub fn std_cargo(builder: &Builder<'_>, target: Interned<String>, stage: u32, ca
244244
if stage >= 1 {
245245
cargo.rustflag("-Cembed-bitcode=yes");
246246
}
247+
248+
// By default, rustc does not include unwind tables unless they are required
249+
// for a particular target. They are not required by RISC-V targets, but
250+
// compiling the standard library with them means that users can get
251+
// backtraces without having to recompile the standard library themselves.
252+
//
253+
// This choice was discussed in https://github.com/rust-lang/rust/pull/69890
254+
if target.contains("riscv") {
255+
cargo.rustflag("-Cforce-unwind-tables=yes");
256+
}
247257
}
248258

249259
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]

src/bootstrap/flags.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
149149
"N",
150150
);
151151
opts.optopt("", "src", "path to the root of the rust checkout", "DIR");
152-
opts.optopt("j", "jobs", "number of jobs to run in parallel", "JOBS");
152+
let j_msg = format!(
153+
"number of jobs to run in parallel; \
154+
defaults to {} (this host's logical CPU count)",
155+
num_cpus::get()
156+
);
157+
opts.optopt("j", "jobs", &j_msg, "JOBS");
153158
opts.optflag("h", "help", "print this help message");
154159
opts.optopt(
155160
"",

src/bootstrap/test.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,10 @@ impl Step for Clippy {
554554

555555
builder.add_rustc_lib_path(compiler, &mut cargo);
556556

557-
builder.run(&mut cargo.into());
557+
// FIXME: Disable clippy tests for now, they're failing on master
558+
// (generally this would mean a toolstate failure but we don't have
559+
// toolstate for clippy anymore).
560+
// builder.run(&mut cargo.into());
558561
}
559562
}
560563

src/bootstrap/toolstate.rs

+12
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,18 @@ impl Builder<'_> {
272272
/// `rust.save-toolstates` in `config.toml`. If unspecified, nothing will be
273273
/// done. The file is updated immediately after this function completes.
274274
pub fn save_toolstate(&self, tool: &str, state: ToolState) {
275+
// If we're in a dry run setting we don't want to save toolstates as
276+
// that means if we e.g. panic down the line it'll look like we tested
277+
// everything (but we actually haven't).
278+
if self.config.dry_run {
279+
return;
280+
}
281+
// Toolstate isn't tracked for clippy, but since most tools do, we avoid
282+
// checking in all the places we could save toolstate and just do so
283+
// here.
284+
if tool == "clippy-driver" {
285+
return;
286+
}
275287
if let Some(ref path) = self.config.save_toolstates {
276288
if let Some(parent) = path.parent() {
277289
// Ensure the parent directory always exists

src/ci/docker/x86_64-gnu-tools/checktools.sh

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ python3 "$X_PY" test --no-fail-fast \
1414
src/doc/rust-by-example \
1515
src/doc/embedded-book \
1616
src/doc/edition-guide \
17-
src/tools/clippy \
1817
src/tools/rls \
1918
src/tools/rustfmt \
2019
src/tools/miri \
2120

2221
set -e
2322

23+
# debugging: print out the saved toolstates
24+
cat /tmp/toolstate/toolstates.json
2425
python3 "$X_PY" test check-tools
26+
python3 "$X_PY" test src/tools/clippy

src/libcore/mem/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ pub use crate::intrinsics::transmute;
129129
/// erring on the side of (double-)dropping.
130130
///
131131
/// Also, `ManuallyDrop` prevents us from having to "touch" `v` after transferring the
132-
/// ownership to `s` - the final step of interacting with `v` to dispoe of it without
132+
/// ownership to `s` the final step of interacting with `v` to dispose of it without
133133
/// running its destructor is entirely avoided.
134134
///
135135
/// [drop]: fn.drop.html

src/libcore/panic.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ pub struct PanicInfo<'a> {
3939
impl<'a> PanicInfo<'a> {
4040
#[unstable(
4141
feature = "panic_internals",
42-
reason = "internal details of the implementation of the `panic!` \
43-
and related macros",
42+
reason = "internal details of the implementation of the `panic!` and related macros",
4443
issue = "none"
4544
)]
4645
#[doc(hidden)]
@@ -55,8 +54,7 @@ impl<'a> PanicInfo<'a> {
5554

5655
#[unstable(
5756
feature = "panic_internals",
58-
reason = "internal details of the implementation of the `panic!` \
59-
and related macros",
57+
reason = "internal details of the implementation of the `panic!` and related macros",
6058
issue = "none"
6159
)]
6260
#[doc(hidden)]
@@ -244,8 +242,7 @@ impl<'a> Location<'a> {
244242
impl<'a> Location<'a> {
245243
#![unstable(
246244
feature = "panic_internals",
247-
reason = "internal details of the implementation of the `panic!` \
248-
and related macros",
245+
reason = "internal details of the implementation of the `panic!` and related macros",
249246
issue = "none"
250247
)]
251248
#[doc(hidden)]

src/libcore/panicking.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
2222
#![allow(dead_code, missing_docs)]
2323
#![unstable(
2424
feature = "core_panic",
25-
reason = "internal details of the implementation of the `panic!` \
26-
and related macros",
25+
reason = "internal details of the implementation of the `panic!` and related macros",
2726
issue = "none"
2827
)]
2928

src/librustc_arena/lib.rs

+41-31
Original file line numberDiff line numberDiff line change
@@ -333,13 +333,6 @@ impl Default for DroplessArena {
333333
}
334334

335335
impl DroplessArena {
336-
#[inline]
337-
fn align(&self, align: usize) {
338-
let final_address = ((self.ptr.get() as usize) + align - 1) & !(align - 1);
339-
self.ptr.set(final_address as *mut u8);
340-
assert!(self.ptr <= self.end);
341-
}
342-
343336
#[inline(never)]
344337
#[cold]
345338
fn grow(&self, additional: usize) {
@@ -370,30 +363,50 @@ impl DroplessArena {
370363
}
371364
}
372365

366+
/// Allocates a byte slice with specified size and alignment from the
367+
/// current memory chunk. Returns `None` if there is no free space left to
368+
/// satisfy the request.
373369
#[inline]
374-
pub fn alloc_raw(&self, bytes: usize, align: usize) -> &mut [u8] {
375-
unsafe {
376-
assert!(bytes != 0);
377-
378-
self.align(align);
370+
fn alloc_raw_without_grow(&self, bytes: usize, align: usize) -> Option<*mut u8> {
371+
let ptr = self.ptr.get() as usize;
372+
let end = self.end.get() as usize;
373+
// The allocation request fits into the current chunk iff:
374+
//
375+
// let aligned = align_to(ptr, align);
376+
// ptr <= aligned && aligned + bytes <= end
377+
//
378+
// Except that we work with fixed width integers and need to be careful
379+
// about potential overflow in the calcuation. If the overflow does
380+
// happen, then we definitely don't have enough free and need to grow
381+
// the arena.
382+
let aligned = ptr.checked_add(align - 1)? & !(align - 1);
383+
let new_ptr = aligned.checked_add(bytes)?;
384+
if new_ptr <= end {
385+
self.ptr.set(new_ptr as *mut u8);
386+
Some(aligned as *mut u8)
387+
} else {
388+
None
389+
}
390+
}
379391

380-
let future_end = intrinsics::arith_offset(self.ptr.get(), bytes as isize);
381-
if (future_end as *mut u8) > self.end.get() {
382-
self.grow(bytes);
392+
#[inline]
393+
pub fn alloc_raw(&self, bytes: usize, align: usize) -> *mut u8 {
394+
assert!(bytes != 0);
395+
loop {
396+
if let Some(a) = self.alloc_raw_without_grow(bytes, align) {
397+
break a;
383398
}
384-
385-
let ptr = self.ptr.get();
386-
// Set the pointer past ourselves
387-
self.ptr.set(intrinsics::arith_offset(self.ptr.get(), bytes as isize) as *mut u8);
388-
slice::from_raw_parts_mut(ptr, bytes)
399+
// No free space left. Allocate a new chunk to satisfy the request.
400+
// On failure the grow will panic or abort.
401+
self.grow(bytes);
389402
}
390403
}
391404

392405
#[inline]
393406
pub fn alloc<T>(&self, object: T) -> &mut T {
394407
assert!(!mem::needs_drop::<T>());
395408

396-
let mem = self.alloc_raw(mem::size_of::<T>(), mem::align_of::<T>()) as *mut _ as *mut T;
409+
let mem = self.alloc_raw(mem::size_of::<T>(), mem::align_of::<T>()) as *mut T;
397410

398411
unsafe {
399412
// Write into uninitialized memory.
@@ -418,13 +431,11 @@ impl DroplessArena {
418431
assert!(mem::size_of::<T>() != 0);
419432
assert!(!slice.is_empty());
420433

421-
let mem = self.alloc_raw(slice.len() * mem::size_of::<T>(), mem::align_of::<T>()) as *mut _
422-
as *mut T;
434+
let mem = self.alloc_raw(slice.len() * mem::size_of::<T>(), mem::align_of::<T>()) as *mut T;
423435

424436
unsafe {
425-
let arena_slice = slice::from_raw_parts_mut(mem, slice.len());
426-
arena_slice.copy_from_slice(slice);
427-
arena_slice
437+
mem.copy_from_nonoverlapping(slice.as_ptr(), slice.len());
438+
slice::from_raw_parts_mut(mem, slice.len())
428439
}
429440
}
430441

@@ -467,7 +478,7 @@ impl DroplessArena {
467478
return &mut [];
468479
}
469480
let size = len.checked_mul(mem::size_of::<T>()).unwrap();
470-
let mem = self.alloc_raw(size, mem::align_of::<T>()) as *mut _ as *mut T;
481+
let mem = self.alloc_raw(size, mem::align_of::<T>()) as *mut T;
471482
unsafe { self.write_from_iter(iter, len, mem) }
472483
}
473484
(_, _) => {
@@ -482,7 +493,7 @@ impl DroplessArena {
482493
let len = vec.len();
483494
let start_ptr = self
484495
.alloc_raw(len * mem::size_of::<T>(), mem::align_of::<T>())
485-
as *mut _ as *mut T;
496+
as *mut T;
486497
vec.as_ptr().copy_to_nonoverlapping(start_ptr, len);
487498
vec.set_len(0);
488499
slice::from_raw_parts_mut(start_ptr, len)
@@ -526,8 +537,7 @@ pub struct DropArena {
526537
impl DropArena {
527538
#[inline]
528539
pub unsafe fn alloc<T>(&self, object: T) -> &mut T {
529-
let mem =
530-
self.arena.alloc_raw(mem::size_of::<T>(), mem::align_of::<T>()) as *mut _ as *mut T;
540+
let mem = self.arena.alloc_raw(mem::size_of::<T>(), mem::align_of::<T>()) as *mut T;
531541
// Write into uninitialized memory.
532542
ptr::write(mem, object);
533543
let result = &mut *mem;
@@ -550,7 +560,7 @@ impl DropArena {
550560
let start_ptr = self
551561
.arena
552562
.alloc_raw(len.checked_mul(mem::size_of::<T>()).unwrap(), mem::align_of::<T>())
553-
as *mut _ as *mut T;
563+
as *mut T;
554564

555565
let mut destructors = self.destructors.borrow_mut();
556566
// Reserve space for the destructors so we can't panic while adding them

src/librustc_codegen_ssa/back/linker.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ impl<'a> Linker for GccLinker<'a> {
280280
fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) {
281281
match output_kind {
282282
LinkOutputKind::DynamicNoPicExe => {
283-
if !self.is_ld {
283+
if !self.is_ld && self.sess.target.target.options.linker_is_gnu {
284284
self.cmd.arg("-no-pie");
285285
}
286286
}
@@ -291,7 +291,7 @@ impl<'a> Linker for GccLinker<'a> {
291291
LinkOutputKind::StaticNoPicExe => {
292292
// `-static` works for both gcc wrapper and ld.
293293
self.cmd.arg("-static");
294-
if !self.is_ld {
294+
if !self.is_ld && self.sess.target.target.options.linker_is_gnu {
295295
self.cmd.arg("-no-pie");
296296
}
297297
}

src/librustc_infer/traits/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ pub type TraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;
5959

6060
// `PredicateObligation` is used a lot. Make sure it doesn't unintentionally get bigger.
6161
#[cfg(target_arch = "x86_64")]
62-
static_assert_size!(PredicateObligation<'_>, 88);
62+
static_assert_size!(PredicateObligation<'_>, 48);
6363

6464
pub type Obligations<'tcx, O> = Vec<Obligation<'tcx, O>>;
6565
pub type PredicateObligations<'tcx> = Vec<PredicateObligation<'tcx>>;

src/librustc_infer/traits/util.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,12 @@ fn predicate_obligation<'tcx>(
142142
predicate: ty::Predicate<'tcx>,
143143
span: Option<Span>,
144144
) -> PredicateObligation<'tcx> {
145-
let mut cause = ObligationCause::dummy();
146-
if let Some(span) = span {
147-
cause.span = span;
148-
}
145+
let cause = if let Some(span) = span {
146+
ObligationCause::dummy_with_span(span)
147+
} else {
148+
ObligationCause::dummy()
149+
};
150+
149151
Obligation { cause, param_env: ty::ParamEnv::empty(), recursion_depth: 0, predicate }
150152
}
151153

src/librustc_middle/macros.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
#[macro_export]
22
macro_rules! bug {
3-
() => ( bug!("impossible case reached") );
4-
($($message:tt)*) => ({
5-
$crate::util::bug::bug_fmt(file!(), line!(), format_args!($($message)*))
6-
})
3+
() => ( $crate::bug!("impossible case reached") );
4+
($msg:expr) => ({ $crate::util::bug::bug_fmt(::std::format_args!($msg)) });
5+
($msg:expr,) => ({ $crate::bug!($msg) });
6+
($fmt:expr, $($arg:tt)+) => ({
7+
$crate::util::bug::bug_fmt(::std::format_args!($fmt, $($arg)+))
8+
});
79
}
810

911
#[macro_export]
1012
macro_rules! span_bug {
11-
($span:expr, $($message:tt)*) => ({
12-
$crate::util::bug::span_bug_fmt(file!(), line!(), $span, format_args!($($message)*))
13-
})
13+
($span:expr, $msg:expr) => ({ $crate::util::bug::span_bug_fmt($span, ::std::format_args!($msg)) });
14+
($span:expr, $msg:expr,) => ({ $crate::span_bug!($span, $msg) });
15+
($span:expr, $fmt:expr, $($arg:tt)+) => ({
16+
$crate::util::bug::span_bug_fmt($span, ::std::format_args!($fmt, $($arg)+))
17+
});
1418
}
1519

1620
///////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)