1
1
//! Error Reporting for `impl` items that do not match the obligations from their `trait`.
2
2
3
+ use syntax_pos:: Span ;
4
+ use crate :: ty:: Ty ;
3
5
use crate :: infer:: { ValuePairs , Subtype } ;
4
6
use crate :: infer:: error_reporting:: nice_region_error:: NiceRegionError ;
5
7
use crate :: infer:: lexical_region_resolve:: RegionResolutionError ;
@@ -25,21 +27,11 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
25
27
) = ( & sub_trace. values , & sup_trace. values ) {
26
28
if sup_expected_found == sub_expected_found {
27
29
let sp = var_origin. span ( ) ;
28
- let mut err = self . tcx ( ) . sess . struct_span_err (
30
+ self . emit_err (
29
31
sp,
30
- "`impl` item doesn't match `trait` item"
31
- ) ;
32
- err. note ( & format ! (
33
- "expected: {:?}\n found: {:?}" ,
34
32
sub_expected_found. expected ,
35
33
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
+ ) ;
43
35
return Some ( ErrorReported ) ;
44
36
}
45
37
}
@@ -50,4 +42,15 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
50
42
}
51
43
None
52
44
}
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
+ }
53
56
}
0 commit comments