if arg_len > 0 {
// N-ary variant.
if arg_len != subpats_len {
- let s = format!("this pattern has {} field{}, \
- but the corresponding {} has {} field{}",
- subpats_len,
- if subpats_len == 1 {""} else {"s"},
- kind_name,
- arg_len,
- if arg_len == 1 {""} else {"s"});
- tcx.sess.span_err(pat.span, s.as_slice());
+ span_err!(tcx.sess, pat.span, E0023,
+ "this pattern has {} field{}, but the corresponding {} has {} field{}",
+ subpats_len, if subpats_len == 1 {""} else {"s"},
+ kind_name, arg_len, if arg_len == 1 {""} else {"s"});
error_happened = true;
}
}
}
} else if subpats_len > 0 {
- tcx.sess.span_err(pat.span,
- format!("this pattern has {} field{}, \
- but the corresponding {} has no fields",
- subpats_len,
- if subpats_len == 1 {""} else {"s"},
- kind_name).as_slice());
+ span_err!(tcx.sess, pat.span, E0024,
+ "this pattern has {} field{}, but the corresponding {} has no fields",
+ subpats_len, if subpats_len == 1 {""} else {"s"},
+ kind_name);
error_happened = true;
}
// Check the pattern anyway, so that attempts to look
// up its type won't fail
check_pat(pcx, &*field.pat, ty::mk_err());
- tcx.sess.span_err(span,
- format!("field `{}` bound twice in pattern",
- token::get_ident(field.ident)).as_slice());
+ span_err!(tcx.sess, span, E0025,
+ "field `{}` bound twice in pattern",
+ token::get_ident(field.ident));
}
Some(&(index, ref mut used)) => {
*used = true;
// Check the pattern anyway, so that attempts to look
// up its type won't fail
check_pat(pcx, &*field.pat, ty::mk_err());
- tcx.sess.span_err(span,
- format!("struct `{}` does not have a field named `{}`",
- ty::item_path_str(tcx, class_id),
- token::get_ident(field.ident)).as_slice());
+ span_err!(tcx.sess, span, E0026,
+ "struct `{}` does not have a field named `{}`",
+ ty::item_path_str(tcx, class_id),
+ token::get_ident(field.ident));
}
}
}
if found_fields.contains(&i) {
continue;
}
-
- tcx.sess
- .span_err(span,
- format!("pattern does not mention field `{}`",
- token::get_name(field.name)).as_slice());
+ span_err!(tcx.sess, span, E0027,
+ "pattern does not mention field `{}`",
+ token::get_name(field.name));
}
}
}
}
Some(&def::DefStruct(..)) | Some(&def::DefVariant(..)) => {
let name = pprust::path_to_string(path);
- tcx.sess.span_err(span,
- format!("mismatched types: expected `{}` but \
- found `{}`",
- fcx.infcx().ty_to_string(expected),
- name).as_slice());
+ span_err!(tcx.sess, span, E0028,
+ "mismatched types: expected `{}` but found `{}`",
+ fcx.infcx().ty_to_string(expected), name);
}
_ => {
tcx.sess.span_bug(span, "resolve didn't write in variant");
{
// no-op
} else if !ty::type_is_numeric(b_ty) && !ty::type_is_char(b_ty) {
- tcx.sess.span_err(pat.span,
+ span_err!(tcx.sess, begin.span, E0029,
"only char and numeric types are allowed in range");
} else {
match valid_range_bounds(fcx.ccx, &**begin, &**end) {
Some(false) => {
- tcx.sess.span_err(begin.span,
+ span_err!(tcx.sess, begin.span, E0030,
"lower range bound must be less than upper");
},
None => {
- tcx.sess.span_err(begin.span,
+ span_err!(tcx.sess, begin.span, E0031,
"mismatched types in range");
},
_ => { },
ty::ty_to_def_id(
ty::lookup_item_type(tcx, item_did).ty).unwrap();
if struct_did != cid {
- tcx.sess
- .span_err(path.span,
- format!("`{}` does not name the \
- structure `{}`",
- pprust::path_to_string(path),
- fcx.infcx()
- .ty_to_string(expected)).as_slice())
+ span_err!(tcx.sess, pat.span, E0032,
+ "`{}` does not name the structure `{}`",
+ pprust::path_to_string(path),
+ fcx.infcx().ty_to_string(expected));
}
check_struct_pat(pcx, pat.id, pat.span, expected, path,
// This is "x = SomeTrait" being reduced from
// "let &x = &SomeTrait" or "let box x = Box<SomeTrait>", an error.
check_pat(pcx, inner, ty::mk_err());
- tcx.sess.span_err(
- span,
- format!("type `{}` cannot be dereferenced",
- fcx.infcx().ty_to_string(expected)).as_slice());
+ span_err!(tcx.sess, span, E0033,
+ "type `{}` cannot be dereferenced",
+ fcx.infcx().ty_to_string(expected));
fcx.write_error(pat_id);
}
_ => {
for f in fields.iter() {
match super_fields.iter().find(|sf| f.name == sf.name) {
Some(prev_field) => {
- tcx.sess.span_err(span_for_field(tcx, f, id),
- format!("field `{}` hides field declared in \
- super-struct",
- token::get_name(f.name)).as_slice());
- tcx.sess.span_note(span_for_field(tcx, prev_field, parent_id),
+ span_err!(tcx.sess, span_for_field(tcx, f, id), E0041,
+ "field `{}` hides field declared in super-struct",
+ token::get_name(f.name));
+ span_note!(tcx.sess, span_for_field(tcx, prev_field, parent_id),
"previously declared here");
},
None => {}
if !ty::type_is_sized(tcx, t) {
match f.node.kind {
ast::NamedField(ident, _) => {
- tcx.sess.span_err(
- f.span,
- format!("type `{}` is dynamically sized. \
- dynamically sized types may only \
- appear as the type of the final \
- field in a struct",
- token::get_ident(ident)).as_slice());
+ span_err!(tcx.sess, f.span, E0042,
+ "type `{}` is dynamically sized. \
+ dynamically sized types may only \
+ appear as the type of the final \
+ field in a struct",
+ token::get_ident(ident));
}
ast::UnnamedField(_) => {
- tcx.sess.span_err(f.span, "dynamically sized type in field");
+ span_err!(tcx.sess, f.span, E0043,
+ "dynamically sized type in field");
}
}
}
for item in m.items.iter() {
let pty = ty::lookup_item_type(ccx.tcx, local_def(item.id));
if !pty.generics.types.is_empty() {
- ccx.tcx.sess.span_err(item.span, "foreign items may not have type parameters");
+ span_err!(ccx.tcx.sess, item.span, E0044,
+ "foreign items may not have type parameters");
}
match item.node {
ast::ForeignItemFn(ref fn_decl, _) => {
if fn_decl.variadic && m.abi != abi::C {
- ccx.tcx.sess.span_err(
- item.span, "variadic function must have C calling convention");
+ span_err!(ccx.tcx.sess, item.span, E0045,
+ "variadic function must have C calling convention");
}
}
_ => {}
}
if !missing_methods.is_empty() {
- tcx.sess.span_err(
- impl_span,
- format!("not all trait methods implemented, missing: {}",
- missing_methods.connect(", ")).as_slice());
+ span_err!(tcx.sess, impl_span, E0046,
+ "not all trait methods implemented, missing: {}",
+ missing_methods.connect(", "));
}
}
match (&trait_m.explicit_self, &impl_m.explicit_self) {
(&ast::SelfStatic, &ast::SelfStatic) => {}
(&ast::SelfStatic, _) => {
- tcx.sess.span_err(
- impl_m_span,
- format!("method `{}` has a `{}` declaration in the impl, \
- but not in the trait",
- token::get_ident(trait_m.ident),
- pprust::explicit_self_to_string(
- impl_m.explicit_self)).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0047,
+ "method `{}` has a `{}` declaration in the impl, but not in the trait",
+ token::get_ident(trait_m.ident),
+ pprust::explicit_self_to_string(impl_m.explicit_self));
return;
}
(_, &ast::SelfStatic) => {
- tcx.sess.span_err(
- impl_m_span,
- format!("method `{}` has a `{}` declaration in the trait, \
- but not in the impl",
- token::get_ident(trait_m.ident),
- pprust::explicit_self_to_string(
- trait_m.explicit_self)).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0048,
+ "method `{}` has a `{}` declaration in the trait, but not in the impl",
+ token::get_ident(trait_m.ident),
+ pprust::explicit_self_to_string(trait_m.explicit_self));
return;
}
_ => {
let num_impl_m_type_params = impl_m.generics.types.len(subst::FnSpace);
let num_trait_m_type_params = trait_m.generics.types.len(subst::FnSpace);
if num_impl_m_type_params != num_trait_m_type_params {
- tcx.sess.span_err(
- impl_m_span,
- format!("method `{}` has {} type parameter{} \
- but its trait declaration has {} type parameter{}",
- token::get_ident(trait_m.ident),
- num_impl_m_type_params,
- if num_impl_m_type_params == 1 {""} else {"s"},
- num_trait_m_type_params,
- if num_trait_m_type_params == 1 {""} else {"s"}).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0049,
+ "method `{}` has {} type parameter{} \
+ but its trait declaration has {} type parameter{}",
+ token::get_ident(trait_m.ident),
+ num_impl_m_type_params,
+ if num_impl_m_type_params == 1 {""} else {"s"},
+ num_trait_m_type_params,
+ if num_trait_m_type_params == 1 {""} else {"s"});
return;
}
if impl_m.fty.sig.inputs.len() != trait_m.fty.sig.inputs.len() {
- tcx.sess.span_err(
- impl_m_span,
- format!("method `{}` has {} parameter{} \
- but the declaration in trait `{}` has {}",
- token::get_ident(trait_m.ident),
- impl_m.fty.sig.inputs.len(),
- if impl_m.fty.sig.inputs.len() == 1 {""} else {"s"},
- ty::item_path_str(tcx, trait_m.def_id),
- trait_m.fty.sig.inputs.len()).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0050,
+ "method `{}` has {} parameter{} \
+ but the declaration in trait `{}` has {}",
+ token::get_ident(trait_m.ident),
+ impl_m.fty.sig.inputs.len(),
+ if impl_m.fty.sig.inputs.len() == 1 {""} else {"s"},
+ ty::item_path_str(tcx, trait_m.def_id),
+ trait_m.fty.sig.inputs.len());
return;
}
impl_param_def.bounds.builtin_bounds -
trait_param_def.bounds.builtin_bounds;
if !extra_bounds.is_empty() {
- tcx.sess.span_err(
- impl_m_span,
- format!("in method `{}`, \
- type parameter {} requires `{}`, \
- which is not required by \
- the corresponding type parameter \
- in the trait declaration",
- token::get_ident(trait_m.ident),
- i,
- extra_bounds.user_string(tcx)).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0051,
+ "in method `{}`, type parameter {} requires `{}`, \
+ which is not required by the corresponding type parameter \
+ in the trait declaration",
+ token::get_ident(trait_m.ident),
+ i,
+ extra_bounds.user_string(tcx));
return;
}
}
if !ok {
- tcx.sess.span_err(impl_m_span,
- format!("in method `{}`, type parameter {} \
- requires bound `{}`, which is not \
- required by the corresponding \
- type parameter in the trait \
- declaration",
- token::get_ident(trait_m.ident),
- i,
- ppaux::trait_ref_to_string(
- tcx,
- &*impl_trait_bound)).as_slice())
+ span_err!(tcx.sess, impl_m_span, E0052,
+ "in method `{}`, type parameter {} requires bound `{}`, which is not \
+ required by the corresponding type parameter in the trait declaration",
+ token::get_ident(trait_m.ident),
+ i,
+ ppaux::trait_ref_to_string(tcx, &*impl_trait_bound));
}
}
}
impl_fty, trait_fty) {
Ok(()) => {}
Err(ref terr) => {
- tcx.sess.span_err(
- impl_m_span,
- format!("method `{}` has an incompatible type for trait: {}",
- token::get_ident(trait_m.ident),
- ty::type_err_to_str(tcx, terr)).as_slice());
+ span_err!(tcx.sess, impl_m_span, E0053,
+ "method `{}` has an incompatible type for trait: {}",
+ token::get_ident(trait_m.ident),
+ ty::type_err_to_str(tcx, terr));
ty::note_and_explain_type_err(tcx, terr);
}
}
}, t_e, None);
}
} else if ty::get(t_1).sty == ty::ty_bool {
- fcx.tcx()
- .sess
- .span_err(span,
- "cannot cast as `bool`, compare with zero instead");
+ span_err!(fcx.tcx().sess, span, E0054,
+ "cannot cast as `bool`, compare with zero instead");
} else if ty::type_is_region_ptr(t_e) && ty::type_is_unsafe_ptr(t_1) {
fn types_compatible(fcx: &FnCtxt, sp: Span,
t1: ty::t, t2: ty::t) -> bool {
}
// We've reached the recursion limit, error gracefully.
- fcx.tcx().sess.span_err(sp,
- format!("reached the recursion limit while auto-dereferencing {}",
- base_ty.repr(fcx.tcx())).as_slice());
+ span_err!(fcx.tcx().sess, sp, E0055,
+ "reached the recursion limit while auto-dereferencing {}",
+ base_ty.repr(fcx.tcx()));
(ty::mk_err(), 0, None)
}
write_call(fcx, call_expression, output_type);
if !fcx.tcx().sess.features.overloaded_calls.get() {
- fcx.tcx().sess.span_err(call_expression.span,
- "overloaded calls are experimental");
- fcx.tcx().sess.span_note(call_expression.span,
- "add `#[feature(overloaded_calls)]` to \
- the crate attributes to enable");
+ span_err!(fcx.tcx().sess, call_expression.span, E0056,
+ "overloaded calls are experimental");
+ span_note!(fcx.tcx().sess, call_expression.span,
+ "add `#[feature(overloaded_calls)]` to \
+ the crate attributes to enable");
}
return true
match ty::get(tuple_type).sty {
ty::ty_tup(ref arg_types) => {
if arg_types.len() != args.len() {
- let msg = format!(
- "this function takes {} parameter{} \
- but {} parameter{} supplied",
- arg_types.len(),
- if arg_types.len() == 1 {""} else {"s"},
- args.len(),
- if args.len() == 1 {" was"} else {"s were"});
- tcx.sess.span_err(sp, msg.as_slice());
+ span_err!(tcx.sess, sp, E0057,
+ "this function takes {} parameter{} but {} parameter{} supplied",
+ arg_types.len(),
+ if arg_types.len() == 1 {""} else {"s"},
+ args.len(),
+ if args.len() == 1 {" was"} else {"s were"});
err_args(args.len())
} else {
(*arg_types).clone()
}
ty::ty_nil => {
if args.len() != 0 {
- let msg = format!(
- "this function takes 0 parameters \
- but {} parameter{} supplied",
- args.len(),
- if args.len() == 1 {" was"} else {"s were"});
- tcx.sess.span_err(sp, msg.as_slice());
+ span_err!(tcx.sess, sp, E0058,
+ "this function takes 0 parameters but {} parameter{} supplied",
+ args.len(),
+ if args.len() == 1 {" was"} else {"s were"});
}
Vec::new()
}
_ => {
- tcx.sess
- .span_err(sp,
- "cannot use call notation; the first type \
- parameter for the function trait is neither a \
- tuple nor unit");
+ span_err!(tcx.sess, sp, E0059,
+ "cannot use call notation; the first type parameter \
+ for the function trait is neither a tuple nor unit");
err_args(supplied_arg_count)
}
}
if supplied_arg_count >= expected_arg_count {
fn_inputs.iter().map(|a| *a).collect()
} else {
- let msg = format!(
+ span_err!(tcx.sess, sp, E0060,
"this function takes at least {} parameter{} \
but {} parameter{} supplied",
- expected_arg_count,
- if expected_arg_count == 1 {""} else {"s"},
- supplied_arg_count,
- if supplied_arg_count == 1 {" was"} else {"s were"});
-
- tcx.sess.span_err(sp, msg.as_slice());
-
+ expected_arg_count,
+ if expected_arg_count == 1 {""} else {"s"},
+ supplied_arg_count,
+ if supplied_arg_count == 1 {" was"} else {"s were"});
err_args(supplied_arg_count)
}
} else {
- let msg = format!(
- "this function takes {} parameter{} \
- but {} parameter{} supplied",
- expected_arg_count,
- if expected_arg_count == 1 {""} else {"s"},
- supplied_arg_count,
- if supplied_arg_count == 1 {" was"} else {"s were"});
-
- tcx.sess.span_err(sp, msg.as_slice());
-
+ span_err!(tcx.sess, sp, E0061,
+ "this function takes {} parameter{} but {} parameter{} supplied",
+ expected_arg_count,
+ if expected_arg_count == 1 {""} else {"s"},
+ supplied_arg_count,
+ if supplied_arg_count == 1 {" was"} else {"s were"});
err_args(supplied_arg_count)
};
error_happened = true;
}
Some((_, true)) => {
- tcx.sess.span_err(
- field.ident.span,
- format!("field `{}` specified more than once",
- token::get_ident(field.ident
- .node)).as_slice());
+ span_err!(fcx.tcx().sess, field.ident.span, E0062,
+ "field `{}` specified more than once",
+ token::get_ident(field.ident.node));
error_happened = true;
}
Some((field_id, false)) => {
}
}
- tcx.sess.span_err(span,
- format!(
- "missing field{}: {fields}",
- if missing_fields.len() == 1 {""} else {"s"},
- fields = missing_fields.connect(", ")).as_slice());
+ span_err!(tcx.sess, span, E0063,
+ "missing field{}: {}",
+ if missing_fields.len() == 1 {""} else {"s"},
+ missing_fields.connect(", "));
}
}
}
}
ast::ExprLit(_) => {
- let error = if vst == ast::ExprVstoreSlice {
- "`&\"string\"` has been removed; use `\"string\"` instead"
+ if vst == ast::ExprVstoreSlice {
+ span_err!(tcx.sess, expr.span, E0064,
+ "`&\"string\"` has been removed; use `\"string\"` instead");
} else {
- "`box \"string\"` has been removed; use `\"string\".to_string()` instead"
- };
- tcx.sess.span_err(expr.span, error);
+ span_err!(tcx.sess, expr.span, E0065,
+ "`box \"string\"` has been removed; use \
+ `\"string\".to_string()` instead");
+ }
ty::mk_err()
}
_ => tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence"),
}
if !checked {
- tcx.sess.span_err(expr.span,
- "only the managed heap and exchange heap are \
- currently supported");
+ span_err!(tcx.sess, expr.span, E0066,
+ "only the managed heap and exchange heap are currently supported");
fcx.write_ty(id, ty::mk_err());
}
}
let tcx = fcx.tcx();
if !ty::expr_is_lval(tcx, &**lhs) {
- tcx.sess.span_err(lhs.span, "illegal left-hand side expression");
+ span_err!(tcx.sess, lhs.span, E0067, "illegal left-hand side expression");
}
// Overwrite result of check_binop...this preserves existing behavior
};
if is_newtype {
// This is an obsolete struct deref
- tcx.sess.span_err(expr.span,
+ span_err!(tcx.sess, expr.span, E0068,
"single-field tuple-structs can \
no longer be dereferenced");
} else {
ret_ty, ty::mk_nil()) {
Ok(_) => { /* fall through */ }
Err(_) => {
- tcx.sess.span_err(
- expr.span,
+ span_err!(tcx.sess, expr.span, E0069,
"`return;` in function returning non-nil");
}
},
let tcx = fcx.tcx();
if !ty::expr_is_lval(tcx, &**lhs) {
- tcx.sess.span_err(lhs.span, "illegal left-hand side expression");
+ span_err!(tcx.sess, expr.span, E0070,
+ "illegal left-hand side expression");
}
let lhs_ty = fcx.expr_ty(&**lhs);
base_expr);
}
_ => {
- tcx.sess
- .span_err(path.span,
- format!("`{}` does not name a structure",
- pprust::path_to_string(
- path)).as_slice())
+ span_err!(tcx.sess, path.span, E0071,
+ "`{}` does not name a structure",
+ pprust::path_to_string(path));
}
}
}
// caught by case 1.
match ty::is_type_representable(tcx, sp, rty) {
ty::SelfRecursive => {
- tcx.sess.span_err(
- sp, format!("illegal recursive {} type; \
- wrap the inner value in a box to make it representable",
- designation).as_slice());
+ span_err!(tcx.sess, sp, E0072,
+ "illegal recursive {} type; \
+ wrap the inner value in a box to make it representable",
+ designation);
return false
}
ty::Representable | ty::ContainsRecursive => (),
-> bool {
let item_ty = ty::node_id_to_type(tcx, item_id);
if !ty::is_instantiable(tcx, item_ty) {
- tcx.sess
- .span_err(sp,
- format!("this type cannot be instantiated without an \
- instance of itself; consider using \
- `Option<{}>`",
- ppaux::ty_to_string(tcx, item_ty)).as_slice());
+ span_err!(tcx.sess, sp, E0073,
+ "this type cannot be instantiated without an \
+ instance of itself; consider using `Option<{}>`",
+ ppaux::ty_to_string(tcx, item_ty));
false
} else {
true
pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) {
let t = ty::node_id_to_type(tcx, id);
if ty::type_needs_subst(t) {
- tcx.sess.span_err(sp, "SIMD vector cannot be generic");
+ span_err!(tcx.sess, sp, E0074, "SIMD vector cannot be generic");
return;
}
match ty::get(t).sty {
ty::ty_struct(did, ref substs) => {
let fields = ty::lookup_struct_fields(tcx, did);
if fields.is_empty() {
- tcx.sess.span_err(sp, "SIMD vector cannot be empty");
+ span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty");
return;
}
let e = ty::lookup_field_type(tcx, did, fields.get(0).id, substs);
if !fields.iter().all(
|f| ty::lookup_field_type(tcx, did, f.id, substs) == e) {
- tcx.sess.span_err(sp, "SIMD vector should be homogeneous");
+ span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous");
return;
}
if !ty::type_is_machine(e) {
- tcx.sess.span_err(sp, "SIMD vector element type should be \
- machine type");
+ span_err!(tcx.sess, sp, E0077,
+ "SIMD vector element type should be machine type");
return;
}
}
// A struct value with an unsized final field is itself
// unsized and we must track this in the type system.
if !ty::type_is_sized(ccx.tcx, *t) {
- ccx.tcx
- .sess
- .span_err(
- args.get(i).ty.span,
- format!("type `{}` is dynamically sized. \
- dynamically sized types may only \
- appear as the final type in a \
- variant",
- ppaux::ty_to_string(ccx.tcx,
- *t)).as_slice());
+ span_err!(ccx.tcx.sess, args.get(i).ty.span, E0078,
+ "type `{}` is dynamically sized. dynamically sized types may only \
+ appear as the final type in a variant",
+ ppaux::ty_to_string(ccx.tcx, *t));
}
}
},
Ok(const_eval::const_int(val)) => current_disr_val = val as Disr,
Ok(const_eval::const_uint(val)) => current_disr_val = val as Disr,
Ok(_) => {
- ccx.tcx.sess.span_err(e.span, "expected signed integer constant");
+ span_err!(ccx.tcx.sess, e.span, E0079,
+ "expected signed integer constant");
}
Err(ref err) => {
- ccx.tcx
- .sess
- .span_err(e.span,
- format!("expected constant: {}",
- *err).as_slice());
+ span_err!(ccx.tcx.sess, e.span, E0080,
+ "expected constant: {}", *err);
}
}
},
// Check for duplicate discriminant values
if disr_vals.contains(¤t_disr_val) {
- ccx.tcx.sess.span_err(v.span, "discriminant value already exists");
+ span_err!(ccx.tcx.sess, v.span, E0081,
+ "discriminant value already exists");
}
// Check for unrepresentable discriminant values
match hint {
attr::ReprAny | attr::ReprExtern => (),
attr::ReprInt(sp, ity) => {
if !disr_in_range(ccx, ity, current_disr_val) {
- ccx.tcx.sess.span_err(v.span,
- "discriminant value outside specified type");
- ccx.tcx.sess.span_note(sp, "discriminant type specified here");
+ span_err!(ccx.tcx.sess, v.span, E0082,
+ "discriminant value outside specified type");
+ span_note!(ccx.tcx.sess, sp,
+ "discriminant type specified here");
}
}
}
let hint = ty::lookup_repr_hint(ccx.tcx, ast::DefId { krate: ast::LOCAL_CRATE, node: id });
if hint != attr::ReprAny && vs.len() <= 1 {
- let msg = if vs.len() == 1 {
- "unsupported representation for univariant enum"
+ if vs.len() == 1 {
+ span_err!(ccx.tcx.sess, sp, E0083,
+ "unsupported representation for univariant enum");
} else {
- "unsupported representation for zero-variant enum"
+ span_err!(ccx.tcx.sess, sp, E0084,
+ "unsupported representation for zero-variant enum");
};
- ccx.tcx.sess.span_err(sp, msg)
}
let variants = do_check(ccx, vs, id, hint);
segment: &ast::PathSegment)
{
for typ in segment.types.iter() {
- fcx.tcx().sess.span_err(
- typ.span,
+ span_err!(fcx.tcx().sess, typ.span, E0085,
"type parameters may not appear here");
break;
}
for lifetime in segment.lifetimes.iter() {
- fcx.tcx().sess.span_err(
- lifetime.span,
+ span_err!(fcx.tcx().sess, lifetime.span, E0086,
"lifetime parameters may not appear here");
break;
}
if i < type_count {
substs.types.push(space, t);
} else if i == type_count {
- fcx.tcx().sess.span_err(
- typ.span,
- format!(
- "too many type parameters provided: \
- expected at most {} parameter(s) \
- but found {} parameter(s)",
- type_count,
- segment.types.len()).as_slice());
+ span_err!(fcx.tcx().sess, typ.span, E0087,
+ "too many type parameters provided: \
+ expected at most {} parameter(s) \
+ but found {} parameter(s)",
+ type_count, segment.types.len());
substs.types.truncate(space, 0);
}
}
if i < region_count {
substs.mut_regions().push(space, r);
} else if i == region_count {
- fcx.tcx().sess.span_err(
- lifetime.span,
- format!(
- "too many lifetime parameters provided: \
- expected {} parameter(s) but found {} parameter(s)",
- region_count,
- segment.lifetimes.len()).as_slice());
+ span_err!(fcx.tcx().sess, lifetime.span, E0088,
+ "too many lifetime parameters provided: \
+ expected {} parameter(s) but found {} parameter(s)",
+ region_count,
+ segment.lifetimes.len());
substs.mut_regions().truncate(space, 0);
}
}
if provided_len < required_len {
let qualifier =
if desired.len() != required_len { "at least " } else { "" };
- fcx.tcx().sess.span_err(
- span,
- format!("too few type parameters provided: \
- expected {}{} parameter(s) \
- but found {} parameter(s)",
- qualifier,
- required_len,
- provided_len).as_slice());
+ span_err!(fcx.tcx().sess, span, E0089,
+ "too few type parameters provided: expected {}{} parameter(s) \
+ but found {} parameter(s)",
+ qualifier, required_len, provided_len);
substs.types.replace(space,
Vec::from_elem(desired.len(), ty::mk_err()));
return;
// Otherwise, too few were provided. Report an error and then
// use inference variables.
- fcx.tcx().sess.span_err(
- span,
- format!(
- "too few lifetime parameters provided: \
- expected {} parameter(s) \
- but found {} parameter(s)",
- desired.len(),
- provided_len).as_slice());
+ span_err!(fcx.tcx().sess, span, E0090,
+ "too few lifetime parameters provided: expected {} parameter(s) \
+ but found {} parameter(s)",
+ desired.len(), provided_len);
substs.mut_regions().replace(
space,
for (i, b) in tps_used.iter().enumerate() {
if !*b {
- ccx.tcx.sess.span_err(
- span,
- format!("type parameter `{}` is unused",
- token::get_ident(tps.get(i).ident)).as_slice());
+ span_err!(ccx.tcx.sess, span, E0091,
+ "type parameter `{}` is unused",
+ token::get_ident(tps.get(i).ident));
}
}
}
(0, Vec::new(), ty::mk_nil())
}
op => {
- tcx.sess.span_err(it.span,
- format!("unrecognized atomic operation \
- function: `{}`",
- op).as_slice());
+ span_err!(tcx.sess, it.span, E0092,
+ "unrecognized atomic operation function: `{}`", op);
return;
}
}
ty::mk_tup(tcx, vec!(ty::mk_u64(), ty::mk_bool()))),
ref other => {
- tcx.sess.span_err(it.span,
- format!("unrecognized intrinsic function: `{}`",
- *other).as_slice());
+ span_err!(tcx.sess, it.span, E0093,
+ "unrecognized intrinsic function: `{}`", *other);
return;
}
}
let i_ty = ty::lookup_item_type(ccx.tcx, local_def(it.id));
let i_n_tps = i_ty.generics.types.len(subst::FnSpace);
if i_n_tps != n_tps {
- tcx.sess.span_err(it.span,
- format!("intrinsic has wrong number of type \
- parameters: found {}, expected {}",
- i_n_tps,
- n_tps).as_slice());
+ span_err!(tcx.sess, it.span, E0094,
+ "intrinsic has wrong number of type \
+ parameters: found {}, expected {}",
+ i_n_tps, n_tps);
} else {
require_same_types(tcx,
None,