1
1
//! Error Reporting for static impl Traits.
2
2
3
3
use rustc_data_structures:: fx:: FxIndexSet ;
4
- use rustc_errors:: { Applicability , Diag , ErrorGuaranteed , MultiSpan } ;
4
+ use rustc_errors:: { Applicability , Diag , ErrorGuaranteed } ;
5
5
use rustc_hir:: def_id:: DefId ;
6
6
use rustc_hir:: intravisit:: { Visitor , VisitorExt , walk_ty} ;
7
7
use rustc_hir:: {
8
8
self as hir, AmbigArg , GenericBound , GenericParam , GenericParamKind , Item , ItemKind , Lifetime ,
9
9
LifetimeName , LifetimeParamKind , MissingLifetimeKind , Node , TyKind ,
10
10
} ;
11
- use rustc_middle:: ty:: { self , StaticLifetimeVisitor , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
11
+ use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
12
12
use rustc_span:: def_id:: LocalDefId ;
13
13
use rustc_span:: { Ident , Span } ;
14
14
use tracing:: debug;
15
15
16
16
use 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 } ;
20
19
21
20
impl < ' a , ' tcx > NiceRegionError < ' a , ' tcx > {
22
21
/// 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> {
89
88
None
90
89
} ;
91
90
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
-
125
91
let diag = ButNeedsToSatisfy {
126
92
sp,
127
93
influencer_point,
@@ -132,7 +98,6 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
132
98
require_span_as_note : require_as_note. then_some ( require_span) ,
133
99
// We don't need a note, it's already at the end, it can be shown as a `span_label`.
134
100
require_span_as_label : ( !require_as_note) . then_some ( require_span) ,
135
- req_introduces_loc : subdiag,
136
101
137
102
has_lifetime : sup_r. has_name ( ) ,
138
103
lifetime : lifetime_name. clone ( ) ,
0 commit comments