11//! Error Reporting for static impl Traits.
22
33use rustc_data_structures:: fx:: FxIndexSet ;
4- use rustc_errors:: { Applicability , Diag , ErrorGuaranteed , MultiSpan } ;
4+ use rustc_errors:: { Applicability , Diag , ErrorGuaranteed } ;
55use rustc_hir:: def_id:: DefId ;
66use rustc_hir:: intravisit:: { Visitor , VisitorExt , walk_ty} ;
77use rustc_hir:: {
88 self as hir, AmbigArg , GenericBound , GenericParam , GenericParamKind , Item , ItemKind , Lifetime ,
99 LifetimeName , LifetimeParamKind , MissingLifetimeKind , Node , TyKind ,
1010} ;
11- use rustc_middle:: ty:: { self , StaticLifetimeVisitor , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
11+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
1212use rustc_span:: def_id:: LocalDefId ;
1313use rustc_span:: { Ident , Span } ;
1414use tracing:: debug;
1515
1616use crate :: error_reporting:: infer:: nice_region_error:: NiceRegionError ;
17- use crate :: errors:: { ButNeedsToSatisfy , ReqIntroducedLocations } ;
18- use crate :: infer:: { RegionResolutionError , SubregionOrigin , TypeTrace } ;
19- use crate :: traits:: ObligationCauseCode ;
17+ use crate :: errors:: ButNeedsToSatisfy ;
18+ use crate :: infer:: { RegionResolutionError , SubregionOrigin } ;
2019
2120impl < ' a , ' tcx > NiceRegionError < ' a , ' tcx > {
2221 /// Print the error message for lifetime errors when the return type is a static `impl Trait`,
@@ -89,39 +88,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
8988 None
9089 } ;
9190
92- let mut subdiag = None ;
93-
94- if let SubregionOrigin :: Subtype ( box TypeTrace { cause, .. } ) = sub_origin {
95- if let ObligationCauseCode :: ReturnValue ( hir_id)
96- | ObligationCauseCode :: BlockTailExpression ( hir_id, ..) = cause. code ( )
97- {
98- let parent_id = tcx. hir ( ) . get_parent_item ( * hir_id) ;
99- if let Some ( fn_decl) = tcx. hir ( ) . fn_decl_by_hir_id ( parent_id. into ( ) ) {
100- let mut span: MultiSpan = fn_decl. output . span ( ) . into ( ) ;
101- let mut spans = Vec :: new ( ) ;
102- let mut add_label = true ;
103- if let hir:: FnRetTy :: Return ( ty) = fn_decl. output {
104- let mut v = StaticLifetimeVisitor ( vec ! [ ] , tcx. hir ( ) ) ;
105- v. visit_ty_unambig ( ty) ;
106- if !v. 0 . is_empty ( ) {
107- span = v. 0 . clone ( ) . into ( ) ;
108- spans = v. 0 ;
109- add_label = false ;
110- }
111- }
112- let fn_decl_span = fn_decl. output . span ( ) ;
113-
114- subdiag = Some ( ReqIntroducedLocations {
115- span,
116- spans,
117- fn_decl_span,
118- cause_span : cause. span ,
119- add_label,
120- } ) ;
121- }
122- }
123- }
124-
12591 let diag = ButNeedsToSatisfy {
12692 sp,
12793 influencer_point,
@@ -132,7 +98,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
13298 require_span_as_note : require_as_note. then_some ( require_span) ,
13399 // We don't need a note, it's already at the end, it can be shown as a `span_label`.
134100 require_span_as_label : ( !require_as_note) . then_some ( require_span) ,
135- req_introduces_loc : subdiag,
136101
137102 has_lifetime : sup_r. has_name ( ) ,
138103 lifetime : lifetime_name. clone ( ) ,
0 commit comments