33use rustc_errors:: ErrorGuaranteed ;
44use rustc_hir as hir;
55use rustc_hir:: def:: { Namespace , Res } ;
6- use rustc_hir:: def_id:: DefId ;
6+ use rustc_hir:: def_id:: { DefId , LocalDefId } ;
77use rustc_hir:: intravisit:: Visitor ;
88use rustc_middle:: hir:: nested_filter;
99use rustc_middle:: traits:: ObligationCauseCode ;
@@ -33,14 +33,21 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
3333 _,
3434 ) = error. clone ( )
3535 && 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 ( )
3839 && sub_trace. values == sup_trace. values
3940 && let ValuePairs :: PolySigs ( ExpectedFound { expected, found } ) = sub_trace. values
4041 {
4142 // FIXME(compiler-errors): Don't like that this needs `Ty`s, but
4243 // 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+ ) ;
4451 return Some ( guar) ;
4552 }
4653 None
@@ -52,6 +59,7 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
5259 expected : ty:: PolyFnSig < ' tcx > ,
5360 found : ty:: PolyFnSig < ' tcx > ,
5461 trait_item_def_id : DefId ,
62+ impl_item_def_id : LocalDefId ,
5563 ) -> ErrorGuaranteed {
5664 let trait_sp = self . tcx ( ) . def_span ( trait_item_def_id) ;
5765
@@ -82,18 +90,25 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8290
8391 let expected_highlight = HighlightBuilder :: build ( expected) ;
8492 let tcx = self . cx . tcx ;
85- let expected = Highlighted {
93+ let mut expected = Highlighted {
8694 highlight : expected_highlight,
8795 ns : Namespace :: TypeNS ,
8896 tcx,
8997 value : expected,
9098 }
9199 . to_string ( ) ;
100+ if tcx. codegen_fn_attrs ( trait_item_def_id) . safe_target_features {
101+ expected = format ! ( "#[target_features] {expected}" ) ;
102+ }
92103 let found_highlight = HighlightBuilder :: build ( found) ;
93- let found =
104+ let mut found =
94105 Highlighted { highlight : found_highlight, ns : Namespace :: TypeNS , tcx, value : found }
95106 . to_string ( ) ;
96107
108+ if tcx. codegen_fn_attrs ( impl_item_def_id) . safe_target_features {
109+ found = format ! ( "#[target_features] {found}" ) ;
110+ }
111+
97112 // Get the span of all the used type parameters in the method.
98113 let assoc_item = self . tcx ( ) . associated_item ( trait_item_def_id) ;
99114 let mut visitor = TypeParamSpanVisitor { tcx : self . tcx ( ) , types : vec ! [ ] } ;
0 commit comments