3
3
use rustc_errors:: ErrorGuaranteed ;
4
4
use rustc_hir as hir;
5
5
use rustc_hir:: def:: { Namespace , Res } ;
6
- use rustc_hir:: def_id:: DefId ;
6
+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
7
7
use rustc_hir:: intravisit:: Visitor ;
8
8
use rustc_middle:: hir:: nested_filter;
9
9
use rustc_middle:: traits:: ObligationCauseCode ;
@@ -33,14 +33,21 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
33
33
_,
34
34
) = error. clone ( )
35
35
&& let ( Subtype ( sup_trace) , Subtype ( sub_trace) ) = ( & sup_origin, & sub_origin)
36
- && let & ObligationCauseCode :: CompareImplItem { trait_item_def_id, .. } =
37
- sub_trace. cause . code ( )
36
+ && let & ObligationCauseCode :: CompareImplItem {
37
+ trait_item_def_id, impl_item_def_id, ..
38
+ } = sub_trace. cause . code ( )
38
39
&& sub_trace. values == sup_trace. values
39
40
&& let ValuePairs :: PolySigs ( ExpectedFound { expected, found } ) = sub_trace. values
40
41
{
41
42
// FIXME(compiler-errors): Don't like that this needs `Ty`s, but
42
43
// all of the region highlighting machinery only deals with those.
43
- let guar = self . emit_err ( var_origin. span ( ) , expected, found, trait_item_def_id) ;
44
+ let guar = self . emit_err (
45
+ var_origin. span ( ) ,
46
+ expected,
47
+ found,
48
+ trait_item_def_id,
49
+ impl_item_def_id,
50
+ ) ;
44
51
return Some ( guar) ;
45
52
}
46
53
None
@@ -52,6 +59,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
52
59
expected : ty:: PolyFnSig < ' tcx > ,
53
60
found : ty:: PolyFnSig < ' tcx > ,
54
61
trait_item_def_id : DefId ,
62
+ impl_item_def_id : LocalDefId ,
55
63
) -> ErrorGuaranteed {
56
64
let trait_sp = self . tcx ( ) . def_span ( trait_item_def_id) ;
57
65
@@ -82,18 +90,25 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
82
90
83
91
let expected_highlight = HighlightBuilder :: build ( expected) ;
84
92
let tcx = self . cx . tcx ;
85
- let expected = Highlighted {
93
+ let mut expected = Highlighted {
86
94
highlight : expected_highlight,
87
95
ns : Namespace :: TypeNS ,
88
96
tcx,
89
97
value : expected,
90
98
}
91
99
. to_string ( ) ;
100
+ if tcx. codegen_fn_attrs ( trait_item_def_id) . safe_target_features {
101
+ expected = format ! ( "#[target_features] {expected}" ) ;
102
+ }
92
103
let found_highlight = HighlightBuilder :: build ( found) ;
93
- let found =
104
+ let mut found =
94
105
Highlighted { highlight : found_highlight, ns : Namespace :: TypeNS , tcx, value : found }
95
106
. to_string ( ) ;
96
107
108
+ if tcx. codegen_fn_attrs ( impl_item_def_id) . safe_target_features {
109
+ found = format ! ( "#[target_features] {found}" ) ;
110
+ }
111
+
97
112
// Get the span of all the used type parameters in the method.
98
113
let assoc_item = self . tcx ( ) . associated_item ( trait_item_def_id) ;
99
114
let mut visitor = TypeParamSpanVisitor { tcx : self . tcx ( ) , types : vec ! [ ] } ;
0 commit comments