Skip to content

Commit a7f2867

Browse files
committed
Auto merge of #62902 - Mark-Simulacrum:rollup-mxfk0mm, r=Mark-Simulacrum
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
2 parents 299ef86 + c939db7 commit a7f2867

File tree

97 files changed

+777
-377
lines changed

Some content is hidden

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

97 files changed

+777
-377
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,11 @@ fetch snapshots, and an OS that can execute the available snapshot binaries.
200200
201201
Snapshot binaries are currently built and tested on several platforms:
202202
203-
| Platform / Architecture | x86 | x86_64 |
204-
|--------------------------|-----|--------|
205-
| Windows (7, 8, 10, ...) | ✓ | ✓ |
206-
| Linux (2.6.18 or later) | ✓ | ✓ |
207-
| OSX (10.7 Lion or later) | ✓ | ✓ |
203+
| Platform / Architecture | x86 | x86_64 |
204+
|----------------------------|-----|--------|
205+
| Windows (7, 8, 10, ...) | ✓ | ✓ |
206+
| Linux (2.6.18 or later) | ✓ | ✓ |
207+
| macOS (10.7 Lion or later) | ✓ | ✓ |
208208
209209
You may find that other platforms work, but these are our officially
210210
supported build environments that are most likely to work.

src/libcore/char/methods.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,12 @@ impl char {
553553
/// 'XID_Start' is a Unicode Derived Property specified in
554554
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
555555
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
556-
#[unstable(feature = "rustc_private",
557-
reason = "mainly needed for compiler internals",
558-
issue = "27812")]
559-
#[inline]
556+
#[cfg_attr(bootstrap,
557+
unstable(feature = "rustc_private",
558+
reason = "mainly needed for compiler internals",
559+
issue = "27812"))]
560+
#[cfg_attr(not(bootstrap),
561+
unstable(feature = "unicode_internals", issue = "0"))]
560562
pub fn is_xid_start(self) -> bool {
561563
derived_property::XID_Start(self)
562564
}
@@ -567,9 +569,12 @@ impl char {
567569
/// 'XID_Continue' is a Unicode Derived Property specified in
568570
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
569571
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
570-
#[unstable(feature = "rustc_private",
571-
reason = "mainly needed for compiler internals",
572-
issue = "27812")]
572+
#[cfg_attr(bootstrap,
573+
unstable(feature = "rustc_private",
574+
reason = "mainly needed for compiler internals",
575+
issue = "27812"))]
576+
#[cfg_attr(not(bootstrap),
577+
unstable(feature = "unicode_internals", issue = "0"))]
573578
#[inline]
574579
pub fn is_xid_continue(self) -> bool {
575580
derived_property::XID_Continue(self)

src/libcore/slice/mod.rs

+9
Original file line numberDiff line numberDiff line change
@@ -1263,6 +1263,15 @@ impl<T> [T] {
12631263
/// assert!(v.contains(&30));
12641264
/// assert!(!v.contains(&50));
12651265
/// ```
1266+
///
1267+
/// If you do not have an `&T`, but just an `&U` such that `T: Borrow<U>`
1268+
/// (e.g. `String: Borrow<str>`), you can use `iter().any`:
1269+
///
1270+
/// ```
1271+
/// let v = [String::from("hello"), String::from("world")]; // slice of `String`
1272+
/// assert!(v.iter().any(|e| e == "hello")); // search with `&str`
1273+
/// assert!(!v.iter().any(|e| e == "hi"));
1274+
/// ```
12661275
#[stable(feature = "rust1", since = "1.0.0")]
12671276
pub fn contains(&self, x: &T) -> bool
12681277
where T: PartialEq

src/libfmt_macros/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#![feature(nll)]
1515
#![feature(rustc_private)]
16+
#![feature(unicode_internals)]
1617

1718
pub use Piece::*;
1819
pub use Position::*;

src/librustc/infer/lexical_region_resolve/mod.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -764,16 +764,17 @@ impl<'cx, 'tcx> LexicalResolver<'cx, 'tcx> {
764764
}
765765
}
766766

767-
span_bug!(
767+
// Errors in earlier passes can yield error variables without
768+
// resolution errors here; delay ICE in favor of those errors.
769+
self.tcx().sess.delay_span_bug(
768770
self.var_infos[node_idx].origin.span(),
769-
"collect_error_for_expanding_node() could not find \
770-
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
771-
upper_bounds={:#?}",
772-
node_idx,
773-
node_universe,
774-
lower_bounds,
775-
upper_bounds
776-
);
771+
&format!("collect_error_for_expanding_node() could not find \
772+
error for var {:?} in universe {:?}, lower_bounds={:#?}, \
773+
upper_bounds={:#?}",
774+
node_idx,
775+
node_universe,
776+
lower_bounds,
777+
upper_bounds));
777778
}
778779

779780
fn collect_concrete_regions(

src/librustc/mir/interpret/error.rs

+47-28
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,24 @@ impl<'tcx> From<InterpError<'tcx, u64>> for InterpErrorInfo<'tcx> {
228228

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

231+
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
232+
pub enum PanicMessage<O> {
233+
Panic {
234+
msg: Symbol,
235+
line: u32,
236+
col: u32,
237+
file: Symbol,
238+
},
239+
BoundsCheck {
240+
len: O,
241+
index: O,
242+
},
243+
Overflow(mir::BinOp),
244+
OverflowNeg,
245+
DivisionByZero,
246+
RemainderByZero,
247+
}
248+
231249
#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
232250
pub enum InterpError<'tcx, O> {
233251
/// This variant is used by machines to signal their own errors that do not
@@ -266,11 +284,6 @@ pub enum InterpError<'tcx, O> {
266284
Unimplemented(String),
267285
DerefFunctionPointer,
268286
ExecuteMemory,
269-
BoundsCheck { len: O, index: O },
270-
Overflow(mir::BinOp),
271-
OverflowNeg,
272-
DivisionByZero,
273-
RemainderByZero,
274287
Intrinsic(String),
275288
InvalidChar(u128),
276289
StackFrameLimitReached,
@@ -298,12 +311,7 @@ pub enum InterpError<'tcx, O> {
298311
HeapAllocZeroBytes,
299312
HeapAllocNonPowerOfTwoAlignment(u64),
300313
Unreachable,
301-
Panic {
302-
msg: Symbol,
303-
line: u32,
304-
col: u32,
305-
file: Symbol,
306-
},
314+
Panic(PanicMessage<O>),
307315
ReadFromReturnPointer,
308316
PathNotFound(Vec<String>),
309317
UnimplementedTraitSelection,
@@ -369,8 +377,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
369377
"tried to dereference a function pointer",
370378
ExecuteMemory =>
371379
"tried to treat a memory pointer as a function pointer",
372-
BoundsCheck{..} =>
373-
"array index out of bounds",
374380
Intrinsic(..) =>
375381
"intrinsic failed",
376382
NoMirFor(..) =>
@@ -422,8 +428,32 @@ impl<'tcx, O> InterpError<'tcx, O> {
422428
two",
423429
Unreachable =>
424430
"entered unreachable code",
425-
Panic { .. } =>
431+
Panic(PanicMessage::Panic{..}) =>
426432
"the evaluated program panicked",
433+
Panic(PanicMessage::BoundsCheck{..}) =>
434+
"array index out of bounds",
435+
Panic(PanicMessage::Overflow(mir::BinOp::Add)) =>
436+
"attempt to add with overflow",
437+
Panic(PanicMessage::Overflow(mir::BinOp::Sub)) =>
438+
"attempt to subtract with overflow",
439+
Panic(PanicMessage::Overflow(mir::BinOp::Mul)) =>
440+
"attempt to multiply with overflow",
441+
Panic(PanicMessage::Overflow(mir::BinOp::Div)) =>
442+
"attempt to divide with overflow",
443+
Panic(PanicMessage::Overflow(mir::BinOp::Rem)) =>
444+
"attempt to calculate the remainder with overflow",
445+
Panic(PanicMessage::OverflowNeg) =>
446+
"attempt to negate with overflow",
447+
Panic(PanicMessage::Overflow(mir::BinOp::Shr)) =>
448+
"attempt to shift right with overflow",
449+
Panic(PanicMessage::Overflow(mir::BinOp::Shl)) =>
450+
"attempt to shift left with overflow",
451+
Panic(PanicMessage::Overflow(op)) =>
452+
bug!("{:?} cannot overflow", op),
453+
Panic(PanicMessage::DivisionByZero) =>
454+
"attempt to divide by zero",
455+
Panic(PanicMessage::RemainderByZero) =>
456+
"attempt to calculate the remainder with a divisor of zero",
427457
ReadFromReturnPointer =>
428458
"tried to read from the return pointer",
429459
PathNotFound(_) =>
@@ -436,17 +466,6 @@ impl<'tcx, O> InterpError<'tcx, O> {
436466
"encountered overly generic constant",
437467
ReferencedConstant =>
438468
"referenced constant has errors",
439-
Overflow(mir::BinOp::Add) => "attempt to add with overflow",
440-
Overflow(mir::BinOp::Sub) => "attempt to subtract with overflow",
441-
Overflow(mir::BinOp::Mul) => "attempt to multiply with overflow",
442-
Overflow(mir::BinOp::Div) => "attempt to divide with overflow",
443-
Overflow(mir::BinOp::Rem) => "attempt to calculate the remainder with overflow",
444-
OverflowNeg => "attempt to negate with overflow",
445-
Overflow(mir::BinOp::Shr) => "attempt to shift right with overflow",
446-
Overflow(mir::BinOp::Shl) => "attempt to shift left with overflow",
447-
Overflow(op) => bug!("{:?} cannot overflow", op),
448-
DivisionByZero => "attempt to divide by zero",
449-
RemainderByZero => "attempt to calculate the remainder with a divisor of zero",
450469
GeneratorResumedAfterReturn => "generator resumed after completion",
451470
GeneratorResumedAfterPanic => "generator resumed after panicking",
452471
InfiniteLoop =>
@@ -493,8 +512,6 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
493512
callee_ty, caller_ty),
494513
FunctionArgCountMismatch =>
495514
write!(f, "tried to call a function with incorrect number of arguments"),
496-
BoundsCheck { ref len, ref index } =>
497-
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
498515
ReallocatedWrongMemoryKind(ref old, ref new) =>
499516
write!(f, "tried to reallocate memory from {} to {}", old, new),
500517
DeallocatedWrongMemoryKind(ref old, ref new) =>
@@ -518,8 +535,10 @@ impl<'tcx, O: fmt::Debug> fmt::Debug for InterpError<'tcx, O> {
518535
write!(f, "incorrect alloc info: expected size {} and align {}, \
519536
got size {} and align {}",
520537
size.bytes(), align.bytes(), size2.bytes(), align2.bytes()),
521-
Panic { ref msg, line, col, ref file } =>
538+
Panic(PanicMessage::Panic { ref msg, line, col, ref file }) =>
522539
write!(f, "the evaluated program panicked at '{}', {}:{}:{}", msg, file, line, col),
540+
Panic(PanicMessage::BoundsCheck { ref len, ref index }) =>
541+
write!(f, "index out of bounds: the len is {:?} but the index is {:?}", len, index),
523542
InvalidDiscriminant(val) =>
524543
write!(f, "encountered invalid enum discriminant {}", val),
525544
Exit(code) =>

src/librustc/mir/interpret/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ mod pointer;
1212

1313
pub use self::error::{
1414
InterpErrorInfo, InterpResult, InterpError, AssertMessage, ConstEvalErr, struct_error,
15-
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled,
15+
FrameInfo, ConstEvalRawResult, ConstEvalResult, ErrorHandled, PanicMessage
1616
};
1717

1818
pub use self::value::{Scalar, ScalarMaybeUndef, RawConst, ConstValue};

src/librustc/mir/interpret/pointer.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::ty::layout::{self, HasDataLayout, Size};
55
use rustc_macros::HashStable;
66

77
use super::{
8-
AllocId, InterpResult,
8+
AllocId, InterpResult, PanicMessage
99
};
1010

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

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

src/librustc/mir/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use crate::hir::def::{CtorKind, Namespace};
88
use crate::hir::def_id::DefId;
99
use crate::hir::{self, InlineAsm as HirInlineAsm};
10-
use crate::mir::interpret::{ConstValue, InterpError, Scalar};
10+
use crate::mir::interpret::{ConstValue, PanicMessage, InterpError::Panic, Scalar};
1111
use crate::mir::visit::MirVisitable;
1212
use crate::rustc_serialize as serialize;
1313
use crate::ty::adjustment::PointerCast;
@@ -1931,7 +1931,7 @@ impl<'tcx> Place<'tcx> {
19311931
iterate_over2(place_base, place_projection, &Projections::Empty, op)
19321932
}
19331933

1934-
pub fn as_place_ref(&self) -> PlaceRef<'_, 'tcx> {
1934+
pub fn as_ref(&self) -> PlaceRef<'_, 'tcx> {
19351935
PlaceRef {
19361936
base: &self.base,
19371937
projection: &self.projection,
@@ -3152,11 +3152,11 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
31523152
}
31533153
}
31543154
Assert { ref cond, expected, ref msg, target, cleanup } => {
3155-
let msg = if let InterpError::BoundsCheck { ref len, ref index } = *msg {
3156-
InterpError::BoundsCheck {
3155+
let msg = if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
3156+
Panic(PanicMessage::BoundsCheck {
31573157
len: len.fold_with(folder),
31583158
index: index.fold_with(folder),
3159-
}
3159+
})
31603160
} else {
31613161
msg.clone()
31623162
};
@@ -3197,7 +3197,7 @@ impl<'tcx> TypeFoldable<'tcx> for Terminator<'tcx> {
31973197
}
31983198
Assert { ref cond, ref msg, .. } => {
31993199
if cond.visit_with(visitor) {
3200-
if let InterpError::BoundsCheck { ref len, ref index } = *msg {
3200+
if let Panic(PanicMessage::BoundsCheck { ref len, ref index }) = *msg {
32013201
len.visit_with(visitor) || index.visit_with(visitor)
32023202
} else {
32033203
false

src/librustc/mir/visit.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,8 @@ macro_rules! make_mir_visitor {
515515
msg: & $($mutability)? AssertMessage<'tcx>,
516516
location: Location) {
517517
use crate::mir::interpret::InterpError::*;
518-
if let BoundsCheck { len, index } = msg {
518+
use crate::mir::interpret::PanicMessage::BoundsCheck;
519+
if let Panic(BoundsCheck { len, index }) = msg {
519520
self.visit_operand(len, location);
520521
self.visit_operand(index, location);
521522
}

src/librustc_allocator/expand.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl MutVisitor for ExpandAllocatorDirectives<'_> {
7979

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

282282
AllocatorTy::Layout | AllocatorTy::Usize | AllocatorTy::Ptr => {
283-
panic!("can't convert AllocatorTy to an output")
283+
panic!("can't convert `AllocatorTy` to an output")
284284
}
285285
}
286286
}

src/librustc_codegen_ssa/mir/analyze.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl<'mir, 'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx>
238238
context: PlaceContext,
239239
location: Location) {
240240
debug!("visit_place(place={:?}, context={:?})", place, context);
241-
self.process_place(&place.as_place_ref(), context, location);
241+
self.process_place(&place.as_ref(), context, location);
242242
}
243243

244244
fn visit_local(&mut self,

0 commit comments

Comments
 (0)