@@ -144,18 +144,100 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
144144 } ;
145145 let r = match f ( self ) {
146146 Ok ( val) => Some ( val) ,
147- Err ( err) => {
148- match err. kind {
147+ Err ( error) => {
148+ let ( stacktrace, span) = self . ecx . generate_stacktrace ( None ) ;
149+ let diagnostic = ConstEvalErr { span, error, stacktrace } ;
150+ use rustc:: mir:: interpret:: EvalErrorKind :: * ;
151+ match diagnostic. error . kind {
149152 // don't report these, they make no sense in a const prop context
150- EvalErrorKind :: MachineError ( _) => { } ,
151- _ => {
152- let ( frames, span) = self . ecx . generate_stacktrace ( None ) ;
153- let err = ConstEvalErr {
154- span,
155- error : err,
156- stacktrace : frames,
157- } ;
158- err. report_as_lint (
153+ | MachineError ( _)
154+ // at runtime these transformations might make sense
155+ // FIXME: figure out the rules and start linting
156+ | FunctionPointerTyMismatch ( ..)
157+ // fine at runtime, might be a register address or sth
158+ | ReadBytesAsPointer
159+ // fine at runtime
160+ | ReadForeignStatic
161+ | Unimplemented ( _)
162+ // don't report const evaluator limits
163+ | StackFrameLimitReached
164+ | NoMirFor ( ..)
165+ | InlineAsm
166+ => { } ,
167+
168+ | InvalidMemoryAccess
169+ | DanglingPointerDeref
170+ | DoubleFree
171+ | InvalidFunctionPointer
172+ | InvalidBool
173+ | InvalidDiscriminant
174+ | PointerOutOfBounds { .. }
175+ | InvalidNullPointerUsage
176+ | MemoryLockViolation { .. }
177+ | MemoryAcquireConflict { .. }
178+ | ValidationFailure ( ..)
179+ | InvalidMemoryLockRelease { .. }
180+ | DeallocatedLockedMemory { .. }
181+ | InvalidPointerMath
182+ | ReadUndefBytes
183+ | DeadLocal
184+ | InvalidBoolOp ( _)
185+ | DerefFunctionPointer
186+ | ExecuteMemory
187+ | Intrinsic ( ..)
188+ | InvalidChar ( ..)
189+ | AbiViolation ( _)
190+ | AlignmentCheckFailed { ..}
191+ | CalledClosureAsFunction
192+ | VtableForArgumentlessMethod
193+ | ModifiedConstantMemory
194+ | AssumptionNotHeld
195+ // FIXME: should probably be removed and turned into a bug! call
196+ | TypeNotPrimitive ( _)
197+ | ReallocatedWrongMemoryKind ( _, _)
198+ | DeallocatedWrongMemoryKind ( _, _)
199+ | ReallocateNonBasePtr
200+ | DeallocateNonBasePtr
201+ | IncorrectAllocationInformation ( ..)
202+ | UnterminatedCString ( _)
203+ | HeapAllocZeroBytes
204+ | HeapAllocNonPowerOfTwoAlignment ( _)
205+ | Unreachable
206+ | ReadFromReturnPointer
207+ | GeneratorResumedAfterReturn
208+ | GeneratorResumedAfterPanic
209+ | ReferencedConstant ( _)
210+ | InfiniteLoop
211+ => {
212+ // FIXME: report UB here
213+ } ,
214+
215+ | OutOfTls
216+ | TlsOutOfBounds
217+ | PathNotFound ( _)
218+ => bug ! ( "these should not be in rustc, but in miri's machine errors" ) ,
219+
220+ | Layout ( _)
221+ | UnimplementedTraitSelection
222+ | TypeckError
223+ | TooGeneric
224+ | CheckMatchError
225+ // these are just noise
226+ => { } ,
227+
228+ // non deterministic
229+ | ReadPointerAsBytes
230+ // FIXME: implement
231+ => { } ,
232+
233+ | Panic
234+ | BoundsCheck { ..}
235+ | Overflow ( _)
236+ | OverflowNeg
237+ | DivisionByZero
238+ | RemainderByZero
239+ => {
240+ diagnostic. report_as_lint (
159241 self . ecx . tcx ,
160242 "this expression will panic at runtime" ,
161243 lint_root,
0 commit comments