Skip to content

Commit 7184d13

Browse files
committed
Auto merge of #71795 - RalfJung:rollup-yqxfi5a, r=RalfJung
Rollup of 6 pull requests Successful merges: - #71712 (Miri: port error backtraces to std::backtrace) - #71736 (bootstrap: also apply unused-attributes hack without deny_warnings) - #71738 (remove AllocId generalization of Pointer) - #71739 (remove obsolete comment) - #71781 (Uncomment test code for failure to use `Box::pin`) - #71782 (Use a non-existent test path instead of clobbering /dev/null) Failed merges: r? @ghost
2 parents 08dfbfb + 2ee49eb commit 7184d13

File tree

16 files changed

+154
-81
lines changed

16 files changed

+154
-81
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -3978,7 +3978,6 @@ name = "rustc_middle"
39783978
version = "0.0.0"
39793979
dependencies = [
39803980
"arena",
3981-
"backtrace",
39823981
"bitflags",
39833982
"byteorder",
39843983
"log",

src/bootstrap/builder.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1088,13 +1088,13 @@ impl<'a> Builder<'a> {
10881088

10891089
if self.config.deny_warnings {
10901090
rustflags.arg("-Dwarnings");
1091+
}
10911092

1092-
// FIXME(#58633) hide "unused attribute" errors in incremental
1093-
// builds of the standard library, as the underlying checks are
1094-
// not yet properly integrated with incremental recompilation.
1095-
if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
1096-
rustflags.arg("-Aunused-attributes");
1097-
}
1093+
// FIXME(#58633) hide "unused attribute" errors in incremental
1094+
// builds of the standard library, as the underlying checks are
1095+
// not yet properly integrated with incremental recompilation.
1096+
if mode == Mode::Std && compiler.stage == 0 && self.config.incremental {
1097+
rustflags.arg("-Aunused-attributes");
10981098
}
10991099
}
11001100

src/librustc_middle/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ rustc_index = { path = "../librustc_index" }
3030
rustc_serialize = { path = "../libserialize", package = "serialize" }
3131
rustc_ast = { path = "../librustc_ast" }
3232
rustc_span = { path = "../librustc_span" }
33-
backtrace = "0.3.40"
3433
byteorder = { version = "1.3" }
3534
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
3635
measureme = "0.7.1"

src/librustc_middle/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
//! This API is completely unstable and subject to change.
2424
2525
#![doc(html_root_url = "https://doc.rust-lang.org/nightly/")]
26+
#![feature(backtrace)]
2627
#![feature(bool_to_option)]
2728
#![feature(box_patterns)]
2829
#![feature(box_syntax)]

src/librustc_middle/mir/interpret/error.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::ty::query::TyCtxtAt;
66
use crate::ty::tls;
77
use crate::ty::{self, layout, Ty};
88

9-
use backtrace::Backtrace;
109
use rustc_data_structures::sync::Lock;
1110
use rustc_errors::{struct_span_err, DiagnosticBuilder, ErrorReported};
1211
use rustc_hir as hir;
@@ -15,7 +14,7 @@ use rustc_macros::HashStable;
1514
use rustc_session::CtfeBacktrace;
1615
use rustc_span::{def_id::DefId, Pos, Span};
1716
use rustc_target::abi::{Align, Size};
18-
use std::{any::Any, fmt, mem};
17+
use std::{any::Any, backtrace::Backtrace, fmt, mem};
1918

2019
#[derive(Debug, Copy, Clone, PartialEq, Eq, HashStable, RustcEncodable, RustcDecodable)]
2120
pub enum ErrorHandled {
@@ -219,16 +218,15 @@ impl fmt::Display for InterpErrorInfo<'_> {
219218
}
220219

221220
impl InterpErrorInfo<'_> {
222-
pub fn print_backtrace(&mut self) {
223-
if let Some(ref mut backtrace) = self.backtrace {
224-
print_backtrace(&mut *backtrace);
221+
pub fn print_backtrace(&self) {
222+
if let Some(backtrace) = self.backtrace.as_ref() {
223+
print_backtrace(backtrace);
225224
}
226225
}
227226
}
228227

229-
fn print_backtrace(backtrace: &mut Backtrace) {
230-
backtrace.resolve();
231-
eprintln!("\n\nAn error occurred in miri:\n{:?}", backtrace);
228+
fn print_backtrace(backtrace: &Backtrace) {
229+
eprintln!("\n\nAn error occurred in miri:\n{}", backtrace);
232230
}
233231

234232
impl From<ErrorHandled> for InterpErrorInfo<'_> {
@@ -255,11 +253,11 @@ impl<'tcx> From<InterpError<'tcx>> for InterpErrorInfo<'tcx> {
255253

256254
let backtrace = match capture_backtrace {
257255
CtfeBacktrace::Disabled => None,
258-
CtfeBacktrace::Capture => Some(Box::new(Backtrace::new_unresolved())),
256+
CtfeBacktrace::Capture => Some(Box::new(Backtrace::force_capture())),
259257
CtfeBacktrace::Immediate => {
260258
// Print it now.
261-
let mut backtrace = Backtrace::new_unresolved();
262-
print_backtrace(&mut backtrace);
259+
let backtrace = Backtrace::force_capture();
260+
print_backtrace(&backtrace);
263261
None
264262
}
265263
};

src/librustc_middle/mir/interpret/pointer.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,14 @@ pub trait PointerArithmetic: HasDataLayout {
7575

7676
impl<T: HasDataLayout> PointerArithmetic for T {}
7777

78-
/// `Pointer` is generic over the type that represents a reference to `Allocation`s,
79-
/// thus making it possible for the most convenient representation to be used in
80-
/// each context.
78+
/// Represents a pointer in the Miri engine.
8179
///
82-
/// Defaults to the index based and loosely coupled `AllocId`.
83-
///
84-
/// `Pointer` is also generic over the `Tag` associated with each pointer,
80+
/// `Pointer` is generic over the `Tag` associated with each pointer,
8581
/// which is used to do provenance tracking during execution.
8682
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
8783
#[derive(HashStable)]
88-
pub struct Pointer<Tag = (), Id = AllocId> {
89-
pub alloc_id: Id,
84+
pub struct Pointer<Tag = ()> {
85+
pub alloc_id: AllocId,
9086
pub offset: Size,
9187
pub tag: Tag,
9288
}
@@ -97,7 +93,7 @@ static_assert_size!(Pointer, 16);
9793
// all the Miri types.
9894
// We have to use `Debug` output for the tag, because `()` does not implement
9995
// `Display` so we cannot specialize that.
100-
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
96+
impl<Tag: fmt::Debug> fmt::Debug for Pointer<Tag> {
10197
default fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
10298
if f.alternate() {
10399
write!(f, "{:#?}+0x{:x}[{:?}]", self.alloc_id, self.offset.bytes(), self.tag)
@@ -107,7 +103,7 @@ impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Pointer<Tag, Id> {
107103
}
108104
}
109105
// Specialization for no tag
110-
impl<Id: fmt::Debug> fmt::Debug for Pointer<(), Id> {
106+
impl fmt::Debug for Pointer<()> {
111107
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
112108
if f.alternate() {
113109
write!(f, "{:#?}+0x{:x}", self.alloc_id, self.offset.bytes())

src/librustc_middle/mir/interpret/value.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl<'tcx> ConstValue<'tcx> {
8989
/// of a simple value or a pointer into another `Allocation`
9090
#[derive(Clone, Copy, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
9191
#[derive(HashStable)]
92-
pub enum Scalar<Tag = (), Id = AllocId> {
92+
pub enum Scalar<Tag = ()> {
9393
/// The raw bytes of a simple value.
9494
Raw {
9595
/// The first `size` bytes of `data` are the value.
@@ -101,15 +101,15 @@ pub enum Scalar<Tag = (), Id = AllocId> {
101101
/// A pointer into an `Allocation`. An `Allocation` in the `memory` module has a list of
102102
/// relocations, but a `Scalar` is only large enough to contain one, so we just represent the
103103
/// relocation and its associated offset together as a `Pointer` here.
104-
Ptr(Pointer<Tag, Id>),
104+
Ptr(Pointer<Tag>),
105105
}
106106

107107
#[cfg(target_arch = "x86_64")]
108108
static_assert_size!(Scalar, 24);
109109

110110
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
111111
// all the Miri types.
112-
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for Scalar<Tag, Id> {
112+
impl<Tag: fmt::Debug> fmt::Debug for Scalar<Tag> {
113113
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
114114
match self {
115115
Scalar::Ptr(ptr) => write!(f, "{:?}", ptr),
@@ -542,8 +542,8 @@ impl<Tag> From<Pointer<Tag>> for Scalar<Tag> {
542542
}
543543

544544
#[derive(Clone, Copy, Eq, PartialEq, RustcEncodable, RustcDecodable, HashStable, Hash)]
545-
pub enum ScalarMaybeUndef<Tag = (), Id = AllocId> {
546-
Scalar(Scalar<Tag, Id>),
545+
pub enum ScalarMaybeUndef<Tag = ()> {
546+
Scalar(Scalar<Tag>),
547547
Undef,
548548
}
549549

@@ -563,7 +563,7 @@ impl<Tag> From<Pointer<Tag>> for ScalarMaybeUndef<Tag> {
563563

564564
// We want the `Debug` output to be readable as it is used by `derive(Debug)` for
565565
// all the Miri types.
566-
impl<Tag: fmt::Debug, Id: fmt::Debug> fmt::Debug for ScalarMaybeUndef<Tag, Id> {
566+
impl<Tag: fmt::Debug> fmt::Debug for ScalarMaybeUndef<Tag> {
567567
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
568568
match self {
569569
ScalarMaybeUndef::Undef => write!(f, "<uninitialized>"),

src/librustc_mir/const_eval/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl Error for ConstEvalErrKind {}
5252
/// Should be called only if the error is actually going to to be reported!
5353
pub fn error_to_const_error<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>>(
5454
ecx: &InterpCx<'mir, 'tcx, M>,
55-
mut error: InterpErrorInfo<'tcx>,
55+
error: InterpErrorInfo<'tcx>,
5656
) -> ConstEvalErr<'tcx> {
5757
error.print_backtrace();
5858
let stacktrace = ecx.generate_stacktrace();

src/librustc_mir/interpret/eval_context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use rustc_macros::HashStable;
1111
use rustc_middle::ich::StableHashingContext;
1212
use rustc_middle::mir;
1313
use rustc_middle::mir::interpret::{
14-
sign_extend, truncate, AllocId, FrameInfo, GlobalId, InterpResult, Pointer, Scalar,
14+
sign_extend, truncate, FrameInfo, GlobalId, InterpResult, Pointer, Scalar,
1515
};
1616
use rustc_middle::ty::layout::{self, TyAndLayout};
1717
use rustc_middle::ty::{
@@ -103,16 +103,16 @@ pub enum StackPopCleanup {
103103

104104
/// State of a local variable including a memoized layout
105105
#[derive(Clone, PartialEq, Eq, HashStable)]
106-
pub struct LocalState<'tcx, Tag = (), Id = AllocId> {
107-
pub value: LocalValue<Tag, Id>,
106+
pub struct LocalState<'tcx, Tag = ()> {
107+
pub value: LocalValue<Tag>,
108108
/// Don't modify if `Some`, this is only used to prevent computing the layout twice
109109
#[stable_hasher(ignore)]
110110
pub layout: Cell<Option<TyAndLayout<'tcx>>>,
111111
}
112112

113113
/// Current value of a local variable
114114
#[derive(Copy, Clone, PartialEq, Eq, Debug, HashStable)] // Miri debug-prints these
115-
pub enum LocalValue<Tag = (), Id = AllocId> {
115+
pub enum LocalValue<Tag = ()> {
116116
/// This local is not currently alive, and cannot be used at all.
117117
Dead,
118118
/// This local is alive but not yet initialized. It can be written to
@@ -125,7 +125,7 @@ pub enum LocalValue<Tag = (), Id = AllocId> {
125125
/// This is an optimization over just always having a pointer here;
126126
/// we can thus avoid doing an allocation when the local just stores
127127
/// immediate values *and* never has its address taken.
128-
Live(Operand<Tag, Id>),
128+
Live(Operand<Tag>),
129129
}
130130

131131
impl<'tcx, Tag: Copy + 'static> LocalState<'tcx, Tag> {

src/librustc_mir/interpret/operand.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use rustc_target::abi::{Abi, DiscriminantKind, HasDataLayout, Integer, LayoutOf,
1515
use rustc_target::abi::{VariantIdx, Variants};
1616

1717
use super::{
18-
from_known_layout, sign_extend, truncate, AllocId, ConstValue, GlobalId, InterpCx,
19-
InterpResult, MPlaceTy, Machine, MemPlace, Place, PlaceTy, Pointer, Scalar, ScalarMaybeUndef,
18+
from_known_layout, sign_extend, truncate, ConstValue, GlobalId, InterpCx, InterpResult,
19+
MPlaceTy, Machine, MemPlace, Place, PlaceTy, Pointer, Scalar, ScalarMaybeUndef,
2020
};
2121

2222
/// An `Immediate` represents a single immediate self-contained Rust value.
@@ -27,9 +27,9 @@ use super::{
2727
/// In particular, thanks to `ScalarPair`, arithmetic operations and casts can be entirely
2828
/// defined on `Immediate`, and do not have to work with a `Place`.
2929
#[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, Hash)]
30-
pub enum Immediate<Tag = (), Id = AllocId> {
31-
Scalar(ScalarMaybeUndef<Tag, Id>),
32-
ScalarPair(ScalarMaybeUndef<Tag, Id>, ScalarMaybeUndef<Tag, Id>),
30+
pub enum Immediate<Tag = ()> {
31+
Scalar(ScalarMaybeUndef<Tag>),
32+
ScalarPair(ScalarMaybeUndef<Tag>, ScalarMaybeUndef<Tag>),
3333
}
3434

3535
impl<Tag> From<ScalarMaybeUndef<Tag>> for Immediate<Tag> {
@@ -145,9 +145,9 @@ impl<'tcx, Tag> ::std::ops::Deref for ImmTy<'tcx, Tag> {
145145
/// or still in memory. The latter is an optimization, to delay reading that chunk of
146146
/// memory and to avoid having to store arbitrary-sized data here.
147147
#[derive(Copy, Clone, Debug, PartialEq, Eq, HashStable, Hash)]
148-
pub enum Operand<Tag = (), Id = AllocId> {
149-
Immediate(Immediate<Tag, Id>),
150-
Indirect(MemPlace<Tag, Id>),
148+
pub enum Operand<Tag = ()> {
149+
Immediate(Immediate<Tag>),
150+
Indirect(MemPlace<Tag>),
151151
}
152152

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

src/librustc_mir/interpret/place.rs

+9-11
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ use super::{
2020

2121
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
2222
/// Information required for the sound usage of a `MemPlace`.
23-
pub enum MemPlaceMeta<Tag = (), Id = AllocId> {
23+
pub enum MemPlaceMeta<Tag = ()> {
2424
/// The unsized payload (e.g. length for slices or vtable pointer for trait objects).
25-
Meta(Scalar<Tag, Id>),
25+
Meta(Scalar<Tag>),
2626
/// `Sized` types or unsized `extern type`
2727
None,
2828
/// The address of this place may not be taken. This protects the `MemPlace` from coming from
@@ -32,8 +32,8 @@ pub enum MemPlaceMeta<Tag = (), Id = AllocId> {
3232
Poison,
3333
}
3434

35-
impl<Tag, Id> MemPlaceMeta<Tag, Id> {
36-
pub fn unwrap_meta(self) -> Scalar<Tag, Id> {
35+
impl<Tag> MemPlaceMeta<Tag> {
36+
pub fn unwrap_meta(self) -> Scalar<Tag> {
3737
match self {
3838
Self::Meta(s) => s,
3939
Self::None | Self::Poison => {
@@ -47,9 +47,7 @@ impl<Tag, Id> MemPlaceMeta<Tag, Id> {
4747
Self::None | Self::Poison => false,
4848
}
4949
}
50-
}
5150

52-
impl<Tag> MemPlaceMeta<Tag> {
5351
pub fn erase_tag(self) -> MemPlaceMeta<()> {
5452
match self {
5553
Self::Meta(s) => MemPlaceMeta::Meta(s.erase_tag()),
@@ -60,22 +58,22 @@ impl<Tag> MemPlaceMeta<Tag> {
6058
}
6159

6260
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
63-
pub struct MemPlace<Tag = (), Id = AllocId> {
61+
pub struct MemPlace<Tag = ()> {
6462
/// A place may have an integral pointer for ZSTs, and since it might
6563
/// be turned back into a reference before ever being dereferenced.
6664
/// However, it may never be undef.
67-
pub ptr: Scalar<Tag, Id>,
65+
pub ptr: Scalar<Tag>,
6866
pub align: Align,
6967
/// Metadata for unsized places. Interpretation is up to the type.
7068
/// Must not be present for sized types, but can be missing for unsized types
7169
/// (e.g., `extern type`).
72-
pub meta: MemPlaceMeta<Tag, Id>,
70+
pub meta: MemPlaceMeta<Tag>,
7371
}
7472

7573
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)]
76-
pub enum Place<Tag = (), Id = AllocId> {
74+
pub enum Place<Tag = ()> {
7775
/// A place referring to a value allocated in the `Memory` system.
78-
Ptr(MemPlace<Tag, Id>),
76+
Ptr(MemPlace<Tag>),
7977

8078
/// To support alloc-free locals, we are able to write directly to a local.
8179
/// (Without that optimization, we'd just always be a `MemPlace`.)

src/librustc_trait_selection/traits/util.rs

-1
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,6 @@ pub fn impl_trait_ref_and_oblig<'a, 'tcx>(
217217
(impl_trait_ref, impl_obligations)
218218
}
219219

220-
/// See [`super::obligations_for_generics`].
221220
pub fn predicates_for_generics<'tcx>(
222221
cause: ObligationCause<'tcx>,
223222
recursion_depth: usize,

src/test/ui/non-ice-error-on-worker-io-fail.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@
44
//
55
// An attempt to `-o` into a directory we cannot write into should indeed
66
// be an error; but not an ICE.
7+
//
8+
// However, some folks run tests as root, which can write `/dev/` and end
9+
// up clobbering `/dev/null`. Instead we'll use a non-existent path, which
10+
// also used to ICE, but even root can't magically write there.
711

8-
// compile-flags: -o /dev/null
12+
// compile-flags: -o /does-not-exist/output
913

1014
// The error-pattern check occurs *before* normalization, and the error patterns
1115
// are wildly different between build environments. So this is a cop-out (and we
@@ -15,10 +19,10 @@
1519
// error-pattern: error
1620

1721
// On Mac OS X, we get an error like the below
18-
// normalize-stderr-test "failed to write bytecode to /dev/null.non_ice_error_on_worker_io_fail.*" -> "io error modifying /dev/"
22+
// normalize-stderr-test "failed to write bytecode to /does-not-exist/output.non_ice_error_on_worker_io_fail.*" -> "io error modifying /does-not-exist/"
1923

2024
// On Linux, we get an error like the below
21-
// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /dev/"
25+
// normalize-stderr-test "couldn't create a temp dir.*" -> "io error modifying /does-not-exist/"
2226

2327
// ignore-tidy-linelength
2428
// ignore-windows - this is a unix-specific test
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
warning: ignoring --out-dir flag due to -o flag
22

3-
error: io error modifying /dev/
3+
error: io error modifying /does-not-exist/
44

55
error: aborting due to previous error; 1 warning emitted
66

0 commit comments

Comments
 (0)