@@ -1215,10 +1215,12 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o {
12151215 type_str : & str ,
12161216 trait_str : & str ,
12171217 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+
12221224 }
12231225
12241226 // 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 {
20952097
20962098 if !trait_bounds. is_empty ( ) {
20972099 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 ( ) ;
21002105 }
21012106
21022107 let region_bound =
@@ -2255,20 +2260,27 @@ fn check_type_argument_count(tcx: TyCtxt, span: Span, supplied: usize,
22552260 } else {
22562261 "expected"
22572262 } ;
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 ( ) ;
22612269 } 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)
22642274 } else {
2265- "expected"
2275+ format ! ( "expected {}" , accepted )
22662276 } ;
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 ( ) ;
22722284 }
22732285}
22742286
0 commit comments