Skip to content

Commit 176f5a5

Browse files
committed
---
yaml --- r: 174721 b: refs/heads/snap-stage3 c: 0c5225c h: refs/heads/master i: 174719: d5b4a8e v: v3
1 parent 008c63d commit 176f5a5

File tree

16 files changed

+180
-158
lines changed

16 files changed

+180
-158
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: a0f86de49748b472d4d189d9688b0d856c000914
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 953d6dfd7e1b1d5c5b17314b6e3bdec15d8e7a01
4+
refs/heads/snap-stage3: 0c5225c5bf31dcca141c36ce1b5850ff2df79b9c
55
refs/heads/try: 08f6380a9f0b866796080094f44fe25ea5636547
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/librustc_typeck/astconv.rs

Lines changed: 36 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -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) => {
@@ -1557,8 +1551,7 @@ fn conv_ty_poly_trait_ref<'tcx>(
15571551
None,
15581552
&mut projection_bounds))
15591553
} else {
1560-
this.tcx().sess.span_err(
1561-
span,
1554+
span_err!(this.tcx().sess, span, E0224,
15621555
"at least one non-builtin trait is required for an object type");
15631556
None
15641557
};
@@ -1593,10 +1586,9 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
15931586

15941587
if !trait_bounds.is_empty() {
15951588
let b = &trait_bounds[0];
1596-
this.tcx().sess.span_err(
1597-
b.trait_ref.path.span,
1598-
&format!("only the builtin traits can be used \
1599-
as closure or object bounds")[]);
1589+
span_err!(this.tcx().sess, b.trait_ref.path.span, E0225,
1590+
"only the builtin traits can be used \
1591+
as closure or object bounds");
16001592
}
16011593

16021594
let region_bound = compute_region_bound(this,
@@ -1633,9 +1625,8 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
16331625
builtin_bounds.repr(tcx));
16341626

16351627
if explicit_region_bounds.len() > 1 {
1636-
tcx.sess.span_err(
1637-
explicit_region_bounds[1].span,
1638-
format!("only a single explicit lifetime bound is permitted").as_slice());
1628+
span_err!(tcx.sess, explicit_region_bounds[1].span, E0226,
1629+
"only a single explicit lifetime bound is permitted");
16391630
}
16401631

16411632
if explicit_region_bounds.len() != 0 {
@@ -1666,10 +1657,9 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
16661657
// error.
16671658
let r = derived_region_bounds[0];
16681659
if derived_region_bounds.slice_from(1).iter().any(|r1| r != *r1) {
1669-
tcx.sess.span_err(
1670-
span,
1671-
&format!("ambiguous lifetime bound, \
1672-
explicit lifetime bound required")[]);
1660+
span_err!(tcx.sess, span, E0227,
1661+
"ambiguous lifetime bound, \
1662+
explicit lifetime bound required");
16731663
}
16741664
return Some(r);
16751665
}
@@ -1693,9 +1683,8 @@ fn compute_region_bound<'tcx>(
16931683
match rscope.default_region_bound(span) {
16941684
Some(r) => { r }
16951685
None => {
1696-
this.tcx().sess.span_err(
1697-
span,
1698-
&format!("explicit lifetime bound required")[]);
1686+
span_err!(this.tcx().sess, span, E0228,
1687+
"explicit lifetime bound required");
16991688
ty::ReStatic
17001689
}
17011690
}
@@ -1779,8 +1768,7 @@ fn prohibit_projections<'tcx>(tcx: &ty::ctxt<'tcx>,
17791768
bindings: &[ConvertedBinding<'tcx>])
17801769
{
17811770
for binding in bindings.iter().take(1) {
1782-
tcx.sess.span_err(
1783-
binding.span,
1771+
span_err!(tcx.sess, binding.span, E0229,
17841772
"associated type bindings are not allowed here");
17851773
}
17861774
}

branches/snap-stage3/src/librustc_typeck/check/closure.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,9 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
5050

5151
check_unboxed_closure(fcx, expr, kind, decl, body, None);
5252

53-
fcx.ccx.tcx.sess.span_err(
54-
expr.span,
53+
span_err!(fcx.ccx.tcx.sess, expr.span, E0187,
5554
"can't infer the \"kind\" of the closure, explicitly annotate it. e.g. \
56-
`|&:| {}`");
55+
`|&:| {{}}`");
5756
},
5857
Some((sig, kind)) => {
5958
check_unboxed_closure(fcx, expr, kind, decl, body, Some(sig));

branches/snap-stage3/src/librustc_typeck/check/compare_method.rs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,21 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
5959
(&ty::StaticExplicitSelfCategory,
6060
&ty::StaticExplicitSelfCategory) => {}
6161
(&ty::StaticExplicitSelfCategory, _) => {
62-
tcx.sess.span_err(
63-
impl_m_span,
64-
format!("method `{}` has a `{}` declaration in the impl, \
62+
span_err!(tcx.sess, impl_m_span, E0185,
63+
"method `{}` has a `{}` declaration in the impl, \
6564
but not in the trait",
6665
token::get_name(trait_m.name),
6766
ppaux::explicit_self_category_to_str(
68-
&impl_m.explicit_self)).as_slice());
67+
&impl_m.explicit_self));
6968
return;
7069
}
7170
(_, &ty::StaticExplicitSelfCategory) => {
72-
tcx.sess.span_err(
73-
impl_m_span,
74-
format!("method `{}` has a `{}` declaration in the trait, \
71+
span_err!(tcx.sess, impl_m_span, E0186,
72+
"method `{}` has a `{}` declaration in the trait, \
7573
but not in the impl",
7674
token::get_name(trait_m.name),
7775
ppaux::explicit_self_category_to_str(
78-
&trait_m.explicit_self)).as_slice());
76+
&trait_m.explicit_self));
7977
return;
8078
}
8179
_ => {
@@ -400,11 +398,10 @@ pub fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
400398
// are zero. Since I don't quite know how to phrase things at
401399
// the moment, give a kind of vague error message.
402400
if trait_params.len() != impl_params.len() {
403-
tcx.sess.span_err(
404-
span,
405-
&format!("lifetime parameters or bounds on method `{}` do \
401+
span_err!(tcx.sess, span, E0195,
402+
"lifetime parameters or bounds on method `{}` do \
406403
not match the trait declaration",
407-
token::get_name(impl_m.name))[]);
404+
token::get_name(impl_m.name));
408405
return false;
409406
}
410407

0 commit comments

Comments
 (0)