11//! Concrete error types for all operations which may be invalid in a certain const context. 
22
3- use  hir:: def_id:: LocalDefId ; 
43use  hir:: { ConstContext ,  LangItem } ; 
54use  rustc_errors:: Diag ; 
65use  rustc_errors:: codes:: * ; 
@@ -74,7 +73,6 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
7473/// A function call where the callee is not marked as `const`. 
7574#[ derive( Debug ,  Clone ,  Copy ) ]  
7675pub ( crate )  struct  FnCallNonConst < ' tcx >  { 
77-     pub  caller :  LocalDefId , 
7876    pub  callee :  DefId , 
7977    pub  args :  GenericArgsRef < ' tcx > , 
8078    pub  span :  Span , 
@@ -87,8 +85,9 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
8785    #[ allow( rustc:: diagnostic_outside_of_impl) ]  
8886    #[ allow( rustc:: untranslatable_diagnostic) ]  
8987    fn  build_error ( & self ,  ccx :  & ConstCx < ' _ ,  ' tcx > ,  _:  Span )  -> Diag < ' tcx >  { 
90-         let  FnCallNonConst  {  caller,  callee,  args,  span,  call_source,  feature }  = * self ; 
91-         let  ConstCx  {  tcx,  param_env,  body,  .. }  = * ccx; 
88+         let  FnCallNonConst  {  callee,  args,  span,  call_source,  feature }  = * self ; 
89+         let  ConstCx  {  tcx,  param_env,  .. }  = * ccx; 
90+         let  caller = ccx. def_id ( ) ; 
9291
9392        let  diag_trait = |err,  self_ty :  Ty < ' _ > ,  trait_id| { 
9493            let  trait_ref = TraitRef :: from_method ( tcx,  trait_id,  args) ; 
@@ -116,7 +115,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
116115                    let  obligation =
117116                        Obligation :: new ( tcx,  ObligationCause :: dummy ( ) ,  param_env,  trait_ref) ; 
118117
119-                     let  infcx = tcx. infer_ctxt ( ) . build ( body. typing_mode ( tcx) ) ; 
118+                     let  infcx = tcx. infer_ctxt ( ) . build ( ccx . body . typing_mode ( tcx) ) ; 
120119                    let  mut  selcx = SelectionContext :: new ( & infcx) ; 
121120                    let  implsrc = selcx. select ( & obligation) ; 
122121
@@ -289,7 +288,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
289288        if  let  Some ( feature)  = feature { 
290289            ccx. tcx . disabled_nightly_features ( 
291290                & mut  err, 
292-                 body . source . def_id ( ) . as_local ( ) . map ( |local|  ccx. tcx . local_def_id_to_hir_id ( local ) ) , 
291+                 Some ( ccx. tcx . local_def_id_to_hir_id ( caller ) ) , 
293292                [ ( String :: new ( ) ,  feature) ] , 
294293            ) ; 
295294        } 
0 commit comments