@@ -11,6 +11,7 @@ use super::{
1111use crate :: infer:: error_reporting:: { TyCategory , TypeAnnotationNeeded as ErrorCode } ;
1212use crate :: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
1313use crate :: infer:: { self , InferCtxt , TyCtxtInferExt } ;
14+ use crate :: traits:: const_evaluatable:: AbstractConst ;
1415use rustc_data_structures:: fx:: FxHashMap ;
1516use rustc_errors:: { pluralize, struct_span_err, Applicability , DiagnosticBuilder , ErrorReported } ;
1617use rustc_hir as hir;
@@ -19,6 +20,7 @@ use rustc_hir::intravisit::Visitor;
1920use rustc_hir:: GenericParam ;
2021use rustc_hir:: Item ;
2122use rustc_hir:: Node ;
23+ //use rustc_middle::mir::interpret::ConstValue;
2224use rustc_middle:: thir:: abstract_const:: NotConstEvaluatable ;
2325use rustc_middle:: ty:: error:: ExpectedFound ;
2426use rustc_middle:: ty:: fast_reject:: { self , SimplifyParams , StripReferences } ;
@@ -1173,6 +1175,11 @@ trait InferCtxtPrivExt<'hir, 'tcx> {
11731175 obligated_types : & mut Vec < & ty:: TyS < ' tcx > > ,
11741176 cause_code : & ObligationCauseCode < ' tcx > ,
11751177 ) -> bool ;
1178+
1179+ fn try_create_suggestion_for_mismatched_const (
1180+ & self ,
1181+ expected_found : ExpectedFound < & ' tcx ty:: Const < ' tcx > > ,
1182+ ) -> Option < String > ;
11761183}
11771184
11781185impl < ' a , ' tcx > InferCtxtPrivExt < ' a , ' tcx > for InferCtxt < ' a , ' tcx > {
@@ -1246,6 +1253,11 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
12461253 . emit ( ) ;
12471254 }
12481255 FulfillmentErrorCode :: CodeConstEquateError ( ref expected_found, ref err) => {
1256+ debug ! (
1257+ "expected: {:?}, found: {:?}" ,
1258+ expected_found. expected, expected_found. found
1259+ ) ;
1260+
12491261 self . report_mismatched_consts (
12501262 & error. obligation . cause ,
12511263 expected_found. expected ,
@@ -1489,6 +1501,16 @@ impl<'a, 'tcx> InferCtxtPrivExt<'a, 'tcx> for InferCtxt<'a, 'tcx> {
14891501 }
14901502 }
14911503
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+
14921514 fn report_similar_impl_candidates (
14931515 & self ,
14941516 impl_candidates : Vec < ty:: TraitRef < ' tcx > > ,
0 commit comments