@@ -11,6 +11,7 @@ use super::{
11
11
use crate :: infer:: error_reporting:: { TyCategory , TypeAnnotationNeeded as ErrorCode } ;
12
12
use crate :: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
13
13
use crate :: infer:: { self , InferCtxt , TyCtxtInferExt } ;
14
+ use crate :: traits:: const_evaluatable:: AbstractConst ;
14
15
use rustc_data_structures:: fx:: FxHashMap ;
15
16
use rustc_errors:: { pluralize, struct_span_err, Applicability , DiagnosticBuilder , ErrorReported } ;
16
17
use rustc_hir as hir;
@@ -19,6 +20,7 @@ use rustc_hir::intravisit::Visitor;
19
20
use rustc_hir:: GenericParam ;
20
21
use rustc_hir:: Item ;
21
22
use rustc_hir:: Node ;
23
+ //use rustc_middle::mir::interpret::ConstValue;
22
24
use rustc_middle:: thir:: abstract_const:: NotConstEvaluatable ;
23
25
use rustc_middle:: ty:: error:: ExpectedFound ;
24
26
use rustc_middle:: ty:: fast_reject:: { self , SimplifyParams , StripReferences } ;
@@ -1173,6 +1175,11 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
1173
1175
obligated_types : & mut Vec < & ty:: TyS < ' tcx > > ,
1174
1176
cause_code : & ObligationCauseCode < ' tcx > ,
1175
1177
) -> bool ;
1178
+
1179
+ fn try_create_suggestion_for_mismatched_const (
1180
+ & self ,
1181
+ expected_found : ExpectedFound < & ' tcx ty:: Const < ' tcx > > ,
1182
+ ) -> Option < String > ;
1176
1183
}
1177
1184
1178
1185
impl < ' a , ' tcx > InferCtxtPrivExt < ' a , ' tcx > for InferCtxt < ' a , ' tcx > {
@@ -1246,6 +1253,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
1246
1253
. emit ( ) ;
1247
1254
}
1248
1255
FulfillmentErrorCode :: CodeConstEquateError ( ref expected_found, ref err) => {
1256
+ debug ! (
1257
+ "expected: {:?}, found: {:?}" ,
1258
+ expected_found. expected, expected_found. found
1259
+ ) ;
1260
+
1249
1261
self . report_mismatched_consts (
1250
1262
& error. obligation . cause ,
1251
1263
expected_found. expected ,
@@ -1489,6 +1501,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
1489
1501
}
1490
1502
}
1491
1503
1504
+ fn try_create_suggestion_for_mismatched_const (
1505
+ & self ,
1506
+ expected_found : ExpectedFound < & ' tcx ty:: Const < ' tcx > > ,
1507
+ ) -> Option < String > {
1508
+ match AbstractConst :: from_const ( self . tcx , expected_found. found ) {
1509
+ Ok ( Some ( f_abstract) ) => f_abstract. try_print_with_replacing_substs ( self . tcx ) ,
1510
+ _ => None ,
1511
+ }
1512
+ }
1513
+
1492
1514
fn report_similar_impl_candidates (
1493
1515
& self ,
1494
1516
impl_candidates : Vec < ty:: TraitRef < ' tcx > > ,
0 commit comments