@@ -202,7 +202,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
202
202
& obligation. cause . code ,
203
203
& mut vec ! [ ] ,
204
204
& mut Default :: default ( ) ,
205
- None ,
206
205
) ;
207
206
208
207
err. emit ( ) ;
@@ -233,7 +232,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
233
232
) {
234
233
let tcx = self . tcx ;
235
234
let span = obligation. cause . span ;
236
- let mut obligation_note = None ;
237
235
238
236
let mut err = match * error {
239
237
SelectionError :: Unimplemented => {
@@ -261,7 +259,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
261
259
262
260
let bound_predicate = obligation. predicate . kind ( ) ;
263
261
match bound_predicate. skip_binder ( ) {
264
- ty:: PredicateKind :: Trait ( trait_predicate, _, implicit ) => {
262
+ ty:: PredicateKind :: Trait ( trait_predicate, _, _ ) => {
265
263
let trait_predicate = bound_predicate. rebind ( trait_predicate) ;
266
264
let trait_predicate = self . resolve_vars_if_possible ( trait_predicate) ;
267
265
@@ -313,61 +311,6 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
313
311
post_message,
314
312
) )
315
313
) ;
316
- if let ty:: ImplicitTraitPredicate :: Yes = implicit {
317
- if let ObligationCauseCode :: BindingObligation ( item_def_id, _) =
318
- obligation. cause . code . peel_derives ( )
319
- {
320
- match self . tcx . hir ( ) . get_if_local ( * item_def_id) {
321
- Some ( hir:: Node :: TraitItem ( hir:: TraitItem {
322
- kind : hir:: TraitItemKind :: Type ( bounds, ty) ,
323
- ident,
324
- ..
325
- } ) ) => {
326
- obligation_note = Some (
327
- "associated types introduce an implicit `Sized` \
328
- obligation",
329
- ) ;
330
- match ( bounds, ty) {
331
- ( [ ] , None ) => {
332
- err. span_suggestion_verbose (
333
- ident. span . shrink_to_hi ( ) ,
334
- "consider relaxing the `Sized` obligation" ,
335
- ": ?Sized" . to_string ( ) ,
336
- Applicability :: MaybeIncorrect ,
337
- ) ;
338
- }
339
- ( [ .., bound] , None ) => {
340
- err. span_suggestion_verbose (
341
- bound. span ( ) . shrink_to_hi ( ) ,
342
- "consider relaxing the `Sized` obligation" ,
343
- " + ?Sized" . to_string ( ) ,
344
- Applicability :: MaybeIncorrect ,
345
- ) ;
346
- }
347
- _ => { }
348
- }
349
- }
350
- Some ( hir:: Node :: ImplItem ( hir:: ImplItem {
351
- kind : hir:: ImplItemKind :: TyAlias ( _) ,
352
- ..
353
- } ) ) => {
354
- obligation_note = Some (
355
- "associated types on `impl` blocks for types, have an \
356
- implicit mandatory `Sized` obligation; associated \
357
- types from `trait`s can be relaxed to `?Sized`",
358
- ) ;
359
- }
360
- _ => {
361
- // This is (likely?) a type parameter. The suggestion is handled
362
- // in `rustc_middle/src/ty/diagnostics.rs`.
363
- obligation_note = Some (
364
- "type parameters introduce an implicit `Sized` \
365
- obligation",
366
- ) ;
367
- }
368
- }
369
- }
370
- }
371
314
372
315
if is_try_conversion {
373
316
let none_error = self
@@ -425,7 +368,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
425
368
points_at_arg,
426
369
have_alt_message,
427
370
) {
428
- self . note_obligation_cause ( & mut err, obligation, obligation_note ) ;
371
+ self . note_obligation_cause ( & mut err, obligation) ;
429
372
err. emit ( ) ;
430
373
return ;
431
374
}
@@ -854,7 +797,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
854
797
}
855
798
} ;
856
799
857
- self . note_obligation_cause ( & mut err, obligation, obligation_note ) ;
800
+ self . note_obligation_cause ( & mut err, obligation) ;
858
801
self . point_at_returns_when_relevant ( & mut err, & obligation) ;
859
802
860
803
err. emit ( ) ;
@@ -1137,7 +1080,6 @@ trait InferCtxtPrivExt<'tcx> {
1137
1080
& self ,
1138
1081
err : & mut DiagnosticBuilder < ' tcx > ,
1139
1082
obligation : & PredicateObligation < ' tcx > ,
1140
- note : Option < & str > ,
1141
1083
) ;
1142
1084
1143
1085
fn suggest_unsized_bound_if_applicable (
@@ -1287,6 +1229,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1287
1229
obligation. cause. code. peel_derives( ) ,
1288
1230
ObligationCauseCode :: ItemObligation ( _)
1289
1231
| ObligationCauseCode :: BindingObligation ( _, _)
1232
+ | ObligationCauseCode :: ImplicitSizedObligation ( _, _)
1290
1233
| ObligationCauseCode :: ObjectCastObligation ( _)
1291
1234
| ObligationCauseCode :: OpaqueType
1292
1235
) ;
@@ -1358,7 +1301,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1358
1301
_ => None ,
1359
1302
} ;
1360
1303
self . note_type_err ( & mut diag, & obligation. cause , secondary_span, values, err, true ) ;
1361
- self . note_obligation_cause ( & mut diag, obligation, None ) ;
1304
+ self . note_obligation_cause ( & mut diag, obligation) ;
1362
1305
diag. emit ( ) ;
1363
1306
}
1364
1307
} ) ;
@@ -1651,7 +1594,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1651
1594
self . suggest_fully_qualified_path ( & mut err, def_id, span, trait_ref. def_id ( ) ) ;
1652
1595
} else if let (
1653
1596
Ok ( ref snippet) ,
1654
- ObligationCauseCode :: BindingObligation ( ref def_id, _) ,
1597
+ ObligationCauseCode :: BindingObligation ( ref def_id, _)
1598
+ | ObligationCauseCode :: ImplicitSizedObligation ( ref def_id, _) ,
1655
1599
) =
1656
1600
( self . tcx . sess . source_map ( ) . span_to_snippet ( span) , & obligation. cause . code )
1657
1601
{
@@ -1767,7 +1711,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1767
1711
err
1768
1712
}
1769
1713
} ;
1770
- self . note_obligation_cause ( & mut err, obligation, None ) ;
1714
+ self . note_obligation_cause ( & mut err, obligation) ;
1771
1715
err. emit ( ) ;
1772
1716
}
1773
1717
@@ -1831,7 +1775,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1831
1775
& self ,
1832
1776
err : & mut DiagnosticBuilder < ' tcx > ,
1833
1777
obligation : & PredicateObligation < ' tcx > ,
1834
- note : Option < & str > ,
1835
1778
) {
1836
1779
// First, attempt to add note to this error with an async-await-specific
1837
1780
// message, and fall back to regular note otherwise.
@@ -1842,7 +1785,6 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1842
1785
& obligation. cause . code ,
1843
1786
& mut vec ! [ ] ,
1844
1787
& mut Default :: default ( ) ,
1845
- note,
1846
1788
) ;
1847
1789
self . suggest_unsized_bound_if_applicable ( err, obligation) ;
1848
1790
}
@@ -1858,7 +1800,8 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
1858
1800
{
1859
1801
(
1860
1802
ty:: PredicateKind :: Trait ( pred, _, _) ,
1861
- & ObligationCauseCode :: BindingObligation ( item_def_id, span) ,
1803
+ & ObligationCauseCode :: BindingObligation ( item_def_id, span)
1804
+ | & ObligationCauseCode :: ImplicitSizedObligation ( item_def_id, span) ,
1862
1805
) => ( pred, item_def_id, span) ,
1863
1806
_ => return ,
1864
1807
} ;
0 commit comments