11//! Error Reporting for `impl` items that do not match the obligations from their `trait`.
22
3+ use syntax_pos:: Span ;
4+ use crate :: ty:: Ty ;
35use crate :: infer:: { ValuePairs , Subtype } ;
46use crate :: infer:: error_reporting:: nice_region_error:: NiceRegionError ;
57use crate :: infer:: lexical_region_resolve:: RegionResolutionError ;
@@ -25,21 +27,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
2527 ) = ( & sub_trace. values , & sup_trace. values ) {
2628 if sup_expected_found == sub_expected_found {
2729 let sp = var_origin. span ( ) ;
28- let mut err = self . tcx ( ) . sess . struct_span_err (
30+ self . emit_err (
2931 sp,
30- "`impl` item doesn't match `trait` item"
31- ) ;
32- err. note ( & format ! (
33- "expected: {:?}\n found: {:?}" ,
3432 sub_expected_found. expected ,
3533 sub_expected_found. found ,
36- ) ) ;
37- err. span_label ( sp, & format ! (
38- "found {:?}" ,
39- sub_expected_found. found,
40- ) ) ;
41- // FIXME: recover the `FnPtr`'s `HirId`/`Node` to point to it.
42- err. emit ( ) ;
34+ ) ;
4335 return Some ( ErrorReported ) ;
4436 }
4537 }
@@ -50,4 +42,15 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5042 }
5143 None
5244 }
45+
46+ fn emit_err ( & self , sp : Span , expected : Ty < ' tcx > , found : Ty < ' tcx > ) {
47+ let mut err = self . tcx ( ) . sess . struct_span_err (
48+ sp,
49+ "`impl` item signature doesn't match `trait` item signature" ,
50+ ) ;
51+ err. note ( & format ! ( "expected: {:?}\n found: {:?}" , expected, found) ) ;
52+ err. span_label ( sp, & format ! ( "found {:?}" , found) ) ;
53+ // FIXME: recover the `FnPtr`'s `HirId`/`Node` to point to it.
54+ err. emit ( ) ;
55+ }
5356}
0 commit comments