Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 5 pull requests #72131

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/liballoc/alloc/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn allocate_zeroed() {
}

#[bench]
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn alloc_owned_small(b: &mut Bencher) {
b.iter(|| {
let _: Box<_> = box 10;
Expand Down
1 change: 0 additions & 1 deletion src/liballoc/collections/linked_list/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,6 @@ fn test_insert_prev() {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn test_send() {
let n = list_from(&[1, 2, 3]);
thread::spawn(move || {
Expand Down
8 changes: 4 additions & 4 deletions src/liballoc/collections/vec_deque/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
use test;

#[bench]
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn bench_push_back_100(b: &mut test::Bencher) {
let mut deq = VecDeque::with_capacity(101);
b.iter(|| {
Expand All @@ -16,7 +16,7 @@ fn bench_push_back_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn bench_push_front_100(b: &mut test::Bencher) {
let mut deq = VecDeque::with_capacity(101);
b.iter(|| {
Expand All @@ -29,7 +29,7 @@ fn bench_push_front_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn bench_pop_back_100(b: &mut test::Bencher) {
let mut deq = VecDeque::<i32>::with_capacity(101);

Expand All @@ -43,7 +43,7 @@ fn bench_pop_back_100(b: &mut test::Bencher) {
}

#[bench]
#[cfg_attr(miri, ignore)] // Miri does not support benchmarks
#[cfg_attr(miri, ignore)] // isolated Miri does not support benchmarks
fn bench_pop_front_100(b: &mut test::Bencher) {
let mut deq = VecDeque::<i32>::with_capacity(101);

Expand Down
8 changes: 5 additions & 3 deletions src/liballoc/sync/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ impl Drop for Canary {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn manually_share_arc() {
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
let arc_v = Arc::new(v);
Expand Down Expand Up @@ -337,12 +336,13 @@ fn test_ptr_eq() {

#[test]
#[cfg_attr(target_os = "emscripten", ignore)]
#[cfg_attr(miri, ignore)] // Miri does not support threads
fn test_weak_count_locked() {
let mut a = Arc::new(atomic::AtomicBool::new(false));
let a2 = a.clone();
let t = thread::spawn(move || {
for _i in 0..1000000 {
// Miri is too slow
let count = if cfg!(miri) { 1000 } else { 1000000 };
for _i in 0..count {
Arc::get_mut(&mut a);
}
a.store(true, SeqCst);
Expand All @@ -351,6 +351,8 @@ fn test_weak_count_locked() {
while !a2.load(SeqCst) {
let n = Arc::weak_count(&a2);
assert!(n < 2, "bad weak count: {}", n);
#[cfg(miri)] // Miri's scheduler does not guarantee liveness, and thus needs this hint.
atomic::spin_loop_hint();
}
t.join().unwrap();
}
Expand Down
23 changes: 14 additions & 9 deletions src/librustc_driver/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1138,6 +1138,16 @@ pub fn catch_fatal_errors<F: FnOnce() -> R, R>(f: F) -> Result<R, ErrorReported>
})
}

/// Variant of `catch_fatal_errors` for the `interface::Result` return type
/// that also computes the exit code.
pub fn catch_with_exit_code(f: impl FnOnce() -> interface::Result<()>) -> i32 {
let result = catch_fatal_errors(f).and_then(|result| result);
match result {
Ok(()) => EXIT_SUCCESS,
Err(_) => EXIT_FAILURE,
}
}

lazy_static! {
static ref DEFAULT_HOOK: Box<dyn Fn(&panic::PanicInfo<'_>) + Sync + Send + 'static> = {
let hook = panic::take_hook();
Expand Down Expand Up @@ -1228,12 +1238,12 @@ pub fn init_rustc_env_logger() {
env_logger::init_from_env("RUSTC_LOG");
}

pub fn main() {
pub fn main() -> ! {
let start = Instant::now();
init_rustc_env_logger();
let mut callbacks = TimePassesCallbacks::default();
install_ice_hook();
let result = catch_fatal_errors(|| {
let exit_code = catch_with_exit_code(|| {
let args = env::args_os()
.enumerate()
.map(|(i, arg)| {
Expand All @@ -1246,13 +1256,8 @@ pub fn main() {
})
.collect::<Vec<_>>();
run_compiler(&args, &mut callbacks, None, None)
})
.and_then(|result| result);
let exit_code = match result {
Ok(_) => EXIT_SUCCESS,
Err(_) => EXIT_FAILURE,
};
});
// The extra `\t` is necessary to align this label with the others.
print_time_passes_entry(callbacks.time_passes, "\ttotal", start.elapsed());
process::exit(exit_code);
process::exit(exit_code)
}
31 changes: 21 additions & 10 deletions src/librustc_middle/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,38 @@ pub struct Pointer<Tag = ()> {

static_assert_size!(Pointer, 16);

/// Print the address of a pointer (without the tag)
fn print_ptr_addr<Tag, Id: fmt::Debug>(
ptr: &Pointer<Tag, Id>,
f: &mut fmt::Formatter<'_>,
) -> fmt::Result {
// Forward `alternate` flag to `alloc_id` printing.
if f.alternate() {
write!(f, "{:#?}", ptr.alloc_id)?;
} else {
write!(f, "{:?}", ptr.alloc_id)?;
}
// Print offset only if it is non-zero.
if ptr.offset.bytes() > 0 {
write!(f, "+0x{:x}", ptr.offset.bytes())?;
}
Ok(())
}

// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
// all the Miri types.
// We have to use `Debug` output for the tag, because `()` does not implement
// `Display` so we cannot specialize that.
impl<Tag: fmt::Debug> fmt::Debug for Pointer<Tag> {
default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
write!(f, "{:#?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
} else {
write!(f, "{:?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
}
print_ptr_addr(self, f)?;
write!(f, "[{:?}]", self.tag)
}
}
// Specialization for no tag
impl fmt::Debug for Pointer<()> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {
write!(f, "{:#?}+0x{:x}", self.alloc_id, self.offset.bytes())
} else {
write!(f, "{:?}+0x{:x}", self.alloc_id, self.offset.bytes())
}
print_ptr_addr(self, f)
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/librustc_mir/interpret/validity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use rustc_middle::mir::interpret::{InterpError, InterpErrorInfo};
use rustc_middle::ty;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_span::symbol::{sym, Symbol};
use rustc_target::abi::{Abi, LayoutOf, Scalar, VariantIdx, Variants};
use rustc_target::abi::{Abi, LayoutOf, Scalar, Size, VariantIdx, Variants};

use std::hash::Hash;

Expand Down Expand Up @@ -744,10 +744,11 @@ impl<'rt, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> ValueVisitor<'mir, 'tcx, M>
match op.layout.ty.kind {
ty::Str => {
let mplace = op.assert_mem_place(self.ecx); // strings are never immediate
let len = mplace.len(self.ecx)?;
try_validation!(
self.ecx.read_str(mplace),
self.ecx.memory.read_bytes(mplace.ptr, Size::from_bytes(len)),
self.path,
err_ub!(InvalidStr(..)) => { "uninitialized or non-UTF-8 data in str" },
err_ub!(InvalidUninitBytes(..)) => { "uninitialized data in `str`" },
);
}
ty::Array(tys, ..) | ty::Slice(tys)
Expand Down
14 changes: 11 additions & 3 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use pulldown_cmark::{html, CodeBlockKind, CowStr, Event, Options, Parser, Tag};
mod tests;

fn opts() -> Options {
Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES
Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES | Options::ENABLE_STRIKETHROUGH
}

/// When `to_string` is called, this struct will emit the HTML corresponding to
Expand Down Expand Up @@ -933,7 +933,11 @@ impl MarkdownSummaryLine<'_> {
}
};

let p = Parser::new_with_broken_link_callback(md, Options::empty(), Some(&replacer));
let p = Parser::new_with_broken_link_callback(
md,
Options::ENABLE_STRIKETHROUGH,
Some(&replacer),
);

let mut s = String::new();

Expand Down Expand Up @@ -975,7 +979,11 @@ pub fn plain_summary_line(md: &str) -> String {
}
}
let mut s = String::with_capacity(md.len() * 3 / 2);
let p = ParserWrapper { inner: Parser::new(md), is_in: 0, is_first: true };
let p = ParserWrapper {
inner: Parser::new_ext(md, Options::ENABLE_STRIKETHROUGH),
is_in: 0,
is_first: true,
};
p.filter(|t| !t.is_empty()).for_each(|i| s.push_str(&i));
s
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ fn main() -> () {
_1 = const b"foo"; // scope 0 at $DIR/byte_slice.rs:5:13: 5:19
// ty::Const
// + ty: &[u8; 3]
// + val: Value(Scalar(alloc0+0x0))
// + val: Value(Scalar(alloc0))
// mir::Constant
// + span: $DIR/byte_slice.rs:5:13: 5:19
// + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0+0x0)) }
// + literal: Const { ty: &[u8; 3], val: Value(Scalar(alloc0)) }
StorageLive(_2); // scope 1 at $DIR/byte_slice.rs:6:9: 6:10
_2 = [const 5u8, const 120u8]; // scope 1 at $DIR/byte_slice.rs:6:13: 6:24
// ty::Const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ promoted[0] in BAR: &[&i32; 1] = {
let mut _3: &i32; // in scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34

bb0: {
_3 = const {alloc0+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
_3 = const {alloc0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
// ty::Const
// + ty: &i32
// + val: Value(Scalar(alloc0+0x0))
// + val: Value(Scalar(alloc0))
// mir::Constant
// + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
// + literal: Const { ty: &i32, val: Value(Scalar(alloc0+0x0)) }
// + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) }
_2 = _3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
_1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
_0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
- StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
- StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
- StorageLive(_5); // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
- _5 = const {alloc0+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
- _5 = const {alloc0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:9:33: 9:34
+ _6 = const BAR::promoted[0]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
// ty::Const
- // + ty: &i32
- // + val: Value(Scalar(alloc0+0x0))
- // + val: Value(Scalar(alloc0))
+ // + ty: &[&i32; 1]
+ // + val: Unevaluated(DefId(0:6 ~ const_promotion_extern_static[317d]::BAR[0]), [], Some(promoted[0]))
// mir::Constant
- // + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc0+0x0)) }
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) }
- _4 = &(*_5); // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ promoted[0] in FOO: &[&i32; 1] = {
}

bb0: {
_3 = const {alloc2+0x0: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:13:42: 13:43
_3 = const {alloc2: &i32}; // scope 0 at $DIR/const-promotion-extern-static.rs:13:42: 13:43
// ty::Const
// + ty: &i32
// + val: Value(Scalar(alloc2+0x0))
// + val: Value(Scalar(alloc2))
// mir::Constant
// + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43
// + literal: Const { ty: &i32, val: Value(Scalar(alloc2+0x0)) }
// + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) }
_2 = _3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:41: 13:43
_1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
_0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
- StorageLive(_3); // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
- StorageLive(_4); // scope 0 at $DIR/const-promotion-extern-static.rs:13:32: 13:45
- StorageLive(_5); // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43
- _5 = const {alloc2+0x0: &i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43
- _5 = const {alloc2: &i32}; // scope 1 at $DIR/const-promotion-extern-static.rs:13:42: 13:43
+ _6 = const FOO::promoted[0]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
// ty::Const
- // + ty: &i32
- // + val: Value(Scalar(alloc2+0x0))
- // + val: Value(Scalar(alloc2))
+ // + ty: &[&i32; 1]
+ // + val: Unevaluated(DefId(0:7 ~ const_promotion_extern_static[317d]::FOO[0]), [], Some(promoted[0]))
// mir::Constant
- // + span: $DIR/const-promotion-extern-static.rs:13:42: 13:43
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc2+0x0)) }
- // + literal: Const { ty: &i32, val: Value(Scalar(alloc2)) }
- _4 = &(*_5); // scope 1 at $DIR/const-promotion-extern-static.rs:13:41: 13:43
- _3 = [move _4]; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
- _2 = &_3; // scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ fn main() -> () {
bb0: {
StorageLive(_1); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8
StorageLive(_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8
_2 = const {alloc0+0x0: &&[(std::option::Option<i32>, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8
_2 = const {alloc0: &&[(std::option::Option<i32>, &[&str])]}; // scope 0 at $DIR/const_allocation.rs:8:5: 8:8
// ty::Const
// + ty: &&[(std::option::Option<i32>, &[&str])]
// + val: Value(Scalar(alloc0+0x0))
// + val: Value(Scalar(alloc0))
// mir::Constant
// + span: $DIR/const_allocation.rs:8:5: 8:8
// + literal: Const { ty: &&[(std::option::Option<i32>, &[&str])], val: Value(Scalar(alloc0+0x0)) }
// + literal: Const { ty: &&[(std::option::Option<i32>, &[&str])], val: Value(Scalar(alloc0)) }
_1 = (*_2); // scope 0 at $DIR/const_allocation.rs:8:5: 8:8
StorageDead(_2); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
StorageDead(_1); // scope 0 at $DIR/const_allocation.rs:8:8: 8:9
Expand All @@ -30,19 +30,19 @@ fn main() -> () {
}

alloc0 (static: FOO, size: 8, align: 4) {
╾─a17+0x0─╼ 03 00 00 00 │ ╾──╼....
╾─alloc17─╼ 03 00 00 00 │ ╾──╼....
}

alloc17 (size: 48, align: 4) {
0x00 │ 00 00 00 00 __ __ __ __ ╾─a4+0x0──╼ 00 00 00 00 │ ....░░░░╾──╼....
0x10 │ 00 00 00 00 __ __ __ __ ╾─a8+0x0──╼ 02 00 00 00 │ ....░░░░╾──╼....
0x20 │ 01 00 00 00 2a 00 00 00 ╾─a13+0x0─╼ 03 00 00 00 │ ....*...╾──╼....
0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc4──╼ 00 00 00 00 │ ....░░░░╾──╼....
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 02 00 00 00 │ ....░░░░╾──╼....
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc13─╼ 03 00 00 00 │ ....*...╾──╼....
}

alloc4 (size: 0, align: 4) {}

alloc8 (size: 16, align: 4) {
╾─a7+0x0──╼ 03 00 00 00 ╾─a9+0x0──╼ 03 00 00 00 │ ╾──╼....╾──╼....
╾─alloc7──╼ 03 00 00 00 ╾─alloc9──╼ 03 00 00 00 │ ╾──╼....╾──╼....
}

alloc7 (size: 3, align: 1) {
Expand All @@ -54,8 +54,8 @@ alloc9 (size: 3, align: 1) {
}

alloc13 (size: 24, align: 4) {
0x00 │ ╾─a12+0x0─╼ 03 00 00 00 ╾─a14+0x0─╼ 03 00 00 00 │ ╾──╼....╾──╼....
0x10 │ ╾─a15+0x0─╼ 04 00 00 00 │ ╾──╼....
0x00 │ ╾─alloc12─╼ 03 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ╾──╼....╾──╼....
0x10 │ ╾─alloc15─╼ 04 00 00 00 │ ╾──╼....
}

alloc12 (size: 3, align: 1) {
Expand Down
Loading