@@ -100,8 +100,7 @@ pub trait AstConv<'tcx> {
100100 -> Ty < ' tcx >
101101 {
102102 if ty:: binds_late_bound_regions ( self . tcx ( ) , & poly_trait_ref) {
103- self . tcx ( ) . sess . span_err (
104- span,
103+ span_err ! ( self . tcx( ) . sess, span, E0212 ,
105104 "cannot extract an associated type from a higher-ranked trait bound \
106105 in this context") ;
107106 self . tcx ( ) . types . err
@@ -119,8 +118,7 @@ pub trait AstConv<'tcx> {
119118 _item_name : ast:: Name )
120119 -> Ty < ' tcx >
121120 {
122- self . tcx ( ) . sess . span_err (
123- span,
121+ span_err ! ( self . tcx( ) . sess, span, E0213 ,
124122 "associated types are not accepted in this context" ) ;
125123
126124 self . tcx ( ) . types . err
@@ -268,8 +266,7 @@ pub fn ast_path_substs_for_ty<'tcx>(
268266 convert_angle_bracketed_parameters ( this, rscope, data)
269267 }
270268 ast:: ParenthesizedParameters ( ref data) => {
271- tcx. sess . span_err (
272- path. span ,
269+ span_err ! ( tcx. sess, path. span, E0214 ,
273270 "parenthesized parameters may only be used with a trait" ) ;
274271 ( Vec :: new ( ) , convert_parenthesized_parameters ( this, data) , Vec :: new ( ) )
275272 }
@@ -610,7 +607,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
610607 if !this. tcx ( ) . sess . features . borrow ( ) . unboxed_closures &&
611608 this. tcx ( ) . lang_items . fn_trait_kind ( trait_def_id) . is_some ( )
612609 {
613- this. tcx ( ) . sess . span_err ( path. span ,
610+ span_err ! ( this. tcx( ) . sess, path. span, E0215 ,
614611 "angle-bracket notation is not stable when \
615612 used with the `Fn` family of traits, use parentheses") ;
616613 span_help ! ( this. tcx( ) . sess, path. span,
@@ -626,7 +623,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
626623 if !this. tcx ( ) . sess . features . borrow ( ) . unboxed_closures &&
627624 this. tcx ( ) . lang_items . fn_trait_kind ( trait_def_id) . is_none ( )
628625 {
629- this. tcx ( ) . sess . span_err ( path. span ,
626+ span_err ! ( this. tcx( ) . sess, path. span, E0216 ,
630627 "parenthetical notation is only stable when \
631628 used with the `Fn` family of traits") ;
632629 span_help ! ( this. tcx( ) . sess, path. span,
@@ -738,32 +735,29 @@ fn ast_type_binding_to_projection_predicate<'tcx>(
738735 }
739736
740737 if candidates. len ( ) > 1 {
741- tcx. sess . span_err (
742- binding. span ,
743- format ! ( "ambiguous associated type: `{}` defined in multiple supertraits `{}`" ,
738+ span_err ! ( tcx. sess, binding. span, E0217 ,
739+ "ambiguous associated type: `{}` defined in multiple supertraits `{}`" ,
744740 token:: get_name( binding. item_name) ,
745- candidates. user_string( tcx) ) . as_slice ( ) ) ;
741+ candidates. user_string( tcx) ) ;
746742 return Err ( ErrorReported ) ;
747743 }
748744
749745 let candidate = match candidates. pop ( ) {
750746 Some ( c) => c,
751747 None => {
752- tcx. sess . span_err (
753- binding. span ,
754- format ! ( "no associated type `{}` defined in `{}`" ,
748+ span_err ! ( tcx. sess, binding. span, E0218 ,
749+ "no associated type `{}` defined in `{}`" ,
755750 token:: get_name( binding. item_name) ,
756- trait_ref. user_string( tcx) ) . as_slice ( ) ) ;
751+ trait_ref. user_string( tcx) ) ;
757752 return Err ( ErrorReported ) ;
758753 }
759754 } ;
760755
761756 if ty:: binds_late_bound_regions ( tcx, & candidate) {
762- tcx. sess . span_err (
763- binding. span ,
764- format ! ( "associated type `{}` defined in higher-ranked supertrait `{}`" ,
757+ span_err ! ( tcx. sess, binding. span, E0219 ,
758+ "associated type `{}` defined in higher-ranked supertrait `{}`" ,
765759 token:: get_name( binding. item_name) ,
766- candidate. user_string( tcx) ) . as_slice ( ) ) ;
760+ candidate. user_string( tcx) ) ;
767761 return Err ( ErrorReported ) ;
768762 }
769763
@@ -964,18 +958,18 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
964958 }
965959
966960 if suitable_bounds. len ( ) == 0 {
967- tcx. sess . span_err ( ast_ty. span ,
968- format ! ( "associated type `{}` not found for type parameter `{}`" ,
961+ span_err ! ( tcx. sess, ast_ty. span, E0220 ,
962+ "associated type `{}` not found for type parameter `{}`" ,
969963 token:: get_name( assoc_name) ,
970- token:: get_name( ty_param_name) ) . as_slice ( ) ) ;
964+ token:: get_name( ty_param_name) ) ;
971965 return this. tcx ( ) . types . err ;
972966 }
973967
974968 if suitable_bounds. len ( ) > 1 {
975- tcx. sess . span_err ( ast_ty. span ,
976- format ! ( "ambiguous associated type `{}` in bounds of `{}`" ,
969+ span_err ! ( tcx. sess, ast_ty. span, E0221 ,
970+ "ambiguous associated type `{}` in bounds of `{}`" ,
977971 token:: get_name( assoc_name) ,
978- token:: get_name( ty_param_name) ) . as_slice ( ) ) ;
972+ token:: get_name( ty_param_name) ) ;
979973
980974 for suitable_bound in suitable_bounds. iter ( ) {
981975 span_note ! ( this. tcx( ) . sess, ast_ty. span,
@@ -1093,7 +1087,7 @@ pub fn ast_ty_to_ty<'tcx>(
10931087 ast:: TyParen ( ref typ) => ast_ty_to_ty ( this, rscope, & * * typ) ,
10941088 ast:: TyBareFn ( ref bf) => {
10951089 if bf. decl . variadic && bf. abi != abi:: C {
1096- tcx. sess . span_err ( ast_ty. span ,
1090+ span_err ! ( tcx. sess, ast_ty. span, E0222 ,
10971091 "variadic function must have C calling convention" ) ;
10981092 }
10991093 let bare_fn = ty_of_bare_fn ( this, bf. unsafety , bf. abi , & * bf. decl ) ;
@@ -1152,8 +1146,8 @@ pub fn ast_ty_to_ty<'tcx>(
11521146 def:: DefAssociatedTy ( trait_type_id) => {
11531147 let path_str = tcx. map . path_to_string (
11541148 tcx. map . get_parent ( trait_type_id. node ) ) ;
1155- tcx. sess . span_err ( ast_ty. span ,
1156- & format ! ( "ambiguous associated \
1149+ span_err ! ( tcx. sess, ast_ty. span, E0223 ,
1150+ "ambiguous associated \
11571151 type; specify the type \
11581152 using the syntax `<Type \
11591153 as {}>::{}`",
@@ -1163,7 +1157,7 @@ pub fn ast_ty_to_ty<'tcx>(
11631157 . last( )
11641158 . unwrap( )
11651159 . identifier)
1166- . get( ) ) [ ] ) ;
1160+ . get( ) ) ;
11671161 this. tcx ( ) . types . err
11681162 }
11691163 def:: DefAssociatedPath ( provenance, assoc_ident) => {
@@ -1549,8 +1543,7 @@ fn conv_ty_poly_trait_ref<'tcx>(
15491543 None ,
15501544 & mut projection_bounds) )
15511545 } else {
1552- this. tcx ( ) . sess . span_err (
1553- span,
1546+ span_err ! ( this. tcx( ) . sess, span, E0224 ,
15541547 "at least one non-builtin trait is required for an object type" ) ;
15551548 None
15561549 } ;
@@ -1585,10 +1578,9 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
15851578
15861579 if !trait_bounds. is_empty ( ) {
15871580 let b = & trait_bounds[ 0 ] ;
1588- this. tcx ( ) . sess . span_err (
1589- b. trait_ref . path . span ,
1590- & format ! ( "only the builtin traits can be used \
1591- as closure or object bounds") [ ] ) ;
1581+ span_err ! ( this. tcx( ) . sess, b. trait_ref. path. span, E0225 ,
1582+ "only the builtin traits can be used \
1583+ as closure or object bounds") ;
15921584 }
15931585
15941586 let region_bound = compute_region_bound ( this,
@@ -1625,9 +1617,8 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
16251617 builtin_bounds. repr( tcx) ) ;
16261618
16271619 if explicit_region_bounds. len ( ) > 1 {
1628- tcx. sess . span_err (
1629- explicit_region_bounds[ 1 ] . span ,
1630- format ! ( "only a single explicit lifetime bound is permitted" ) . as_slice ( ) ) ;
1620+ span_err ! ( tcx. sess, explicit_region_bounds[ 1 ] . span, E0226 ,
1621+ "only a single explicit lifetime bound is permitted" ) ;
16311622 }
16321623
16331624 if explicit_region_bounds. len ( ) != 0 {
@@ -1658,10 +1649,9 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
16581649 // error.
16591650 let r = derived_region_bounds[ 0 ] ;
16601651 if derived_region_bounds. slice_from ( 1 ) . iter ( ) . any ( |r1| r != * r1) {
1661- tcx. sess . span_err (
1662- span,
1663- & format ! ( "ambiguous lifetime bound, \
1664- explicit lifetime bound required") [ ] ) ;
1652+ span_err ! ( tcx. sess, span, E0227 ,
1653+ "ambiguous lifetime bound, \
1654+ explicit lifetime bound required") ;
16651655 }
16661656 return Some ( r) ;
16671657}
@@ -1685,9 +1675,8 @@ fn compute_region_bound<'tcx>(
16851675 match rscope. default_region_bound ( span) {
16861676 Some ( r) => { r }
16871677 None => {
1688- this. tcx ( ) . sess . span_err (
1689- span,
1690- & format ! ( "explicit lifetime bound required" ) [ ] ) ;
1678+ span_err ! ( this. tcx( ) . sess, span, E0228 ,
1679+ "explicit lifetime bound required" ) ;
16911680 ty:: ReStatic
16921681 }
16931682 }
@@ -1771,8 +1760,7 @@ fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>,
17711760 bindings : & [ ConvertedBinding < ' tcx > ] )
17721761{
17731762 for binding in bindings. iter ( ) . take ( 1 ) {
1774- tcx. sess . span_err (
1775- binding. span ,
1763+ span_err ! ( tcx. sess, binding. span, E0229 ,
17761764 "associated type bindings are not allowed here" ) ;
17771765 }
17781766}
0 commit comments