@@ -9,7 +9,7 @@ use rustc_middle::hir::nested_filter;
9
9
use rustc_middle:: traits:: ObligationCauseCode ;
10
10
use rustc_middle:: ty:: error:: ExpectedFound ;
11
11
use rustc_middle:: ty:: print:: RegionHighlightMode ;
12
- use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitor } ;
12
+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitable } ;
13
13
use rustc_span:: Span ;
14
14
use tracing:: debug;
15
15
@@ -39,12 +39,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
39
39
{
40
40
// FIXME(compiler-errors): Don't like that this needs `Ty`s, but
41
41
// all of the region highlighting machinery only deals with those.
42
- let guar = self . emit_err (
43
- var_origin. span ( ) ,
44
- Ty :: new_fn_ptr ( self . cx . tcx , expected) ,
45
- Ty :: new_fn_ptr ( self . cx . tcx , found) ,
46
- * trait_item_def_id,
47
- ) ;
42
+ let guar = self . emit_err ( var_origin. span ( ) , expected, found, trait_item_def_id) ;
48
43
return Some ( guar) ;
49
44
}
50
45
None
@@ -53,8 +48,8 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
53
48
fn emit_err (
54
49
& self ,
55
50
sp : Span ,
56
- expected : Ty < ' tcx > ,
57
- found : Ty < ' tcx > ,
51
+ expected : ty :: PolyFnSig < ' tcx > ,
52
+ found : ty :: PolyFnSig < ' tcx > ,
58
53
trait_def_id : DefId ,
59
54
) -> ErrorGuaranteed {
60
55
let trait_sp = self . tcx ( ) . def_span ( trait_def_id) ;
@@ -67,10 +62,10 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
67
62
}
68
63
69
64
impl < ' tcx > HighlightBuilder < ' tcx > {
70
- fn build ( ty : Ty < ' tcx > ) -> RegionHighlightMode < ' tcx > {
65
+ fn build ( sig : ty :: PolyFnSig < ' tcx > ) -> RegionHighlightMode < ' tcx > {
71
66
let mut builder =
72
67
HighlightBuilder { highlight : RegionHighlightMode :: default ( ) , counter : 1 } ;
73
- builder . visit_ty ( ty ) ;
68
+ sig . visit_with ( & mut builder ) ;
74
69
builder. highlight
75
70
}
76
71
}
@@ -85,13 +80,22 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
85
80
}
86
81
87
82
let expected_highlight = HighlightBuilder :: build ( expected) ;
83
+ let tcx = self . cx . tcx ;
88
84
let expected = self
89
85
. cx
90
- . extract_inference_diagnostics_data ( expected. into ( ) , Some ( expected_highlight) )
86
+ . extract_inference_diagnostics_data (
87
+ Ty :: new_fn_ptr ( tcx, expected) . into ( ) ,
88
+ Some ( expected_highlight) ,
89
+ )
91
90
. name ;
92
91
let found_highlight = HighlightBuilder :: build ( found) ;
93
- let found =
94
- self . cx . extract_inference_diagnostics_data ( found. into ( ) , Some ( found_highlight) ) . name ;
92
+ let found = self
93
+ . cx
94
+ . extract_inference_diagnostics_data (
95
+ Ty :: new_fn_ptr ( tcx, found) . into ( ) ,
96
+ Some ( found_highlight) ,
97
+ )
98
+ . name ;
95
99
96
100
// Get the span of all the used type parameters in the method.
97
101
let assoc_item = self . tcx ( ) . associated_item ( trait_def_id) ;
0 commit comments