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
This commit is contained in:
bors 2020-04-28 15:56:45 +00:00
commit db98d32ea0
52 changed files with 128 additions and 168 deletions

@ -1 +1 @@
Subproject commit f5db319e0b19c22964398d56bc63103d669e1bba
Subproject commit e37c0e84e2ef73d3a4ebffda8011db6814a3b02d

@ -1 +1 @@
Subproject commit 668fb07b6160b9c468f598e839c1e044db65de30
Subproject commit 40beccdf1bb8eb9184a2e3b42db8b8c6e394247f

@ -1 +1 @@
Subproject commit 6eb24d6e9c0773d4aee68ed5fca121ce3cdf676a
Subproject commit 4d2d275997746d35eabfc4d992dfbdcce2f626ed

@ -1 +1 @@
Subproject commit 3ce94caed4cf967106c51ae86be5e098f7875f11
Subproject commit ed22e6fbfcb6ce436e9ea3b4bb4a55b2fb50a57e

@ -1 +1 @@
Subproject commit c106d1683c3a2b0960f0f0fb01728cbb19807332
Subproject commit ffc99581689fe2455908aaef5f5cf50dd03bb8f5

View File

@ -11,26 +11,24 @@ depending on whether a particular sanitizer is enabled or not.
## Examples
``` rust
```rust
#![feature(cfg_sanitize)]
#[cfg(sanitize = "thread")]
fn a() {
// ...
// ...
}
#[cfg(not(sanitize = "thread"))]
fn a() {
// ...
// ...
}
fn b() {
if cfg!(sanitize = "leak") {
// ...
} else {
// ...
}
if cfg!(sanitize = "leak") {
// ...
} else {
// ...
}
}
```

View File

@ -1,7 +1,7 @@
use rustc_middle::mir;
use rustc_middle::ty::layout::HasTyCtxt;
use rustc_middle::ty::{self, Ty};
use std::borrow::{Borrow, Cow};
use std::borrow::Borrow;
use std::collections::hash_map::Entry;
use std::hash::Hash;
@ -13,8 +13,8 @@ use rustc_middle::mir::AssertMessage;
use rustc_span::symbol::Symbol;
use crate::interpret::{
self, AllocId, Allocation, Frame, GlobalId, ImmTy, InterpCx, InterpResult, Memory, MemoryKind,
OpTy, PlaceTy, Pointer, Scalar,
self, compile_time_machine, AllocId, Allocation, Frame, GlobalId, ImmTy, InterpCx,
InterpResult, Memory, OpTy, PlaceTy, Pointer, Scalar,
};
use super::error::*;
@ -171,29 +171,9 @@ impl interpret::MayLeak for ! {
}
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir, 'tcx> {
type MemoryKind = !;
type PointerTag = ();
type ExtraFnVal = !;
compile_time_machine!(<'mir, 'tcx>);
type FrameExtra = ();
type MemoryExtra = MemoryExtra;
type AllocExtra = ();
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
#[inline(always)]
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
// We do not check for alignment to avoid having to carry an `Align`
// in `ConstValue::ByRef`.
false
}
#[inline(always)]
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
false // for now, we don't enforce validity
}
fn find_mir_or_eval_fn(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
@ -241,16 +221,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
}))
}
fn call_extra_fn(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
fn_val: !,
_args: &[OpTy<'tcx>],
_ret: Option<(PlaceTy<'tcx>, mir::BasicBlock)>,
_unwind: Option<mir::BasicBlock>,
) -> InterpResult<'tcx> {
match fn_val {}
}
fn call_intrinsic(
ecx: &mut InterpCx<'mir, 'tcx, Self>,
instance: ty::Instance<'tcx>,
@ -310,20 +280,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
Err(ConstEvalErrKind::NeedsRfc("pointer arithmetic or comparison".to_string()).into())
}
#[inline(always)]
fn init_allocation_extra<'b>(
_memory_extra: &MemoryExtra,
_id: AllocId,
alloc: Cow<'b, Allocation>,
_kind: Option<MemoryKind<!>>,
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
// We do not use a tag so we can just cheaply forward the allocation
(alloc, ())
}
#[inline(always)]
fn tag_global_base_pointer(_memory_extra: &MemoryExtra, _id: AllocId) -> Self::PointerTag {}
fn box_alloc(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_dest: PlaceTy<'tcx>,
@ -345,14 +301,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for CompileTimeInterpreter<'mir,
Ok(())
}
#[inline(always)]
fn init_frame_extra(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
frame: Frame<'mir, 'tcx>,
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
Ok(frame)
}
#[inline(always)]
fn stack(
ecx: &'a InterpCx<'mir, 'tcx, Self>,

View File

@ -357,3 +357,67 @@ pub trait Machine<'mir, 'tcx>: Sized {
_ptr: Pointer<Self::PointerTag>,
) -> InterpResult<'tcx, u64>;
}
// A lot of the flexibility above is just needed for `Miri`, but all "compile-time" machines
// (CTFE and ConstProp) use the same instance. Here, we share that code.
pub macro compile_time_machine(<$mir: lifetime, $tcx: lifetime>) {
type PointerTag = ();
type ExtraFnVal = !;
type MemoryKind = !;
type MemoryMap = rustc_data_structures::fx::FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
type AllocExtra = ();
type FrameExtra = ();
#[inline(always)]
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
// We do not check for alignment to avoid having to carry an `Align`
// in `ConstValue::ByRef`.
false
}
#[inline(always)]
fn enforce_validity(_ecx: &InterpCx<$mir, $tcx, Self>) -> bool {
false // for now, we don't enforce validity
}
#[inline(always)]
fn call_extra_fn(
_ecx: &mut InterpCx<$mir, $tcx, Self>,
fn_val: !,
_args: &[OpTy<$tcx>],
_ret: Option<(PlaceTy<$tcx>, mir::BasicBlock)>,
_unwind: Option<mir::BasicBlock>,
) -> InterpResult<$tcx> {
match fn_val {}
}
#[inline(always)]
fn init_allocation_extra<'b>(
_memory_extra: &Self::MemoryExtra,
_id: AllocId,
alloc: Cow<'b, Allocation>,
_kind: Option<MemoryKind<!>>,
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
// We do not use a tag so we can just cheaply forward the allocation
(alloc, ())
}
#[inline(always)]
fn tag_global_base_pointer(
_memory_extra: &Self::MemoryExtra,
_id: AllocId,
) -> Self::PointerTag {
()
}
#[inline(always)]
fn init_frame_extra(
_ecx: &mut InterpCx<$mir, $tcx, Self>,
frame: Frame<$mir, $tcx>,
) -> InterpResult<$tcx, Frame<$mir, $tcx>> {
Ok(frame)
}
}

View File

@ -19,7 +19,7 @@ pub use rustc_middle::mir::interpret::*; // have all the `interpret` symbols in
pub use self::eval_context::{Frame, InterpCx, LocalState, LocalValue, StackPopCleanup};
pub use self::intern::{intern_const_alloc_recursive, InternKind};
pub use self::machine::{AllocMap, Machine, MayLeak, StackPopJump};
pub use self::machine::{compile_time_machine, AllocMap, Machine, MayLeak, StackPopJump};
pub use self::memory::{AllocCheck, FnVal, Memory, MemoryKind};
pub use self::operand::{ImmTy, Immediate, OpTy, Operand};
pub use self::place::{MPlaceTy, MemPlace, MemPlaceMeta, Place, PlaceTy};

View File

@ -13,6 +13,7 @@ Rust MIR: a lowered representation of Rust.
#![feature(const_fn)]
#![feature(const_panic)]
#![feature(crate_visibility_modifier)]
#![feature(decl_macro)]
#![feature(drain_filter)]
#![feature(exhaustive_patterns)]
#![feature(iter_order_by)]

View File

@ -1,11 +1,9 @@
//! Propagates constants for early reporting of statically known
//! assertion failures
use std::borrow::Cow;
use std::cell::Cell;
use rustc_ast::ast::Mutability;
use rustc_data_structures::fx::FxHashMap;
use rustc_hir::def::DefKind;
use rustc_hir::HirId;
use rustc_index::bit_set::BitSet;
@ -29,9 +27,9 @@ use rustc_trait_selection::traits;
use crate::const_eval::error_to_const_error;
use crate::interpret::{
self, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy, Immediate, InternKind,
InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy, Operand as InterpOperand, PlaceTy,
Pointer, ScalarMaybeUndef, StackPopCleanup,
self, compile_time_machine, intern_const_alloc_recursive, AllocId, Allocation, Frame, ImmTy,
Immediate, InternKind, InterpCx, LocalState, LocalValue, Memory, MemoryKind, OpTy,
Operand as InterpOperand, PlaceTy, Pointer, ScalarMaybeUndef, StackPopCleanup,
};
use crate::transform::{MirPass, MirSource};
@ -162,27 +160,9 @@ impl<'mir, 'tcx> ConstPropMachine<'mir, 'tcx> {
}
impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> {
type MemoryKind = !;
type PointerTag = ();
type ExtraFnVal = !;
compile_time_machine!(<'mir, 'tcx>);
type FrameExtra = ();
type MemoryExtra = ();
type AllocExtra = ();
type MemoryMap = FxHashMap<AllocId, (MemoryKind<!>, Allocation)>;
const GLOBAL_KIND: Option<!> = None; // no copying of globals from `tcx` to machine memory
#[inline(always)]
fn enforce_alignment(_memory_extra: &Self::MemoryExtra) -> bool {
false
}
#[inline(always)]
fn enforce_validity(_ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
false
}
fn find_mir_or_eval_fn(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
@ -194,16 +174,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
Ok(None)
}
fn call_extra_fn(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
fn_val: !,
_args: &[OpTy<'tcx>],
_ret: Option<(PlaceTy<'tcx>, BasicBlock)>,
_unwind: Option<BasicBlock>,
) -> InterpResult<'tcx> {
match fn_val {}
}
fn call_intrinsic(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_instance: ty::Instance<'tcx>,
@ -236,20 +206,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
throw_machine_stop_str!("pointer arithmetic or comparisons aren't supported in ConstProp")
}
#[inline(always)]
fn init_allocation_extra<'b>(
_memory_extra: &(),
_id: AllocId,
alloc: Cow<'b, Allocation>,
_kind: Option<MemoryKind<!>>,
) -> (Cow<'b, Allocation<Self::PointerTag>>, Self::PointerTag) {
// We do not use a tag so we can just cheaply forward the allocation
(alloc, ())
}
#[inline(always)]
fn tag_global_base_pointer(_memory_extra: &(), _id: AllocId) -> Self::PointerTag {}
fn box_alloc(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
_dest: PlaceTy<'tcx>,
@ -290,14 +246,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx>
Ok(())
}
#[inline(always)]
fn init_frame_extra(
_ecx: &mut InterpCx<'mir, 'tcx, Self>,
frame: Frame<'mir, 'tcx>,
) -> InterpResult<'tcx, Frame<'mir, 'tcx>> {
Ok(frame)
}
#[inline(always)]
fn stack(
ecx: &'a InterpCx<'mir, 'tcx, Self>,

View File

@ -1,6 +1,6 @@
// revisions: cfail1 cfail2 cfail3
// compile-flags: -Coverflow-checks=on
// build-pass (FIXME(62277): could be check-pass?)
// build-pass
#![warn(arithmetic_overflow)]

View File

@ -1,7 +1,7 @@
#![warn(anonymous_parameters)]
// Test for the anonymous_parameters deprecation lint (RFC 1685)
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2015
// run-rustfix

View File

@ -1,7 +1,7 @@
#![warn(anonymous_parameters)]
// Test for the anonymous_parameters deprecation lint (RFC 1685)
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2015
// run-rustfix

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018
use std::future::Future;

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018
struct Xyz {

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018
use std::future::Future;

View File

@ -1,6 +1,6 @@
// Test that opaque `impl Trait` types are allowed to contain late-bound regions.
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018
#![feature(type_alias_impl_trait)]

View File

@ -2,7 +2,7 @@
// for completeness since .rs files linked from .rc files support this
// notation to specify their module's attributes
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(rustc_attrs)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// Bastion of the Turbofish
// ------------------------

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
fn main() {
let s = "ZͨA͑ͦ͒͋ͤ͑̚L̄͑͋Ĝͨͥ̿͒̽̈́Oͥ͛ͭ!̏"; while true { break; } //~ WARNING while_true

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(const_generics)]
//~^ WARN the feature `const_generics` is incomplete and may cause the compiler to crash

View File

@ -1,5 +1,5 @@
// run-rustfix
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#[allow(deprecated, unused_imports)]
use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT};

View File

@ -1,5 +1,5 @@
// run-rustfix
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#[allow(deprecated, unused_imports)]
use std::sync::atomic::{AtomicIsize, ATOMIC_ISIZE_INIT};

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// compile-flags: -Wunused
// ensure there are no special warnings about uninhabited types

View File

@ -1,6 +1,6 @@
// aux-build:edition-extern-crate-allowed.rs
// edition:2015
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(rust_2018_idioms)]

View File

@ -1,5 +1,5 @@
// edition:2018
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(rust_2018_preview)]
//~^ WARN the feature `rust_2018_preview` is included in the Rust 2018 edition

View File

@ -1,5 +1,5 @@
// compile-flags:--emit=metadata --error-format=json --json artifacts
// build-pass (FIXME(62277): could be check-pass?)
// build-pass
// ignore-pass
// ^-- needed because `--pass check` does not emit the output needed.

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// This is a stub feature that doesn't control anything, so to make tidy happy,
// gate-test-test_2018_feature

View File

@ -1,2 +1,2 @@
// compile-flags: --explain E0591
// build-pass (FIXME(62277): could be check-pass?)
// check-pass

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(unused_must_use)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
fn macros() {
macro_rules! foo{

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// ignore-tidy-linelength

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// ignore-tidy-linelength

View File

@ -1,7 +1,7 @@
// Issue #21633: reject duplicate loop labels in function bodies.
// This is testing interaction between lifetime-params and labels.
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![allow(dead_code, unused_variables)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![allow(dead_code, unused_variables)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// compile-flags: -Wunused
// make sure write!() can't hide its unused Result

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
fn main() {
let _ = "Foo"_;

View File

@ -1,5 +1,5 @@
// aux-build:attributes-included.rs
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(unused)]

View File

@ -1,6 +1,6 @@
// aux-build:macro-use-warned-against.rs
// aux-build:macro-use-warned-against2.rs
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(macro_use_extern_crate, unused)]

View File

@ -1,6 +1,6 @@
// run-rustfix
// edition:2018
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate

View File

@ -1,6 +1,6 @@
// run-rustfix
// edition:2018
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// aux-build:remove-extern-crate.rs
// compile-flags:--extern remove_extern_crate

View File

@ -2,7 +2,7 @@
// edition:2015
// run-rustfix
// rustfix-only-machine-applicable
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(rust_2018_preview)]
#![warn(rust_2018_compatibility)]

View File

@ -2,7 +2,7 @@
// edition:2015
// run-rustfix
// rustfix-only-machine-applicable
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![feature(rust_2018_preview)]
#![warn(rust_2018_compatibility)]

View File

@ -1,5 +1,5 @@
// run-rustfix
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(rust_2018_compatibility)]

View File

@ -1,5 +1,5 @@
// run-rustfix
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(rust_2018_compatibility)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(unused)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
#![warn(unused)]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// compile-flags: --test
#[test]

View File

@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// aux-build:underscore-imports.rs
#![warn(unused_imports, unused_extern_crates)]

View File

@ -1750,6 +1750,7 @@ impl<'test> TestCx<'test> {
|| self.config.target.contains("wasm32")
|| self.config.target.contains("nvptx")
|| self.is_vxworks_pure_static()
|| self.config.target.contains("sgx")
{
// We primarily compile all auxiliary libraries as dynamic libraries
// to avoid code size bloat and large binaries as much as possible