Skip to content
Merged
2 changes: 1 addition & 1 deletion src/doc/book
Submodule book updated 33 files
+1 −1 listings/ch20-web-server/listing-20-02/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-03/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-04/src/main.rs
+6 −2 listings/ch20-web-server/listing-20-05/src/main.rs
+6 −2 listings/ch20-web-server/listing-20-06/src/main.rs
+6 −2 listings/ch20-web-server/listing-20-07/src/main.rs
+6 −2 listings/ch20-web-server/listing-20-08/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-09/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-10/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-11/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-12/src/main.rs
+1 −1 listings/ch20-web-server/listing-20-13/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-14/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-15/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-16/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-17/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-18/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-19/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-20/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-21/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-22/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-23/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-24/src/bin/main.rs
+1 −1 listings/ch20-web-server/listing-20-25/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-01-define-threadpool-struct/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-02-impl-threadpool-new/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-03-define-execute/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-04-update-worker-definition/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-05-fix-worker-new/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-06-fix-threadpool-drop/src/bin/main.rs
+1 −1 listings/ch20-web-server/no-listing-07-define-message-enum/src/bin/main.rs
+2 −2 src/appendix-02-operators.md
+2 −1 src/ch20-01-single-threaded.md
2 changes: 1 addition & 1 deletion src/doc/nomicon
18 changes: 8 additions & 10 deletions src/doc/unstable-book/src/language-features/cfg-sanitize.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// ...
}
}

```

60 changes: 4 additions & 56 deletions src/librustc_mir/const_eval/machine.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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::*;
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand All @@ -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>,
Expand Down
64 changes: 64 additions & 0 deletions src/librustc_mir/interpret/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 1 addition & 0 deletions src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
60 changes: 4 additions & 56 deletions src/librustc_mir/transform/const_prop.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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};

Expand Down Expand Up @@ -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>,
Expand All @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down Expand Up @@ -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>,
Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/warnings-reemitted.rs
Original file line number Diff line number Diff line change
@@ -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)]

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/anon-params/anon-params-deprecated.fixed
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/anon-params/anon-params-deprecated.rs
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-55324.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018

use std::future::Future;
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-58885.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018

struct Xyz {
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/async-await/issues/issue-59001.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// build-pass (FIXME(62277): could be check-pass?)
// check-pass
// edition:2018

use std::future::Future;
Expand Down
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
Loading