@@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
1215
1215
type_str : & str ,
1216
1216
trait_str : & str ,
1217
1217
name : & str ) {
1218
- span_err ! ( self . tcx( ) . sess, span, E0223 ,
1219
- "ambiguous associated type; specify the type using the syntax \
1220
- `<{} as {}>::{}`",
1221
- type_str, trait_str, name) ;
1218
+ struct_span_err ! ( self . tcx( ) . sess, span, E0223 , "ambiguous associated type" )
1219
+ . span_label ( span, & format ! ( "ambiguous associated type" ) )
1220
+ . note ( & format ! ( "specify the type using the syntax `<{} as {}>::{}`" ,
1221
+ type_str, trait_str, name) )
1222
+ . emit ( ) ;
1223
+
1222
1224
}
1223
1225
1224
1226
// Search for a bound on a type parameter which includes the associated item
@@ -2095,8 +2097,11 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
2095
2097
2096
2098
if !trait_bounds. is_empty ( ) {
2097
2099
let b = & trait_bounds[ 0 ] ;
2098
- span_err ! ( self . tcx( ) . sess, b. trait_ref. path. span, E0225 ,
2099
- "only the builtin traits can be used as closure or object bounds" ) ;
2100
+ let span = b. trait_ref . path . span ;
2101
+ struct_span_err ! ( self . tcx( ) . sess, span, E0225 ,
2102
+ "only the builtin traits can be used as closure or object bounds" )
2103
+ . span_label ( span, & format ! ( "non-builtin trait used as bounds" ) )
2104
+ . emit ( ) ;
2100
2105
}
2101
2106
2102
2107
let region_bound =
@@ -2255,20 +2260,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
2255
2260
} else {
2256
2261
"expected"
2257
2262
} ;
2258
- span_err ! ( tcx. sess, span, E0243 ,
2259
- "wrong number of type arguments: {} {}, found {}" ,
2260
- expected, required, supplied) ;
2263
+ struct_span_err ! ( tcx. sess, span, E0243 , "wrong number of type arguments" )
2264
+ . span_label (
2265
+ span,
2266
+ & format ! ( "{} {} type arguments, found {}" , expected, required, supplied)
2267
+ )
2268
+ . emit ( ) ;
2261
2269
} else if supplied > accepted {
2262
- let expected = if required < accepted {
2263
- "expected at most"
2270
+ let expected = if required == 0 {
2271
+ "expected no" . to_string ( )
2272
+ } else if required < accepted {
2273
+ format ! ( "expected at most {}" , accepted)
2264
2274
} else {
2265
- "expected"
2275
+ format ! ( "expected {}" , accepted )
2266
2276
} ;
2267
- span_err ! ( tcx. sess, span, E0244 ,
2268
- "wrong number of type arguments: {} {}, found {}" ,
2269
- expected,
2270
- accepted,
2271
- supplied) ;
2277
+
2278
+ struct_span_err ! ( tcx. sess, span, E0244 , "wrong number of type arguments" )
2279
+ . span_label (
2280
+ span,
2281
+ & format ! ( "{} type arguments, found {}" , expected, supplied)
2282
+ )
2283
+ . emit ( ) ;
2272
2284
}
2273
2285
}
2274
2286
0 commit comments