Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 14 pull requests #62902

Merged
merged 40 commits into from
Jul 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
50840ee
Delay bug; this sidesteps ICE'ing when compiler is just doing error-r…
pnkfelix Jul 9, 2019
837fe7b
Regression test.
pnkfelix Jul 9, 2019
d73c23d
explain how to search without owned data
RalfJung Jul 13, 2019
3f77f2c
better comments
RalfJung Jul 14, 2019
589f6a7
tries to refactor InterpError in mir
saleemjaffer Jul 18, 2019
469b7a9
rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 18, 2019
c6735a6
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
10d4159
Revert "Disable stack probing for gnux32."
crlf0710 Jul 19, 2019
f5b2859
Handle more cases of typos misinterpreted as type ascription
estebank Jul 17, 2019
9dbe2e7
review comments
estebank Jul 19, 2019
b361864
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
c6e027d
fixup! rustc_typeck: improve diagnostics for _ const/static declarations
lundibundi Jul 19, 2019
2641bed
Tweak span for variant not found error
estebank Jul 20, 2019
fd352b0
alters the panic variant of InterpError
saleemjaffer Jul 20, 2019
18dceab
Add tests for issue-58887
JohnTitor Jul 21, 2019
e63fe15
move unescape module to rustc_lexer
matklad Jul 21, 2019
e75ae15
Move into existential-type dir
JohnTitor Jul 21, 2019
795d96d
Place::as_place_ref is now Place::as_ref
spastorino Jul 21, 2019
27b703d
add rustc_private as a proper language feature gate
matklad Jul 22, 2019
1a7127b
normalize use of backticks in compiler messages for librustc_allocator
Jul 22, 2019
4e02a1f
Change "OSX" to "macOS"
atouchet Jul 22, 2019
1ed375c
Update stage0.txt
git-iso Jul 23, 2019
7e612c1
Update src/librustc_lexer/src/lib.rs
matklad Jul 23, 2019
90426ed
moving some variants from InterpError to EvalErrorPanic
saleemjaffer Jul 20, 2019
3730ed9
renames EvalErrorPanic to PanicMessage
saleemjaffer Jul 23, 2019
f48ee09
Update stage0.txt
git-iso Jul 23, 2019
52e9e44
Rollup merge of #60951 - saleemjaffer:mir_better_error_enum, r=oli-obk
Mark-Simulacrum Jul 23, 2019
ad57597
Rollup merge of #62523 - pnkfelix:delay-bug-to-resolve-issue-62203-ic…
Mark-Simulacrum Jul 23, 2019
4264f83
Rollup merge of #62656 - RalfJung:contains-no-own, r=Dylan-DPC
Mark-Simulacrum Jul 23, 2019
ab7149b
Rollup merge of #62791 - estebank:type-ascription, r=petrochenkov
Mark-Simulacrum Jul 23, 2019
13775d2
Rollup merge of #62804 - lundibundi:help-infer-const-static, r=eddyb
Mark-Simulacrum Jul 23, 2019
66c2965
Rollup merge of #62808 - crlf0710:gnux32_stack_probe, r=nikic
Mark-Simulacrum Jul 23, 2019
24a8065
Rollup merge of #62817 - estebank:variant-sp, r=matthewjasper
Mark-Simulacrum Jul 23, 2019
8afc53c
Rollup merge of #62842 - JohnTitor:test-for-58887, r=alexreg
Mark-Simulacrum Jul 23, 2019
4cb3586
Rollup merge of #62851 - matklad:unescape, r=petrochenkov
Mark-Simulacrum Jul 23, 2019
b2155dd
Rollup merge of #62859 - spastorino:rename-to-as-ref, r=Centril
Mark-Simulacrum Jul 23, 2019
f11ffd3
Rollup merge of #62869 - matklad:feature-gate, r=Mark-Simulacrum
Mark-Simulacrum Jul 23, 2019
32e5f98
Rollup merge of #62880 - fakenine:normalize_use_of_backticks_compiler…
Mark-Simulacrum Jul 23, 2019
f1b267b
Rollup merge of #62885 - atouchet:macos, r=alexcrichton
Mark-Simulacrum Jul 23, 2019
c939db7
Rollup merge of #62889 - git-iso:patch-1, r=jonas-schievink
Mark-Simulacrum Jul 23, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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