@@ -3,7 +3,6 @@ use super::OverlapError;
3
3
use crate :: traits;
4
4
use rustc_hir:: def_id:: DefId ;
5
5
use rustc_middle:: ty:: fast_reject:: { self , SimplifiedType , TreatParams } ;
6
- use rustc_middle:: ty:: print:: with_no_trimmed_paths;
7
6
use rustc_middle:: ty:: { self , TyCtxt , TypeVisitable } ;
8
7
9
8
pub use rustc_middle:: traits:: specialization_graph:: * ;
@@ -15,15 +14,15 @@ pub enum FutureCompatOverlapErrorKind {
15
14
}
16
15
17
16
#[ derive( Debug ) ]
18
- pub struct FutureCompatOverlapError {
19
- pub error : OverlapError ,
17
+ pub struct FutureCompatOverlapError < ' tcx > {
18
+ pub error : OverlapError < ' tcx > ,
20
19
pub kind : FutureCompatOverlapErrorKind ,
21
20
}
22
21
23
22
/// The result of attempting to insert an impl into a group of children.
24
- enum Inserted {
23
+ enum Inserted < ' tcx > {
25
24
/// The impl was inserted as a new child in this group of children.
26
- BecameNewSibling ( Option < FutureCompatOverlapError > ) ,
25
+ BecameNewSibling ( Option < FutureCompatOverlapError < ' tcx > > ) ,
27
26
28
27
/// The impl should replace existing impls [X1, ..], because the impl specializes X1, X2, etc.
29
28
ReplaceChildren ( Vec < DefId > ) ,
@@ -42,12 +41,12 @@ trait ChildrenExt<'tcx> {
42
41
impl_def_id : DefId ,
43
42
simplified_self : Option < SimplifiedType > ,
44
43
overlap_mode : OverlapMode ,
45
- ) -> Result < Inserted , OverlapError > ;
44
+ ) -> Result < Inserted < ' tcx > , OverlapError < ' tcx > > ;
46
45
}
47
46
48
- impl ChildrenExt < ' _ > for Children {
47
+ impl < ' tcx > ChildrenExt < ' tcx > for Children {
49
48
/// Insert an impl into this set of children without comparing to any existing impls.
50
- fn insert_blindly ( & mut self , tcx : TyCtxt < ' _ > , impl_def_id : DefId ) {
49
+ fn insert_blindly ( & mut self , tcx : TyCtxt < ' tcx > , impl_def_id : DefId ) {
51
50
let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) ;
52
51
if let Some ( st) = fast_reject:: simplify_type ( tcx, trait_ref. self_ty ( ) , TreatParams :: AsInfer )
53
52
{
@@ -62,7 +61,7 @@ impl ChildrenExt<'_> for Children {
62
61
/// Removes an impl from this set of children. Used when replacing
63
62
/// an impl with a parent. The impl must be present in the list of
64
63
/// children already.
65
- fn remove_existing ( & mut self , tcx : TyCtxt < ' _ > , impl_def_id : DefId ) {
64
+ fn remove_existing ( & mut self , tcx : TyCtxt < ' tcx > , impl_def_id : DefId ) {
66
65
let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) ;
67
66
let vec: & mut Vec < DefId > ;
68
67
if let Some ( st) = fast_reject:: simplify_type ( tcx, trait_ref. self_ty ( ) , TreatParams :: AsInfer )
@@ -82,11 +81,11 @@ impl ChildrenExt<'_> for Children {
82
81
/// specialization relationships.
83
82
fn insert (
84
83
& mut self ,
85
- tcx : TyCtxt < ' _ > ,
84
+ tcx : TyCtxt < ' tcx > ,
86
85
impl_def_id : DefId ,
87
86
simplified_self : Option < SimplifiedType > ,
88
87
overlap_mode : OverlapMode ,
89
- ) -> Result < Inserted , OverlapError > {
88
+ ) -> Result < Inserted < ' tcx > , OverlapError < ' tcx > > {
90
89
let mut last_lint = None ;
91
90
let mut replace_children = Vec :: new ( ) ;
92
91
@@ -103,30 +102,23 @@ impl ChildrenExt<'_> for Children {
103
102
impl_def_id, simplified_self, possible_sibling,
104
103
) ;
105
104
106
- let create_overlap_error = |overlap : traits:: coherence:: OverlapResult < ' _ > | {
105
+ let create_overlap_error = |overlap : traits:: coherence:: OverlapResult < ' tcx > | {
107
106
let trait_ref = overlap. impl_header . trait_ref . unwrap ( ) ;
108
107
let self_ty = trait_ref. self_ty ( ) ;
109
108
110
- // FIXME: should postpone string formatting until we decide to actually emit.
111
- with_no_trimmed_paths ! ( {
112
- OverlapError {
113
- with_impl: possible_sibling,
114
- trait_desc: trait_ref. print_only_trait_path( ) . to_string( ) ,
115
- // Only report the `Self` type if it has at least
116
- // some outer concrete shell; otherwise, it's
117
- // not adding much information.
118
- self_desc: if self_ty. has_concrete_skeleton( ) {
119
- Some ( self_ty. to_string( ) )
120
- } else {
121
- None
122
- } ,
123
- intercrate_ambiguity_causes: overlap. intercrate_ambiguity_causes,
124
- involves_placeholder: overlap. involves_placeholder,
125
- }
126
- } )
109
+ OverlapError {
110
+ with_impl : possible_sibling,
111
+ trait_ref,
112
+ // Only report the `Self` type if it has at least
113
+ // some outer concrete shell; otherwise, it's
114
+ // not adding much information.
115
+ self_ty : if self_ty. has_concrete_skeleton ( ) { Some ( self_ty) } else { None } ,
116
+ intercrate_ambiguity_causes : overlap. intercrate_ambiguity_causes ,
117
+ involves_placeholder : overlap. involves_placeholder ,
118
+ }
127
119
} ;
128
120
129
- let report_overlap_error = |overlap : traits:: coherence:: OverlapResult < ' _ > ,
121
+ let report_overlap_error = |overlap : traits:: coherence:: OverlapResult < ' tcx > ,
130
122
last_lint : & mut _ | {
131
123
// Found overlap, but no specialization; error out or report future-compat warning.
132
124
@@ -255,31 +247,31 @@ where
255
247
}
256
248
}
257
249
258
- pub trait GraphExt {
250
+ pub trait GraphExt < ' tcx > {
259
251
/// Insert a local impl into the specialization graph. If an existing impl
260
252
/// conflicts with it (has overlap, but neither specializes the other),
261
253
/// information about the area of overlap is returned in the `Err`.
262
254
fn insert (
263
255
& mut self ,
264
- tcx : TyCtxt < ' _ > ,
256
+ tcx : TyCtxt < ' tcx > ,
265
257
impl_def_id : DefId ,
266
258
overlap_mode : OverlapMode ,
267
- ) -> Result < Option < FutureCompatOverlapError > , OverlapError > ;
259
+ ) -> Result < Option < FutureCompatOverlapError < ' tcx > > , OverlapError < ' tcx > > ;
268
260
269
261
/// Insert cached metadata mapping from a child impl back to its parent.
270
- fn record_impl_from_cstore ( & mut self , tcx : TyCtxt < ' _ > , parent : DefId , child : DefId ) ;
262
+ fn record_impl_from_cstore ( & mut self , tcx : TyCtxt < ' tcx > , parent : DefId , child : DefId ) ;
271
263
}
272
264
273
- impl GraphExt for Graph {
265
+ impl < ' tcx > GraphExt < ' tcx > for Graph {
274
266
/// Insert a local impl into the specialization graph. If an existing impl
275
267
/// conflicts with it (has overlap, but neither specializes the other),
276
268
/// information about the area of overlap is returned in the `Err`.
277
269
fn insert (
278
270
& mut self ,
279
- tcx : TyCtxt < ' _ > ,
271
+ tcx : TyCtxt < ' tcx > ,
280
272
impl_def_id : DefId ,
281
273
overlap_mode : OverlapMode ,
282
- ) -> Result < Option < FutureCompatOverlapError > , OverlapError > {
274
+ ) -> Result < Option < FutureCompatOverlapError < ' tcx > > , OverlapError < ' tcx > > {
283
275
assert ! ( impl_def_id. is_local( ) ) ;
284
276
285
277
let trait_ref = tcx. impl_trait_ref ( impl_def_id) . unwrap ( ) ;
@@ -376,7 +368,7 @@ impl GraphExt for Graph {
376
368
}
377
369
378
370
/// Insert cached metadata mapping from a child impl back to its parent.
379
- fn record_impl_from_cstore ( & mut self , tcx : TyCtxt < ' _ > , parent : DefId , child : DefId ) {
371
+ fn record_impl_from_cstore ( & mut self , tcx : TyCtxt < ' tcx > , parent : DefId , child : DefId ) {
380
372
if self . parent . insert ( child, parent) . is_some ( ) {
381
373
bug ! (
382
374
"When recording an impl from the crate store, information about its parent \
0 commit comments