@@ -2,7 +2,7 @@ use std::mem;
22
33use  rustc_errors:: { Diag ,  DiagArgName ,  DiagArgValue ,  DiagMessage ,  IntoDiagArg } ; 
44use  rustc_middle:: mir:: AssertKind ; 
5- use  rustc_middle:: mir:: interpret:: { Provenance ,  ReportedErrorInfo } ; 
5+ use  rustc_middle:: mir:: interpret:: { AllocId ,   Provenance ,  ReportedErrorInfo } ; 
66use  rustc_middle:: query:: TyCtxtAt ; 
77use  rustc_middle:: ty:: layout:: LayoutError ; 
88use  rustc_middle:: ty:: { ConstInt ,  TyCtxt } ; 
@@ -11,8 +11,8 @@ use rustc_span::{Span, Symbol};
1111use  super :: CompileTimeMachine ; 
1212use  crate :: errors:: { self ,  FrameNote ,  ReportErrorExt } ; 
1313use  crate :: interpret:: { 
14-     ErrorHandled ,  Frame ,  InterpErrorInfo ,  InterpErrorKind ,  MachineStopType ,  err_inval , 
15-     err_machine_stop, 
14+     CtfeProvenance ,   ErrorHandled ,  Frame ,  InterpErrorInfo ,  InterpErrorKind ,  MachineStopType , 
15+     Pointer ,  err_inval ,   err_machine_stop, 
1616} ; 
1717
1818/// The CTFE machine has some custom error kinds. 
@@ -22,8 +22,22 @@ pub enum ConstEvalErrKind {
2222    ModifiedGlobal , 
2323    RecursiveStatic , 
2424    AssertFailure ( AssertKind < ConstInt > ) , 
25-     Panic  {  msg :  Symbol ,  line :  u32 ,  col :  u32 ,  file :  Symbol  } , 
25+     Panic  { 
26+         msg :  Symbol , 
27+         line :  u32 , 
28+         col :  u32 , 
29+         file :  Symbol , 
30+     } , 
2631    WriteThroughImmutablePointer , 
32+     /// Called `const_make_global` twice. 
33+      ConstMakeGlobalPtrAlreadyMadeGlobal ( AllocId ) , 
34+     /// Called `const_make_global` on a non-heap pointer. 
35+      ConstMakeGlobalPtrIsNonHeap ( Pointer < Option < CtfeProvenance > > ) , 
36+     /// Called `const_make_global` on a dangling pointer. 
37+      ConstMakeGlobalWithDanglingPtr ( Pointer < Option < CtfeProvenance > > ) , 
38+     /// Called `const_make_global` on a pointer that does not start at the 
39+      /// beginning of an object. 
40+      ConstMakeGlobalWithOffset ( Pointer < Option < CtfeProvenance > > ) , 
2741} 
2842
2943impl  MachineStopType  for  ConstEvalErrKind  { 
@@ -38,6 +52,12 @@ impl MachineStopType for ConstEvalErrKind {
3852            RecursiveStatic  => const_eval_recursive_static, 
3953            AssertFailure ( x)  => x. diagnostic_message ( ) , 
4054            WriteThroughImmutablePointer  => const_eval_write_through_immutable_pointer, 
55+             ConstMakeGlobalPtrAlreadyMadeGlobal  {  .. }  => { 
56+                 const_eval_const_make_global_ptr_already_made_global
57+             } 
58+             ConstMakeGlobalPtrIsNonHeap ( _)  => const_eval_const_make_global_ptr_is_non_heap, 
59+             ConstMakeGlobalWithDanglingPtr ( _)  => const_eval_const_make_global_with_dangling_ptr, 
60+             ConstMakeGlobalWithOffset ( _)  => const_eval_const_make_global_with_offset, 
4161        } 
4262    } 
4363    fn  add_args ( self :  Box < Self > ,  adder :  & mut  dyn  FnMut ( DiagArgName ,  DiagArgValue ) )  { 
@@ -51,6 +71,14 @@ impl MachineStopType for ConstEvalErrKind {
5171            Panic  {  msg,  .. }  => { 
5272                adder ( "msg" . into ( ) ,  msg. into_diag_arg ( & mut  None ) ) ; 
5373            } 
74+             ConstMakeGlobalPtrIsNonHeap ( ptr) 
75+             | ConstMakeGlobalWithOffset ( ptr) 
76+             | ConstMakeGlobalWithDanglingPtr ( ptr)  => { 
77+                 adder ( "ptr" . into ( ) ,  format ! ( "{ptr:?}" ) . into_diag_arg ( & mut  None ) ) ; 
78+             } 
79+             ConstMakeGlobalPtrAlreadyMadeGlobal ( alloc)  => { 
80+                 adder ( "alloc" . into ( ) ,  alloc. into_diag_arg ( & mut  None ) ) ; 
81+             } 
5482        } 
5583    } 
5684} 
0 commit comments