@@ -296,26 +296,28 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
296296 // as it seems confusing to report an error about
297297 // extraneous predicates created by things like
298298 // an associated type inside the trait.
299-
299+ let mut err = None ;
300300 if !items. is_empty ( ) {
301301 error_380 ( self . ccx , span) ;
302302 } 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") ) ;
306306 } 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") ) ;
310310 }
311311
312312 // Finally if either of the above conditions apply we should add a note
313313 // 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+ }
319321 }
320322 }
321323
@@ -325,8 +327,6 @@ impl<'ccx, 'gcx> CheckTypeWellFormedVisitor<'ccx, 'gcx> {
325327 {
326328 let trait_def_id = self . tcx ( ) . map . local_def_id ( item. id ) ;
327329
328- // TODO: in a second pass, globally rename to auto_trait,
329- // from default_impl.
330330 if self . tcx ( ) . trait_has_default_impl ( trait_def_id) {
331331 self . check_auto_trait ( trait_def_id, items, item. span ) ;
332332 }
@@ -701,7 +701,7 @@ fn error_192(ccx: &CrateCtxt, span: Span) {
701701
702702fn error_380 ( ccx : & CrateCtxt , span : Span ) {
703703 span_err ! ( ccx. tcx. sess, span, E0380 ,
704- "traits with default impls (`e.g. unsafe impl \
704+ "traits with default impls (`e.g. impl \
705705 Trait for ..`) must have no methods or associated items")
706706}
707707
0 commit comments