Skip to content

Commit db98d32

Browse files
committed
Auto merge of #71644 - Dylan-DPC:rollup-cq7plwa, r=Dylan-DPC
Rollup of 5 pull requests Successful merges: - #71340 (Moving more build-pass tests to check-pass) - #71456 (Use lib crate type for SGX in `fn build_auxiliary`) - #71615 (share some common code for compile-time miri instances) - #71637 (Minor formatting changes in `cfg-sanitize.md`) - #71641 (Update books) Failed merges: r? @ghost
2 parents b7bd7c1 + b17ef86 commit db98d32

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+128
-168
lines changed

src/doc/book

Submodule book updated 33 files

src/doc/unstable-book/src/language-features/cfg-sanitize.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,24 @@ depending on whether a particular sanitizer is enabled or not.
1111

1212
## Examples
1313

14-
``` rust
14+
```rust
1515
#![feature(cfg_sanitize)]
1616

1717
#[cfg(sanitize = "thread")]
1818
fn a() {
19-
// ...
19+
// ...
2020
}
2121

2222
#[cfg(not(sanitize = "thread"))]
2323
fn a() {
24-
// ...
24+
// ...
2525
}
2626

2727
fn b() {
28-
if cfg!(sanitize = "leak") {
29-
// ...
30-
} else {
31-
// ...
32-
}
28+
if cfg!(sanitize = "leak") {
29+
// ...
30+
} else {
31+
// ...
32+
}
3333
}
34-
3534
```
36-

src/librustc_mir/const_eval/machine.rs

+4-56
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_middle::mir;
22
use rustc_middle::ty::layout::HasTyCtxt;
33
use rustc_middle::ty::{self, Ty};
4-
use std::borrow::{Borrow, Cow};
4+
use std::borrow::Borrow;
55
use std::collections::hash_map::Entry;
66
use std::hash::Hash;
77

@@ -13,8 +13,8 @@ use rustc_middle::mir::AssertMessage;
1313
use rustc_span::symbol::Symbol;
1414

1515
use crate::interpret::{
16-
self, AllocId, Allocation, Frame, GlobalId, ImmTy, InterpCx, InterpResult, Memory, MemoryKind,
17-
OpTy, PlaceTy, Pointer, Scalar,
16+
self, compile_time_machine, AllocId, Allocation, Frame, GlobalId, ImmTy, InterpCx,
17+
InterpResult, Memory, OpTy, PlaceTy, Pointer, Scalar,
1818
};
1919

2020
use super::error::*;
@@ -171,29 +171,9 @@ impl interpret::MayLeak for ! {
171171
}
172172

173173
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 'tcx> {
174-
type MemoryKind = !;
175-
type PointerTag = ();
176-
type ExtraFnVal = !;
174+
compile_time_machine!(<'mir, 'tcx>);
177175

178-
type FrameExtra = ();
179176
type MemoryExtra = MemoryExtra;
180-
type AllocExtra = ();
181-
182-
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
183-
184-
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
185-
186-
#[inline(always)]
187-
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
188-
// We do not check for alignment to avoid having to carry an `Align`
189-
// in `ConstValue::ByRef`.
190-
false
191-
}
192-
193-
#[inline(always)]
194-
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
195-
false // for now, we don't enforce validity
196-
}
197177

198178
fn find_mir_or_eval_fn(
199179
ecx: &mut InterpCx<'mir, 'tcx, Self>,
@@ -241,16 +221,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
241221
}))
242222
}
243223

244-
fn call_extra_fn(
245-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
246-
fn_val: !,
247-
_args: &[OpTy<'tcx>],
248-
_ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>,
249-
_unwind: Option<mir::BasicBlock>,
250-
) -> InterpResult<'tcx> {
251-
match fn_val {}
252-
}
253-
254224
fn call_intrinsic(
255225
ecx: &mut InterpCx<'mir, 'tcx, Self>,
256226
instance: ty::Instance<'tcx>,
@@ -310,20 +280,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
310280
Err(ConstEvalErrKind::NeedsRfc("pointer arithmetic or comparison".to_string()).into())
311281
}
312282

313-
#[inline(always)]
314-
fn init_allocation_extra<'b>(
315-
_memory_extra: &MemoryExtra,
316-
_id: AllocId,
317-
alloc: Cow<'b, Allocation>,
318-
_kind: Option<MemoryKind<!>>,
319-
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
320-
// We do not use a tag so we can just cheaply forward the allocation
321-
(alloc, ())
322-
}
323-
324-
#[inline(always)]
325-
fn tag_global_base_pointer(_memory_extra: &MemoryExtra, _id: AllocId) -> Self::PointerTag {}
326-
327283
fn box_alloc(
328284
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
329285
_dest: PlaceTy<'tcx>,
@@ -345,14 +301,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
345301
Ok(())
346302
}
347303

348-
#[inline(always)]
349-
fn init_frame_extra(
350-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
351-
frame: Frame<'mir, 'tcx>,
352-
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
353-
Ok(frame)
354-
}
355-
356304
#[inline(always)]
357305
fn stack(
358306
ecx: &'a InterpCx<'mir, 'tcx, Self>,

src/librustc_mir/interpret/machine.rs

+64
Original file line numberDiff line numberDiff line change
@@ -357,3 +357,67 @@ pub trait Machine<'mir, 'tcx>: Sized {
357357
_ptr: Pointer<Self::PointerTag>,
358358
) -> InterpResult<'tcx, u64>;
359359
}
360+
361+
// A lot of the flexibility above is just needed for `Miri`, but all "compile-time" machines
362+
// (CTFE and ConstProp) use the same instance. Here, we share that code.
363+
pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
364+
type PointerTag = ();
365+
type ExtraFnVal = !;
366+
367+
type MemoryKind = !;
368+
type MemoryMap = rustc_data_structures::fx::FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
369+
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
370+
371+
type AllocExtra = ();
372+
type FrameExtra = ();
373+
374+
#[inline(always)]
375+
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
376+
// We do not check for alignment to avoid having to carry an `Align`
377+
// in `ConstValue::ByRef`.
378+
false
379+
}
380+
381+
#[inline(always)]
382+
fn enforce_validity(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
383+
false // for now, we don't enforce validity
384+
}
385+
386+
#[inline(always)]
387+
fn call_extra_fn(
388+
_ecx: &mut InterpCx<$mir, $tcx, Self>,
389+
fn_val: !,
390+
_args: &[OpTy<$tcx>],
391+
_ret: Option<(PlaceTy<$tcx>, mir::BasicBlock)>,
392+
_unwind: Option<mir::BasicBlock>,
393+
) -> InterpResult<$tcx> {
394+
match fn_val {}
395+
}
396+
397+
#[inline(always)]
398+
fn init_allocation_extra<'b>(
399+
_memory_extra: &Self::MemoryExtra,
400+
_id: AllocId,
401+
alloc: Cow<'b, Allocation>,
402+
_kind: Option<MemoryKind<!>>,
403+
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
404+
// We do not use a tag so we can just cheaply forward the allocation
405+
(alloc, ())
406+
}
407+
408+
#[inline(always)]
409+
fn tag_global_base_pointer(
410+
_memory_extra: &Self::MemoryExtra,
411+
_id: AllocId,
412+
) -> Self::PointerTag {
413+
()
414+
}
415+
416+
#[inline(always)]
417+
fn init_frame_extra(
418+
_ecx: &mut InterpCx<$mir, $tcx, Self>,
419+
frame: Frame<$mir, $tcx>,
420+
) -> InterpResult<$tcx, Frame<$mir, $tcx>> {
421+
Ok(frame)
422+
}
423+
}

src/librustc_mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in
1919

2020
pub use self::eval_context::{Frame, InterpCx, LocalState, LocalValue, StackPopCleanup};
2121
pub use self::intern::{intern_const_alloc_recursive, InternKind};
22-
pub use self::machine::{AllocMap, Machine, MayLeak, StackPopJump};
22+
pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump};
2323
pub use self::memory::{AllocCheck, FnVal, Memory, MemoryKind};
2424
pub use self::operand::{ImmTy, Immediate, OpTy, Operand};
2525
pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy};

src/librustc_mir/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Rust MIR: a lowered representation of Rust.
1313
#![feature(const_fn)]
1414
#![feature(const_panic)]
1515
#![feature(crate_visibility_modifier)]
16+
#![feature(decl_macro)]
1617
#![feature(drain_filter)]
1718
#![feature(exhaustive_patterns)]
1819
#![feature(iter_order_by)]

src/librustc_mir/transform/const_prop.rs

+4-56
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
//! Propagates constants for early reporting of statically known
22
//! assertion failures
33
4-
use std::borrow::Cow;
54
use std::cell::Cell;
65

76
use rustc_ast::ast::Mutability;
8-
use rustc_data_structures::fx::FxHashMap;
97
use rustc_hir::def::DefKind;
108
use rustc_hir::HirId;
119
use rustc_index::bit_set::BitSet;
@@ -29,9 +27,9 @@ use rustc_trait_selection::traits;
2927

3028
use crate::const_eval::error_to_const_error;
3129
use crate::interpret::{
32-
self, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, Immediate, InternKind,
33-
InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy,
34-
Pointer, ScalarMaybeUndef, StackPopCleanup,
30+
self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy,
31+
Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy,
32+
Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUndef, StackPopCleanup,
3533
};
3634
use crate::transform::{MirPass, MirSource};
3735

@@ -162,27 +160,9 @@ impl<'mir, 'tcx> ConstPropMachine<'mir, 'tcx> {
162160
}
163161

164162
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> {
165-
type MemoryKind = !;
166-
type PointerTag = ();
167-
type ExtraFnVal = !;
163+
compile_time_machine!(<'mir, 'tcx>);
168164

169-
type FrameExtra = ();
170165
type MemoryExtra = ();
171-
type AllocExtra = ();
172-
173-
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
174-
175-
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
176-
177-
#[inline(always)]
178-
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
179-
false
180-
}
181-
182-
#[inline(always)]
183-
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
184-
false
185-
}
186166

187167
fn find_mir_or_eval_fn(
188168
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
@@ -194,16 +174,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
194174
Ok(None)
195175
}
196176

197-
fn call_extra_fn(
198-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
199-
fn_val: !,
200-
_args: &[OpTy<'tcx>],
201-
_ret: Option<(PlaceTy<'tcx>, BasicBlock)>,
202-
_unwind: Option<BasicBlock>,
203-
) -> InterpResult<'tcx> {
204-
match fn_val {}
205-
}
206-
207177
fn call_intrinsic(
208178
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
209179
_instance: ty::Instance<'tcx>,
@@ -236,20 +206,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
236206
throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp")
237207
}
238208

239-
#[inline(always)]
240-
fn init_allocation_extra<'b>(
241-
_memory_extra: &(),
242-
_id: AllocId,
243-
alloc: Cow<'b, Allocation>,
244-
_kind: Option<MemoryKind<!>>,
245-
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
246-
// We do not use a tag so we can just cheaply forward the allocation
247-
(alloc, ())
248-
}
249-
250-
#[inline(always)]
251-
fn tag_global_base_pointer(_memory_extra: &(), _id: AllocId) -> Self::PointerTag {}
252-
253209
fn box_alloc(
254210
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
255211
_dest: PlaceTy<'tcx>,
@@ -290,14 +246,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
290246
Ok(())
291247
}
292248

293-
#[inline(always)]
294-
fn init_frame_extra(
295-
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
296-
frame: Frame<'mir, 'tcx>,
297-
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
298-
Ok(frame)
299-
}
300-
301249
#[inline(always)]
302250
fn stack(
303251
ecx: &'a InterpCx<'mir, 'tcx, Self>,

src/test/incremental/warnings-reemitted.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// revisions: cfail1 cfail2 cfail3
22
// compile-flags: -Coverflow-checks=on
3-
// build-pass (FIXME(62277): could be check-pass?)
3+
// build-pass
44

55
#![warn(arithmetic_overflow)]
66

src/test/ui/anon-params/anon-params-deprecated.fixed

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![warn(anonymous_parameters)]
22
// Test for the anonymous_parameters deprecation lint (RFC 1685)
33

4-
// build-pass (FIXME(62277): could be check-pass?)
4+
// check-pass
55
// edition:2015
66
// run-rustfix
77

src/test/ui/anon-params/anon-params-deprecated.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#![warn(anonymous_parameters)]
22
// Test for the anonymous_parameters deprecation lint (RFC 1685)
33

4-
// build-pass (FIXME(62277): could be check-pass?)
4+
// check-pass
55
// edition:2015
66
// run-rustfix
77

src/test/ui/async-await/issues/issue-55324.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build-pass (FIXME(62277): could be check-pass?)
1+
// check-pass
22
// edition:2018
33

44
use std::future::Future;

src/test/ui/async-await/issues/issue-58885.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build-pass (FIXME(62277): could be check-pass?)
1+
// check-pass
22
// edition:2018
33

44
struct Xyz {

src/test/ui/async-await/issues/issue-59001.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// build-pass (FIXME(62277): could be check-pass?)
1+
// check-pass
22
// edition:2018
33

44
use std::future::Future;

src/test/ui/async-await/issues/issue-60655-latebound-regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test that opaque `impl Trait` types are allowed to contain late-bound regions.
22

3-
// build-pass (FIXME(62277): could be check-pass?)
3+
// check-pass
44
// edition:2018
55

66
#![feature(type_alias_impl_trait)]

0 commit comments

Comments
 (0)