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 7 pull requests #63214

Merged
merged 42 commits into from
Aug 2, 2019
Merged
Changes from 1 commit
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0aa9658
changing the fields of InterpError
saleemjaffer Jul 25, 2019
01859bb
grouping the variants of InterpError
saleemjaffer Jul 26, 2019
fc48f3e
more grouping of the variants in InterpError
saleemjaffer Jul 26, 2019
eeb2335
moving remaining variants to UnsupportedInfo
saleemjaffer Jul 26, 2019
4f0ab6c
code review fixes
saleemjaffer Jul 26, 2019
307798a
fixing fallout due to InterpError refactor
saleemjaffer Jul 27, 2019
aa3d40c
tidy fixes
saleemjaffer Jul 27, 2019
9782b37
implementing Debug for UnsupportedInfo
saleemjaffer Jul 28, 2019
8e9d0fa
adding a err macro for each of the InterpError variants
saleemjaffer Jul 29, 2019
654519d
use PanicInfo and UnsupportedOpInfo
saleemjaffer Jul 29, 2019
03d47be
code review fixes
saleemjaffer Jul 29, 2019
9f8b099
code review fixes
saleemjaffer Jul 29, 2019
5bb06b3
code review fixes
saleemjaffer Jul 29, 2019
9620521
code review fixes
saleemjaffer Jul 30, 2019
2a33fbf
addding an interp_error module
saleemjaffer Jul 30, 2019
69daf84
adding throw_ and err_ macros for InterpError
saleemjaffer Jul 30, 2019
b60a336
tidy fixes
saleemjaffer Jul 30, 2019
fc5df1d
renaming err to err_unsup
saleemjaffer Jul 30, 2019
35417e7
renaming throw_err_* to throw_*
saleemjaffer Jul 30, 2019
5585445
throw_X macros use err_X macros
saleemjaffer Jul 30, 2019
87e73c1
Remove redundant method with const variable resolution
varkor Jul 31, 2019
152f0d3
code review fixes
saleemjaffer Jul 31, 2019
a1e59d1
code review fixes
saleemjaffer Jul 31, 2019
c17d11f
code review fixes
saleemjaffer Jul 31, 2019
0c4513e
code review fixes
saleemjaffer Aug 1, 2019
00d32e8
code review fixes
saleemjaffer Aug 1, 2019
b5c04e6
FixedSizeArray: Add missing links in doc comments.
waywardmonkeys Aug 1, 2019
cbac781
More questionmarks in doctests
llogiq Jul 13, 2019
86633b6
Fix typos in doc comments.
waywardmonkeys Aug 1, 2019
ae65848
Remove extraneous {} in use stmts in doc comments.
waywardmonkeys Aug 1, 2019
325c6a5
Futures: Add link to Waker in trait doc.
waywardmonkeys Aug 1, 2019
cefbf4d
Allow trailing comma in macro 2.0 declarations.
rbartlensky Aug 1, 2019
b3321fb
Fix ICE in #63135
ExpHP Aug 1, 2019
2aa368a
Add check-pass test for #63102.
rbartlensky Aug 1, 2019
7052c35
Make is_mutable use PlaceRef instead of it's fields
spastorino Aug 1, 2019
6b951c2
Rollup merge of #62663 - llogiq:more-questionmark-docs, r=GuillaumeGomez
Centril Aug 2, 2019
51dc78e
Rollup merge of #62969 - saleemjaffer:declutter_interperror, r=RalfJung
Centril Aug 2, 2019
5155c7e
Rollup merge of #63153 - varkor:remove-resolve_const_var, r=cramertj
Centril Aug 2, 2019
dbfe12d
Rollup merge of #63189 - waywardmonkeys:doc-improvements, r=Centril
Centril Aug 2, 2019
89dce46
Rollup merge of #63198 - rbartlensky:fix-macro-trailing-comma, r=petr…
Centril Aug 2, 2019
3396550
Rollup merge of #63202 - exphp-forks:parser-ice-63135, r=estebank
Centril Aug 2, 2019
97098f4
Rollup merge of #63203 - spastorino:is-mutable-use-place-ref, r=oli-obk
Centril Aug 2, 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
Prev Previous commit
Next Next commit
more grouping of the variants in InterpError
  • Loading branch information
saleemjaffer committed Jul 29, 2019
commit fc48f3e824333f1dc8166f9760795a8b67c84714
86 changes: 44 additions & 42 deletions src/librustc/mir/interpret/error.rs
Original file line number Diff line number Diff line change
@@ -137,12 +137,13 @@ impl<'tcx> ConstEvalErr<'tcx> {
message: &str,
lint_root: Option<hir::HirId>,
) -> Result<DiagnosticBuilder<'tcx>, ErrorHandled> {
use InvalidProgramInfo::*;
match self.error {
InterpError::Layout(LayoutError::Unknown(_)) |
InterpError::InvalidProgram(InvalidProgramMessage::TooGeneric) =>
InterpError::InvalidProgram(Layout(LayoutError::Unknown(_))) |
InterpError::InvalidProgram(TooGeneric) =>
return Err(ErrorHandled::TooGeneric),
InterpError::Layout(LayoutError::SizeOverflow(_)) |
InterpError::InvalidProgram(InvalidProgramMessage::TypeckError) =>
InterpError::InvalidProgram(TypeckError) =>
return Err(ErrorHandled::Reported),
_ => {},
}
@@ -312,42 +313,74 @@ impl<O: fmt::Debug> fmt::Debug for PanicMessage<O> {
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum InvalidProgramMessage {
pub enum InvalidProgramInfo<'tcx> {
/// Resolution can fail if we are in a too generic context
TooGeneric,
/// Cannot compute this constant because it depends on another one
/// which already produced an error
ReferencedConstant,
/// Abort in case type errors are reached
TypeckError,
Layout(layout::LayoutError<'tcx>),
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum UndefinedBehaviourMessage {
pub enum UndefinedBehaviourInfo {
Unreachable,
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum UnsupportedMessage {
pub enum UnsupportedInfo<'tcx> {
FunctionAbiMismatch(Abi, Abi),
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
FunctionArgCountMismatch,
UnterminatedCString(Pointer),
DanglingPointerDeref,
DoubleFree,
InvalidMemoryAccess,
InvalidFunctionPointer,
InvalidBool,
InvalidDiscriminant(ScalarMaybeUndef),
PointerOutOfBounds {
ptr: Pointer,
msg: CheckInAllocMsg,
allocation_size: Size,
},
InvalidNullPointerUsage,
ReadPointerAsBytes,
ReadBytesAsPointer,
ReadForeignStatic,
InvalidPointerMath,
ReadUndefBytes(Size),
DeadLocal,
InvalidBoolOp(mir::BinOp),
InlineAsm,
UnimplementedTraitSelection,
CalledClosureAsFunction,
NoMirFor(String),
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum ResourceExhaustionMessage {
pub enum ResourceExhaustionInfo {
StackFrameLimitReached,
InfiniteLoop,
}

#[derive(Clone, RustcEncodable, RustcDecodable, HashStable)]
pub enum InterpError<'tcx> {
/// The program panicked.
Panic(PanicMessage<u64>),
/// The program caused undefined behavior.
UndefinedBehaviour(UndefinedBehaviourMessage),
UndefinedBehaviour(UndefinedBehaviourInfo),
/// The program did something the interpreter does not support (some of these *might* be UB
/// but the interpreter is not sure).
Unsupported(UnsupportedMessage),
Unsupported(UnsupportedInfo<'tcx>),
/// The program was invalid (ill-typed, not sufficiently monomorphized, ...).
InvalidProgram(InvalidProgramMessage),
InvalidProgram(InvalidProgramInfo<'tcx>),
/// The program exhausted the interpreter's resources (stack/heap too big,
/// execution takes too long, ..).
ResourceExhaustion(ResourceExhaustionMessage),
ResourceExhaustion(ResourceExhaustionInfo),

/// THe above 5 variants are what we want to group all the remaining InterpError variants into

@@ -359,37 +392,11 @@ pub enum InterpError<'tcx> {
/// with the given status code. Used by Miri, but not by CTFE.
Exit(i32),

FunctionAbiMismatch(Abi, Abi),
FunctionArgMismatch(Ty<'tcx>, Ty<'tcx>),
FunctionRetMismatch(Ty<'tcx>, Ty<'tcx>),
FunctionArgCountMismatch,
NoMirFor(String),
UnterminatedCString(Pointer),
DanglingPointerDeref,
DoubleFree,
InvalidMemoryAccess,
InvalidFunctionPointer,
InvalidBool,
InvalidDiscriminant(ScalarMaybeUndef),
PointerOutOfBounds {
ptr: Pointer,
msg: CheckInAllocMsg,
allocation_size: Size,
},
InvalidNullPointerUsage,
ReadPointerAsBytes,
ReadBytesAsPointer,
ReadForeignStatic,
InvalidPointerMath,
ReadUndefBytes(Size),
DeadLocal,
InvalidBoolOp(mir::BinOp),
Unimplemented(String),
DerefFunctionPointer,
ExecuteMemory,
Intrinsic(String),
InvalidChar(u128),
StackFrameLimitReached,
OutOfTls,
TlsOutOfBounds,
AbiViolation(String),
@@ -398,25 +405,20 @@ pub enum InterpError<'tcx> {
has: Align,
},
ValidationFailure(String),
CalledClosureAsFunction,
VtableForArgumentlessMethod,
ModifiedConstantMemory,
ModifiedStatic,
AssumptionNotHeld,
InlineAsm,
TypeNotPrimitive(Ty<'tcx>),
ReallocatedWrongMemoryKind(String, String),
DeallocatedWrongMemoryKind(String, String),
ReallocateNonBasePtr,
DeallocateNonBasePtr,
IncorrectAllocationInformation(Size, Size, Align, Align),
Layout(layout::LayoutError<'tcx>),
HeapAllocZeroBytes,
HeapAllocNonPowerOfTwoAlignment(u64),
Unreachable,
ReadFromReturnPointer,
PathNotFound(Vec<String>),
UnimplementedTraitSelection,
}

pub type InterpResult<'tcx, T = ()> = Result<T, InterpErrorInfo<'tcx>>;