@@ -100,8 +100,7 @@ pub trait AstConv<'tcx> {
100
100
-> Ty < ' tcx >
101
101
{
102
102
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 ,
105
104
"cannot extract an associated type from a higher-ranked trait bound \
106
105
in this context") ;
107
106
self . tcx ( ) . types . err
@@ -119,8 +118,7 @@ pub trait AstConv<'tcx> {
119
118
_item_name : ast:: Name )
120
119
-> Ty < ' tcx >
121
120
{
122
- self . tcx ( ) . sess . span_err (
123
- span,
121
+ span_err ! ( self . tcx( ) . sess, span, E0213 ,
124
122
"associated types are not accepted in this context" ) ;
125
123
126
124
self . tcx ( ) . types . err
@@ -268,8 +266,7 @@ pub fn ast_path_substs_for_ty<'tcx>(
268
266
convert_angle_bracketed_parameters ( this, rscope, data)
269
267
}
270
268
ast:: ParenthesizedParameters ( ref data) => {
271
- tcx. sess . span_err (
272
- path. span ,
269
+ span_err ! ( tcx. sess, path. span, E0214 ,
273
270
"parenthesized parameters may only be used with a trait" ) ;
274
271
( Vec :: new ( ) , convert_parenthesized_parameters ( this, data) , Vec :: new ( ) )
275
272
}
@@ -610,7 +607,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
610
607
if !this. tcx ( ) . sess . features . borrow ( ) . unboxed_closures &&
611
608
this. tcx ( ) . lang_items . fn_trait_kind ( trait_def_id) . is_some ( )
612
609
{
613
- this. tcx ( ) . sess . span_err ( path. span ,
610
+ span_err ! ( this. tcx( ) . sess, path. span, E0215 ,
614
611
"angle-bracket notation is not stable when \
615
612
used with the `Fn` family of traits, use parentheses") ;
616
613
span_help ! ( this. tcx( ) . sess, path. span,
@@ -626,7 +623,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
626
623
if !this. tcx ( ) . sess . features . borrow ( ) . unboxed_closures &&
627
624
this. tcx ( ) . lang_items . fn_trait_kind ( trait_def_id) . is_none ( )
628
625
{
629
- this. tcx ( ) . sess . span_err ( path. span ,
626
+ span_err ! ( this. tcx( ) . sess, path. span, E0216 ,
630
627
"parenthetical notation is only stable when \
631
628
used with the `Fn` family of traits") ;
632
629
span_help ! ( this. tcx( ) . sess, path. span,
@@ -738,32 +735,29 @@ fn ast_type_binding_to_projection_predicate<'tcx>(
738
735
}
739
736
740
737
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 `{}`" ,
744
740
token:: get_name( binding. item_name) ,
745
- candidates. user_string( tcx) ) . as_slice ( ) ) ;
741
+ candidates. user_string( tcx) ) ;
746
742
return Err ( ErrorReported ) ;
747
743
}
748
744
749
745
let candidate = match candidates. pop ( ) {
750
746
Some ( c) => c,
751
747
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 `{}`" ,
755
750
token:: get_name( binding. item_name) ,
756
- trait_ref. user_string( tcx) ) . as_slice ( ) ) ;
751
+ trait_ref. user_string( tcx) ) ;
757
752
return Err ( ErrorReported ) ;
758
753
}
759
754
} ;
760
755
761
756
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 `{}`" ,
765
759
token:: get_name( binding. item_name) ,
766
- candidate. user_string( tcx) ) . as_slice ( ) ) ;
760
+ candidate. user_string( tcx) ) ;
767
761
return Err ( ErrorReported ) ;
768
762
}
769
763
@@ -964,18 +958,18 @@ fn associated_path_def_to_ty<'tcx>(this: &AstConv<'tcx>,
964
958
}
965
959
966
960
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 `{}`" ,
969
963
token:: get_name( assoc_name) ,
970
- token:: get_name( ty_param_name) ) . as_slice ( ) ) ;
964
+ token:: get_name( ty_param_name) ) ;
971
965
return this. tcx ( ) . types . err ;
972
966
}
973
967
974
968
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 `{}`" ,
977
971
token:: get_name( assoc_name) ,
978
- token:: get_name( ty_param_name) ) . as_slice ( ) ) ;
972
+ token:: get_name( ty_param_name) ) ;
979
973
980
974
for suitable_bound in suitable_bounds. iter ( ) {
981
975
span_note ! ( this. tcx( ) . sess, ast_ty. span,
@@ -1093,7 +1087,7 @@ pub fn ast_ty_to_ty<'tcx>(
1093
1087
ast:: TyParen ( ref typ) => ast_ty_to_ty ( this, rscope, & * * typ) ,
1094
1088
ast:: TyBareFn ( ref bf) => {
1095
1089
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 ,
1097
1091
"variadic function must have C calling convention" ) ;
1098
1092
}
1099
1093
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>(
1152
1146
def:: DefAssociatedTy ( trait_type_id) => {
1153
1147
let path_str = tcx. map . path_to_string (
1154
1148
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 \
1157
1151
type; specify the type \
1158
1152
using the syntax `<Type \
1159
1153
as {}>::{}`",
@@ -1163,7 +1157,7 @@ pub fn ast_ty_to_ty<'tcx>(
1163
1157
. last( )
1164
1158
. unwrap( )
1165
1159
. identifier)
1166
- . get( ) ) [ ] ) ;
1160
+ . get( ) ) ;
1167
1161
this. tcx ( ) . types . err
1168
1162
}
1169
1163
def:: DefAssociatedPath ( provenance, assoc_ident) => {
@@ -1549,8 +1543,7 @@ fn conv_ty_poly_trait_ref<'tcx>(
1549
1543
None ,
1550
1544
& mut projection_bounds) )
1551
1545
} else {
1552
- this. tcx ( ) . sess . span_err (
1553
- span,
1546
+ span_err ! ( this. tcx( ) . sess, span, E0224 ,
1554
1547
"at least one non-builtin trait is required for an object type" ) ;
1555
1548
None
1556
1549
} ;
@@ -1585,10 +1578,9 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
1585
1578
1586
1579
if !trait_bounds. is_empty ( ) {
1587
1580
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") ;
1592
1584
}
1593
1585
1594
1586
let region_bound = compute_region_bound ( this,
@@ -1625,9 +1617,8 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
1625
1617
builtin_bounds. repr( tcx) ) ;
1626
1618
1627
1619
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" ) ;
1631
1622
}
1632
1623
1633
1624
if explicit_region_bounds. len ( ) != 0 {
@@ -1658,10 +1649,9 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
1658
1649
// error.
1659
1650
let r = derived_region_bounds[ 0 ] ;
1660
1651
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") ;
1665
1655
}
1666
1656
return Some ( r) ;
1667
1657
}
@@ -1685,9 +1675,8 @@ fn compute_region_bound<'tcx>(
1685
1675
match rscope. default_region_bound ( span) {
1686
1676
Some ( r) => { r }
1687
1677
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" ) ;
1691
1680
ty:: ReStatic
1692
1681
}
1693
1682
}
@@ -1771,8 +1760,7 @@ fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>,
1771
1760
bindings : & [ ConvertedBinding < ' tcx > ] )
1772
1761
{
1773
1762
for binding in bindings. iter ( ) . take ( 1 ) {
1774
- tcx. sess . span_err (
1775
- binding. span ,
1763
+ span_err ! ( tcx. sess, binding. span, E0229 ,
1776
1764
"associated type bindings are not allowed here" ) ;
1777
1765
}
1778
1766
}
0 commit comments