1
1
//! Concrete error types for all operations which may be invalid in a certain const context.
2
2
3
- use hir:: def_id:: LocalDefId ;
4
3
use hir:: { ConstContext , LangItem } ;
5
4
use rustc_errors:: Diag ;
6
5
use rustc_errors:: codes:: * ;
@@ -74,7 +73,6 @@ impl<'tcx> NonConstOp<'tcx> for FnCallIndirect {
74
73
/// A function call where the callee is not marked as `const`.
75
74
#[ derive( Debug , Clone , Copy ) ]
76
75
pub ( crate ) struct FnCallNonConst < ' tcx > {
77
- pub caller : LocalDefId ,
78
76
pub callee : DefId ,
79
77
pub args : GenericArgsRef < ' tcx > ,
80
78
pub span : Span ,
@@ -87,8 +85,9 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
87
85
#[ allow( rustc:: diagnostic_outside_of_impl) ]
88
86
#[ allow( rustc:: untranslatable_diagnostic) ]
89
87
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 ( ) ;
92
91
93
92
let diag_trait = |err, self_ty : Ty < ' _ > , trait_id| {
94
93
let trait_ref = TraitRef :: from_method ( tcx, trait_id, args) ;
@@ -289,7 +288,7 @@ impl<'tcx> NonConstOp<'tcx> for FnCallNonConst<'tcx> {
289
288
if let Some ( feature) = feature {
290
289
ccx. tcx . disabled_nightly_features (
291
290
& 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 ) ) ,
293
292
[ ( String :: new ( ) , feature) ] ,
294
293
) ;
295
294
}
0 commit comments