@@ -33,10 +33,12 @@ struct OrphanChecker<'cx, 'tcx:'cx> {
33
33
impl < ' cx , ' tcx > OrphanChecker < ' cx , ' tcx > {
34
34
fn check_def_id ( & self , item : & hir:: Item , def_id : DefId ) {
35
35
if def_id. krate != LOCAL_CRATE {
36
- span_err ! ( self . tcx. sess, item. span, E0116 ,
36
+ struct_span_err ! ( self . tcx. sess, item. span, E0116 ,
37
37
"cannot define inherent `impl` for a type outside of the \
38
- crate where the type is defined; define and implement \
39
- a trait or new type instead") ;
38
+ crate where the type is defined")
39
+ . span_label ( item. span , & format ! ( "impl for type defined outside of crate." ) )
40
+ . span_note ( item. span , & format ! ( "define and implement a trait or new type instead" ) )
41
+ . emit ( ) ;
40
42
}
41
43
}
42
44
@@ -66,7 +68,7 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
66
68
fn check_item ( & self , item : & hir:: Item ) {
67
69
let def_id = self . tcx . map . local_def_id ( item. id ) ;
68
70
match item. node {
69
- hir:: ItemImpl ( _, _, _, None , _ , _) => {
71
+ hir:: ItemImpl ( _, _, _, None , ref ty , _) => {
70
72
// For inherent impls, self type must be a nominal type
71
73
// defined in this crate.
72
74
debug ! ( "coherence2::orphan check: inherent impl {}" ,
@@ -209,11 +211,11 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
209
211
return ;
210
212
}
211
213
_ => {
212
- struct_span_err ! ( self . tcx. sess, item . span, E0118 ,
214
+ struct_span_err ! ( self . tcx. sess, ty . span, E0118 ,
213
215
"no base type found for inherent implementation" )
214
- . span_help ( item . span ,
215
- "either implement a trait on it or create a newtype to wrap it \
216
- instead")
216
+ . span_label ( ty . span , & format ! ( "impl requires a base type" ) )
217
+ . note ( & format ! ( "either implement a trait on it or create a newtype \
218
+ to wrap it instead") )
217
219
. emit ( ) ;
218
220
return ;
219
221
}
@@ -228,12 +230,14 @@ impl<'cx, 'tcx> OrphanChecker<'cx, 'tcx> {
228
230
match traits:: orphan_check ( self . tcx , def_id) {
229
231
Ok ( ( ) ) => { }
230
232
Err ( traits:: OrphanCheckErr :: NoLocalInputType ) => {
231
- span_err ! (
233
+ struct_span_err ! (
232
234
self . tcx. sess, item. span, E0117 ,
233
- "the impl does not reference any \
234
- types defined in this crate; \
235
- only traits defined in the current crate can be \
236
- implemented for arbitrary types") ;
235
+ "only traits defined in the current crate can be \
236
+ implemented for arbitrary types")
237
+ . span_label ( item. span , & format ! ( "impl doesn't use types inside crate" ) )
238
+ . note ( & format ! ( "the impl does not reference any \
239
+ types defined in this crate") )
240
+ . emit ( ) ;
237
241
return ;
238
242
}
239
243
Err ( traits:: OrphanCheckErr :: UncoveredTy ( param_ty) ) => {
0 commit comments