-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Refactor error reporting of constants #51636
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
src/librustc/mir/interpret/error.rs
Outdated
@@ -150,6 +150,9 @@ pub enum EvalErrorKind<'tcx, O> { | |||
UnimplementedTraitSelection, | |||
/// Abort in case type errors are reached | |||
TypeckError, | |||
/// Resolution can fail if we are in a too generic context | |||
ResolutionFailed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather call this TooGeneric
or something more obvious.
src/librustc/middle/const_val.rs
Outdated
TypeckError, | ||
CheckMatchError, | ||
Miri(::mir::interpret::EvalError<'tcx>, Vec<FrameInfo>), | ||
pub data: Lrc<(::mir::interpret::EvalError<'tcx>, Vec<FrameInfo>)>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this struct be moved to mir::interpret
? Also, maybe put the Lrc
around the struct, that way you can name the fields that are currently in a tuple.
src/librustc/traits/fulfill.rs
Outdated
ProcessResult::Error( | ||
CodeSelectionError(ConstEvalFailure(ConstEvalErr { | ||
span: obligation.cause.span, | ||
kind: ErrKind::CouldNotResolve.into(), | ||
data: (err, Vec::new()).into(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: vec![]
8bf8763
to
c93a80c
Compare
Addressed all review comments |
--> $DIR/const-len-underflow-separate-spans.rs:21:17 | ||
| | ||
LL | let a: [i8; LEN] = unimplemented!(); | ||
| ^^^ referenced constant has errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems weird, since the constant is not in an Operand::Const
, but rather in a type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This note means to say that LEN
has errors, which is a constant reference right where the span points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an "error: this expression will panic at runtime" inside non-runtime code though?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... Looks like const prop is running on array lengths?! I wonder how that happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
ec32bcb
to
8b957ca
Compare
|
||
use super::{EvalResult, Pointer, PointerArithmetic, Allocation}; | ||
|
||
/// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which | ||
/// matches Value's optimizations for easy conversions between these two types | ||
#[derive(Clone, Copy, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] | ||
#[derive(Copy, Clone, Debug, Eq, PartialEq, PartialOrd, Ord, RustcEncodable, RustcDecodable, Hash)] | ||
pub enum ConstValue<'tcx> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @Zoxc
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
4064f09
to
c190b3a
Compare
r? @eddyb (since I'm still on leave) |
☔ The latest upstream changes (presumably #51538) made this pull request unmergeable. Please resolve the merge conflicts. |
a155b37
to
4d47330
Compare
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r+ |
📌 Commit 2a55d2f has been approved by |
Refactor error reporting of constants cc @eddyb This PR should not change any behaviour. It solely simplifies the internal handling of the errors
Rollup of 6 pull requests Successful merges: - #51636 (Refactor error reporting of constants) - #51765 (Use assert_eq! in copy_from_slice) - #51822 (Provide existing ref suggestions for more E0308 errors) - #51839 (Detect overflows of non u32 shifts) - #51868 (Remove process::id from 'Stabilized APIs' in 1.27.0 release notes) - #51875 (Explicitely disable WASM code generation for Emscripten) Failed merges: r? @ghost
cc @eddyb
This PR should not change any behaviour. It solely simplifies the internal handling of the errors