Skip to content

Commit

Permalink
Auto merge of #62902 - Mark-Simulacrum:rollup-mxfk0mm, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Rollup of 14 pull requests

Successful merges:

 - #60951 (more specific errors in src/librustc/mir/interpret/error.rs)
 - #62523 (Delay bug to resolve HRTB ICE)
 - #62656 (explain how to search in slice without owned data)
 - #62791 (Handle more cases of typos misinterpreted as type ascription)
 - #62804 (rustc_typeck: improve diagnostics for _ const/static declarations)
 - #62808 (Revert "Disable stack probing for gnux32.")
 - #62817 (Tweak span for variant not found error)
 - #62842 (Add tests for issue-58887)
 - #62851 (move unescape module to rustc_lexer)
 - #62859 (Place::as_place_ref is now Place::as_ref)
 - #62869 (add rustc_private as a proper language feature gate)
 - #62880 (normalize use of backticks in compiler messages for librustc_allocator)
 - #62885 (Change "OSX" to "macOS")
 - #62889 (Update stage0.txt)

Failed merges:

r? @ghost
  • Loading branch information
bors committed Jul 23, 2019
2 parents 299ef86 + c939db7 commit a7f2867
Show file tree
Hide file tree
Showing 97 changed files with 777 additions and 377 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,11 @@ fetch snapshots, and an OS that can execute the available snapshot binaries.
Snapshot binaries are currently built and tested on several platforms:
| Platform / Architecture | x86 | x86_64 |
|--------------------------|-----|--------|
| Windows (7, 8, 10, ...) | ✓ | ✓ |
| Linux (2.6.18 or later) | ✓ | ✓ |
| OSX (10.7 Lion or later) | ✓ | ✓ |
| Platform / Architecture | x86 | x86_64 |
|----------------------------|-----|--------|
| Windows (7, 8, 10, ...) | ✓ | ✓ |
| Linux (2.6.18 or later) | ✓ | ✓ |
| macOS (10.7 Lion or later) | ✓ | ✓ |
You may find that other platforms work, but these are our officially
supported build environments that are most likely to work.
Expand Down
19 changes: 12 additions & 7 deletions src/libcore/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,12 @@ impl char {
/// 'XID_Start' is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
#[unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812")]
#[inline]
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
pub fn is_xid_start(self) -> bool {
derived_property::XID_Start(self)
}
Expand All @@ -567,9 +569,12 @@ impl char {
/// 'XID_Continue' is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
#[unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812")]
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
#[inline]
pub fn is_xid_continue(self) -> bool {
derived_property::XID_Continue(self)
Expand Down
9 changes: 9 additions & 0 deletions src/libcore/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,15 @@ impl<T> [T] {
/// assert!(v.contains(&30));
/// assert!(!v.contains(&50));
/// ```
///
/// If you do not have an `&T`, but just an `&U` such that `T: Borrow<U>`
/// (e.g. `String: Borrow<str>`), you can use `iter().any`:
///
/// ```
/// let v = [String::from("hello"), String::from("world")]; // slice of `String`
/// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
/// assert!(!v.iter().any(|e| e == "hi"));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn contains(&self, x: &T) -> bool
where T: PartialEq
Expand Down
1 change: 1 addition & 0 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#![feature(nll)]
#![feature(rustc_private)]
#![feature(unicode_internals)]

pub use Piece::*;
pub use Position::*;
Expand Down
19 changes: 10 additions & 9 deletions src/librustc/infer/lexical_region_resolve/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,17 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
}
}

span_bug!(
// Errors in earlier passes can yield error variables without
// resolution errors here; delay ICE in favor of those errors.
self.tcx().sess.delay_span_bug(
self.var_infos[node_idx].origin.span(),
"collect_error_for_expanding_node() could not find \
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
upper_bounds={:#?}",
node_idx,
node_universe,
lower_bounds,
upper_bounds
);
&format!("collect_error_for_expanding_node() could not find \
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
upper_bounds={:#?}",
node_idx,
node_universe,
lower_bounds,
upper_bounds));
}

fn collect_concrete_regions(
Expand Down
75 changes: 47 additions & 28 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,24 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {

pub type AssertMessage<'tcx> = InterpError<'tcx, mir::Operand<'tcx>>;

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum PanicMessage<O> {
Panic {
msg: Symbol,
line: u32,
col: u32,
file: Symbol,
},
BoundsCheck {
len: O,
index: O,
},
Overflow(mir::BinOp),
OverflowNeg,
DivisionByZero,
RemainderByZero,
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum InterpError<'tcx, O> {
/// This variant is used by machines to signal their own errors that do not
Expand Down Expand Up @@ -266,11 +284,6 @@ pub enum InterpError<'tcx, O> {
Unimplemented(String),
DerefFunctionPointer,
ExecuteMemory,
BoundsCheck { len: O, index: O },
Overflow(mir::BinOp),
OverflowNeg,
DivisionByZero,
RemainderByZero,
Intrinsic(String),
InvalidChar(u128),
StackFrameLimitReached,
Expand Down Expand Up @@ -298,12 +311,7 @@ pub enum InterpError<'tcx, O> {
HeapAllocZeroBytes,
HeapAllocNonPowerOfTwoAlignment(u64),
Unreachable,
Panic {
msg: Symbol,
line: u32,
col: u32,
file: Symbol,
},
Panic(PanicMessage<O>),
ReadFromReturnPointer,
PathNotFound(Vec<String>),
UnimplementedTraitSelection,
Expand Down Expand Up @@ -369,8 +377,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
"tried to dereference a function pointer",
ExecuteMemory =>
"tried to treat a memory pointer as a function pointer",
BoundsCheck{..} =>
"array index out of bounds",
Intrinsic(..) =>
"intrinsic failed",
NoMirFor(..) =>
Expand Down Expand Up @@ -422,8 +428,32 @@ impl<'tcx, O> InterpError<'tcx, O> {
two",
Unreachable =>
"entered unreachable code",
Panic { .. } =>
Panic(PanicMessage::Panic{..}) =>
"the evaluated program panicked",
Panic(PanicMessage::BoundsCheck{..}) =>
"array index out of bounds",
Panic(PanicMessage::Overflow(mir::BinOp::Add)) =>
"attempt to add with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Sub)) =>
"attempt to subtract with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Mul)) =>
"attempt to multiply with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Div)) =>
"attempt to divide with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Rem)) =>
"attempt to calculate the remainder with overflow",
Panic(PanicMessage::OverflowNeg) =>
"attempt to negate with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Shr)) =>
"attempt to shift right with overflow",
Panic(PanicMessage::Overflow(mir::BinOp::Shl)) =>
"attempt to shift left with overflow",
Panic(PanicMessage::Overflow(op)) =>
bug!("{:?} cannot overflow", op),
Panic(PanicMessage::DivisionByZero) =>
"attempt to divide by zero",
Panic(PanicMessage::RemainderByZero) =>
"attempt to calculate the remainder with a divisor of zero",
ReadFromReturnPointer =>
"tried to read from the return pointer",
PathNotFound(_) =>
Expand All @@ -436,17 +466,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
"encountered overly generic constant",
ReferencedConstant =>
"referenced constant has errors",
Overflow(mir::BinOp::Add) => "attempt to add with overflow",
Overflow(mir::BinOp::Sub) => "attempt to subtract with overflow",
Overflow(mir::BinOp::Mul) => "attempt to multiply with overflow",
Overflow(mir::BinOp::Div) => "attempt to divide with overflow",
Overflow(mir::BinOp::Rem) => "attempt to calculate the remainder with overflow",
OverflowNeg => "attempt to negate with overflow",
Overflow(mir::BinOp::Shr) => "attempt to shift right with overflow",
Overflow(mir::BinOp::Shl) => "attempt to shift left with overflow",
Overflow(op) => bug!("{:?} cannot overflow", op),
DivisionByZero => "attempt to divide by zero",
RemainderByZero => "attempt to calculate the remainder with a divisor of zero",
GeneratorResumedAfterReturn => "generator resumed after completion",
GeneratorResumedAfterPanic => "generator resumed after panicking",
InfiniteLoop =>
Expand Down Expand Up @@ -493,8 +512,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
callee_ty, caller_ty),
FunctionArgCountMismatch =>
write!(f, "tried to call a function with incorrect number of arguments"),
BoundsCheck { ref len, ref index } =>
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
ReallocatedWrongMemoryKind(ref old, ref new) =>
write!(f, "tried to reallocate memory from {} to {}", old, new),
DeallocatedWrongMemoryKind(ref old, ref new) =>
Expand All @@ -518,8 +535,10 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
write!(f, "incorrect alloc info: expected size {} and align {}, \
got size {} and align {}",
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
Panic { ref msg, line, col, ref file } =>
Panic(PanicMessage::Panic { ref msg, line, col, ref file }) =>
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
Panic(PanicMessage::BoundsCheck { ref len, ref index }) =>
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
InvalidDiscriminant(val) =>
write!(f, "encountered invalid enum discriminant {}", val),
Exit(code) =>
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod pointer;

pub use self::error::{
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicMessage
};

pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/mir/interpret/pointer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ty::layout::{self, HasDataLayout, Size};
use rustc_macros::HashStable;

use super::{
AllocId, InterpResult,
AllocId, InterpResult, PanicMessage
};

/// Used by `check_in_alloc` to indicate context of check
Expand Down Expand Up @@ -76,13 +76,13 @@ pub trait PointerArithmetic: layout::HasDataLayout {
#[inline]
fn offset<'tcx>(&self, val: u64, i: u64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_offset(val, i);
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
}

#[inline]
fn signed_offset<'tcx>(&self, val: u64, i: i64) -> InterpResult<'tcx, u64> {
let (res, over) = self.overflowing_signed_offset(val, i128::from(i));
if over { err!(Overflow(mir::BinOp::Add)) } else { Ok(res) }
if over { err!(Panic(PanicMessage::Overflow(mir::BinOp::Add))) } else { Ok(res) }
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/librustc/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use crate::hir::def::{CtorKind, Namespace};
use crate::hir::def_id::DefId;
use crate::hir::{self, InlineAsm as HirInlineAsm};
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
use crate::mir::interpret::{ConstValue, PanicMessage, InterpError::Panic, Scalar};
use crate::mir::visit::MirVisitable;
use crate::rustc_serialize as serialize;
use crate::ty::adjustment::PointerCast;
Expand Down Expand Up @@ -1931,7 +1931,7 @@ impl<'tcx> Place<'tcx> {
iterate_over2(place_base, place_projection, &Projections::Empty, op)
}

pub fn as_place_ref(&self) -> PlaceRef<'_, 'tcx> {
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
PlaceRef {
base: &self.base,
projection: &self.projection,
Expand Down Expand Up @@ -3152,11 +3152,11 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
}
}
Assert { ref cond, expected, ref msg, target, cleanup } => {
let msg = if let InterpError::BoundsCheck { ref len, ref index } = *msg {
InterpError::BoundsCheck {
let msg = if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
Panic(PanicMessage::BoundsCheck {
len: len.fold_with(folder),
index: index.fold_with(folder),
}
})
} else {
msg.clone()
};
Expand Down Expand Up @@ -3197,7 +3197,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
}
Assert { ref cond, ref msg, .. } => {
if cond.visit_with(visitor) {
if let InterpError::BoundsCheck { ref len, ref index } = *msg {
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
len.visit_with(visitor) || index.visit_with(visitor)
} else {
false
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,8 @@ macro_rules! make_mir_visitor {
msg: & $($mutability)? AssertMessage<'tcx>,
location: Location) {
use crate::mir::interpret::InterpError::*;
if let BoundsCheck { len, index } = msg {
use crate::mir::interpret::PanicMessage::BoundsCheck;
if let Panic(BoundsCheck { len, index }) = msg {
self.visit_operand(len, location);
self.visit_operand(index, location);
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_allocator/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> {

if self.found {
self.handler
.span_err(item.span, "cannot define more than one #[global_allocator]");
.span_err(item.span, "cannot define more than one `#[global_allocator]`");
return smallvec![item];
}
self.found = true;
Expand Down Expand Up @@ -280,7 +280,7 @@ impl AllocFnFactory<'_> {
AllocatorTy::Unit => (self.cx.ty(self.span, TyKind::Tup(Vec::new())), expr),

AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => {
panic!("can't convert AllocatorTy to an output")
panic!("can't convert `AllocatorTy` to an output")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_ssa/mir/analyze.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
context: PlaceContext,
location: Location) {
debug!("visit_place(place={:?}, context={:?})", place, context);
self.process_place(&place.as_place_ref(), context, location);
self.process_place(&place.as_ref(), context, location);
}

fn visit_local(&mut self,
Expand Down
Loading

0 comments on commit a7f2867

Please sign in to comment.