@@ -296,26 +296,28 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
296
296
// as it seems confusing to report an error about
297
297
// extraneous predicates created by things like
298
298
// an associated type inside the trait.
299
-
299
+ let mut err = None ;
300
300
if !items. is_empty ( ) {
301
301
error_380 ( self . ccx , span) ;
302
302
} else if has_ty_params {
303
- span_err ! ( self . tcx( ) . sess, span, E0566 ,
304
- "traits with auto impls (`e.g. unsafe impl \
305
- Trait for ..`) can not have type parameters")
303
+ err = Some ( struct_span_err ! ( self . tcx( ) . sess, span, E0566 ,
304
+ "traits with auto impls (`e.g. impl \
305
+ Trait for ..`) can not have type parameters") ) ;
306
306
} else if has_predicates {
307
- span_err ! ( self . tcx( ) . sess, span, E0565 ,
308
- "traits with auto impls (`e.g. unsafe impl \
309
- Trait for ..`) can not have predicates")
307
+ err = Some ( struct_span_err ! ( self . tcx( ) . sess, span, E0565 ,
308
+ "traits with auto impls (`e.g. impl \
309
+ Trait for ..`) cannot have predicates") ) ;
310
310
}
311
311
312
312
// Finally if either of the above conditions apply we should add a note
313
313
// indicating that this error is the result of a recent soundness fix.
314
- if has_ty_params || has_predicates {
315
- self . tcx ( ) . sess . span_note_without_error (
316
- span,
317
- "the new auto trait rules are the result of a \
318
- recent soundness fix; see #29859 for more details")
314
+ match err {
315
+ None => { } ,
316
+ Some ( mut e) => {
317
+ e. note ( "the new auto trait rules are the result of a \
318
+ recent soundness fix; see #29859 for more details") ;
319
+ e. emit ( ) ;
320
+ }
319
321
}
320
322
}
321
323
@@ -325,8 +327,6 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
325
327
{
326
328
let trait_def_id = self . tcx ( ) . map . local_def_id ( item. id ) ;
327
329
328
- // TODO: in a second pass, globally rename to auto_trait,
329
- // from default_impl.
330
330
if self . tcx ( ) . trait_has_default_impl ( trait_def_id) {
331
331
self . check_auto_trait ( trait_def_id, items, item. span ) ;
332
332
}
@@ -701,7 +701,7 @@ fn error_192(ccx: &CrateCtxt, span: Span) {
701
701
702
702
fn error_380 ( ccx : & CrateCtxt , span : Span ) {
703
703
span_err ! ( ccx. tcx. sess, span, E0380 ,
704
- "traits with default impls (`e.g. unsafe impl \
704
+ "traits with default impls (`e.g. impl \
705
705
Trait for ..`) must have no methods or associated items")
706
706
}
707
707
0 commit comments