E0091,
E0092,
E0093,
- E0094
+ E0094,
+ E0095,
+ E0096,
+ E0097,
+ E0098,
+ E0099,
+ E0100,
+ E0101,
+ E0102,
+ E0103,
+ E0104,
+ E0105,
+ E0106,
+ E0107,
+ E0108,
+ E0109,
+ E0110,
+ E0111,
+ E0112,
+ E0113,
+ E0114,
+ E0115,
+ E0116,
+ E0117,
+ E0118,
+ E0119,
+ E0120,
+ E0121,
+ E0122,
+ E0123,
+ E0124,
+ E0125,
+ E0126,
+ E0127,
+ E0128,
+ E0129,
+ E0130,
+ E0131,
+ E0132,
+ E0133,
+ E0134,
+ E0135,
+ E0136,
+ E0137,
+ E0138,
+ E0139,
+ E0140,
+ E0141,
+ E0142,
+ E0143,
+ E0144,
+ E0145,
+ E0146,
+ E0147,
+ E0148,
+ E0149,
+ E0150,
+ E0151,
+ E0152,
+ E0153,
+ E0154,
+ E0155,
+ E0156,
+ E0157
)
match self.unsafe_context {
SafeContext => {
// Report an error.
- self.tcx.sess.span_err(span,
- format!("{} requires unsafe function or \
- block",
- description).as_slice())
+ span_err!(self.tcx.sess, span, E0133,
+ "{} requires unsafe function or block",
+ description);
}
UnsafeBlock(block_id) => {
// OK, but record this.
match ty::get(base_type).sty {
ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) => match ty::get(ty).sty {
ty::ty_str => {
- self.tcx.sess.span_err(e.span,
- "modification of string types is not allowed");
+ span_err!(self.tcx.sess, e.span, E0134,
+ "modification of string types is not allowed");
}
_ => {}
},
ty::ty_str => {
- self.tcx.sess.span_err(e.span,
- "modification of string types is not allowed");
+ span_err!(self.tcx.sess, e.span, E0135,
+ "modification of string types is not allowed");
}
_ => {}
}
if ctxt.main_fn.is_none() {
ctxt.main_fn = Some((item.id, item.span));
} else {
- ctxt.session.span_err(
- item.span,
- "multiple 'main' functions");
+ span_err!(ctxt.session, item.span, E0136,
+ "multiple 'main' functions");
}
} else {
// This isn't main
if ctxt.attr_main_fn.is_none() {
ctxt.attr_main_fn = Some((item.id, item.span));
} else {
- ctxt.session.span_err(
- item.span,
- "multiple 'main' functions");
+ span_err!(ctxt.session, item.span, E0137,
+ "multiple functions with a #[main] attribute");
}
}
if ctxt.start_fn.is_none() {
ctxt.start_fn = Some((item.id, item.span));
} else {
- ctxt.session.span_err(
- item.span,
- "multiple 'start' functions");
+ span_err!(ctxt.session, item.span, E0138,
+ "multiple 'start' functions");
}
}
}
fn check_transmute(&self, span: Span, from: ty::t, to: ty::t) {
if type_size_is_affected_by_type_parameters(self.tcx, from) {
- self.tcx.sess.span_err(span,
- "cannot transmute from a type that \
- contains type parameters");
+ span_err!(self.tcx.sess, span, E0139,
+ "cannot transmute from a type that contains type parameters");
}
if type_size_is_affected_by_type_parameters(self.tcx, to) {
- self.tcx.sess.span_err(span,
- "cannot transmute to a type that contains \
- type parameters");
+ span_err!(self.tcx.sess, span, E0140,
+ "cannot transmute to a type that contains type parameters");
}
let restriction = TransmuteRestriction {
let struct_ty = ty::mk_struct(cx.tcx, struct_did,
subst::Substs::empty());
if !ty::type_is_sendable(cx.tcx, struct_ty) {
- cx.tcx.sess.span_err(span,
- "cannot implement a destructor on a \
- structure that does not satisfy Send");
- cx.tcx.sess.span_note(span,
- "use \"#[unsafe_destructor]\" on the \
- implementation to force the compiler to \
- allow this");
+ span_err!(cx.tcx.sess, span, E0125,
+ "cannot implement a destructor on a \
+ structure that does not satisfy Send");
+ span_note!(cx.tcx.sess, span,
+ "use \"#[unsafe_destructor]\" on the implementation \
+ to force the compiler to allow this");
}
} else {
- cx.tcx.sess.span_err(span,
- "cannot implement a destructor on a structure \
- with type parameters");
- cx.tcx.sess.span_note(span,
- "use \"#[unsafe_destructor]\" on the \
- implementation to force the compiler to \
- allow this");
+ span_err!(cx.tcx.sess, span, E0141,
+ "cannot implement a destructor on a structure \
+ with type parameters");
+ span_note!(cx.tcx.sess, span,
+ "use \"#[unsafe_destructor]\" on the implementation \
+ to force the compiler to allow this");
}
}
let self_ty: ty::t = ty::node_id_to_type(cx.tcx, it.id);
debug!("checking impl with self type {}", ty::get(self_ty).sty);
check_builtin_bounds(cx, self_ty, trait_def.bounds, |missing| {
- cx.tcx.sess.span_err(self_type.span,
- format!("the type `{}', which does not fulfill `{}`, cannot implement this \
- trait",
- ty_to_string(cx.tcx, self_ty),
- missing.user_string(cx.tcx)).as_slice());
- cx.tcx.sess.span_note(self_type.span,
- format!("types implementing this trait must fulfill `{}`",
- trait_def.bounds.user_string(cx.tcx)).as_slice());
+ span_err!(cx.tcx.sess, self_type.span, E0142,
+ "the type `{}', which does not fulfill `{}`, cannot implement this trait",
+ ty_to_string(cx.tcx, self_ty), missing.user_string(cx.tcx));
+ span_note!(cx.tcx.sess, self_type.span,
+ "types implementing this trait must fulfill `{}`",
+ trait_def.bounds.user_string(cx.tcx));
});
// If this is a destructor, check kinds.
}
fn check_for_bare(cx: &Context, fv: &freevar_entry) {
- cx.tcx.sess.span_err(
- fv.span,
- "can't capture dynamic environment in a fn item; \
- use the || { ... } closure form instead");
+ span_err!(cx.tcx.sess, fv.span, E0143,
+ "can't capture dynamic environment in a fn item; \
+ use the || {} closure form instead", "{ ... }");
} // same check is done in resolve.rs, but shouldn't be done
let fty = ty::node_id_to_type(cx.tcx, id);
ty,
type_param_def.bounds.builtin_bounds,
|missing| {
- cx.tcx.sess.span_err(
- sp,
- format!("instantiating a type parameter with an incompatible type \
- `{}`, which does not fulfill `{}`",
- ty_to_string(cx.tcx, ty),
- missing.user_string(cx.tcx)).as_slice());
+ span_err!(cx.tcx.sess, sp, E0144,
+ "instantiating a type parameter with an incompatible type \
+ `{}`, which does not fulfill `{}`",
+ ty_to_string(cx.tcx, ty),
+ missing.user_string(cx.tcx));
});
}
// Emit a less mysterious error message in this case.
match referenced_ty {
Some(rty) => {
- cx.tcx.sess.span_err(sp,
- format!("cannot implicitly borrow variable of type `{}` in a \
- bounded stack closure (implicit reference does not \
- fulfill `{}`)",
- ty_to_string(cx.tcx, rty),
- missing.user_string(cx.tcx)).as_slice())
+ span_err!(cx.tcx.sess, sp, E0145,
+ "cannot implicitly borrow variable of type `{}` in a \
+ bounded stack closure (implicit reference does not fulfill `{}`)",
+ ty_to_string(cx.tcx, rty), missing.user_string(cx.tcx));
}
None => {
- cx.tcx.sess.span_err(sp,
- format!("cannot capture variable of type `{}`, which does \
- not fulfill `{}`, in a bounded closure",
- ty_to_string(cx.tcx, ty),
- missing.user_string(cx.tcx)).as_slice())
+ span_err!(cx.tcx.sess, sp, E0146,
+ "cannot capture variable of type `{}`, which does \
+ not fulfill `{}`, in a bounded closure",
+ ty_to_string(cx.tcx, ty), missing.user_string(cx.tcx));
}
}
- cx.tcx.sess.span_note(
- sp,
- format!("this closure's environment must satisfy `{}`",
- bounds.user_string(cx.tcx)).as_slice());
+ span_note!(cx.tcx.sess, sp,
+ "this closure's environment must satisfy `{}`",
+ bounds.user_string(cx.tcx));
});
}
pub fn check_trait_cast_bounds(cx: &Context, sp: Span, ty: ty::t,
bounds: ty::BuiltinBounds) {
check_builtin_bounds(cx, ty, bounds, |missing| {
- cx.tcx.sess.span_err(sp,
- format!("cannot pack type `{}`, which does not fulfill \
- `{}`, as a trait bounded by {}",
- ty_to_string(cx.tcx, ty), missing.user_string(cx.tcx),
- bounds.user_string(cx.tcx)).as_slice());
+ span_err!(cx.tcx.sess, sp, E0147,
+ "cannot pack type `{}`, which does not fulfill `{}`, as a trait bounded by {}",
+ ty_to_string(cx.tcx, ty),
+ missing.user_string(cx.tcx),
+ bounds.user_string(cx.tcx));
});
}
ty_to_string(cx.tcx, ty),
ty::type_contents(cx.tcx, ty).to_string());
if ty::type_moves_by_default(cx.tcx, ty) {
- cx.tcx.sess.span_err(
- sp,
- format!("copying a value of non-copyable type `{}`",
- ty_to_string(cx.tcx, ty)).as_slice());
- cx.tcx.sess.span_note(sp, format!("{}", reason).as_slice());
+ span_err!(cx.tcx.sess, sp, E0148,
+ "copying a value of non-copyable type `{}`",
+ ty_to_string(cx.tcx, ty));
+ span_note!(cx.tcx.sess, sp, "{}", reason.as_slice());
}
}
pub fn check_static(tcx: &ty::ctxt, ty: ty::t, sp: Span) -> bool {
if !ty::type_is_static(tcx, ty) {
match ty::get(ty).sty {
- ty::ty_param(..) => {
- tcx.sess.span_err(sp,
- format!("value may contain references; \
- add `'static` bound to `{}`",
- ty_to_string(tcx, ty)).as_slice());
- }
- _ => {
- tcx.sess.span_err(sp, "value may contain references");
- }
+ ty::ty_param(..) => {
+ span_err!(tcx.sess, sp, E0149,
+ "value may contain references; \
+ add `'static` bound to `{}`",
+ ty_to_string(tcx, ty));
+ }
+ _ => {
+ span_err!(tcx.sess, sp, E0150,
+ "value may contain references");
+ }
}
false
} else {
// Ensure that `ty` has a statically known size (i.e., it has the `Sized` bound).
fn check_sized(tcx: &ty::ctxt, ty: ty::t, name: String, sp: Span) {
if !ty::type_is_sized(tcx, ty) {
- tcx.sess.span_err(sp,
- format!("variable `{}` has dynamically sized type \
- `{}`",
- name,
- ty_to_string(tcx, ty)).as_slice());
+ span_err!(tcx.sess, sp, E0151,
+ "variable `{}` has dynamically sized type `{}`",
+ name, ty_to_string(tcx, ty));
}
}
use syntax::ast;
use syntax::ast_util::local_def;
use syntax::attr::AttrMetaMethods;
+use syntax::codemap::{DUMMY_SP, Span};
use syntax::parse::token::InternedString;
use syntax::visit::Visitor;
use syntax::visit;
match item_index {
Some(item_index) => {
- self.collect_item(item_index, local_def(item.id))
+ self.collect_item(item_index, local_def(item.id), item.span)
}
None => {}
}
}
}
- pub fn collect_item(&mut self, item_index: uint, item_def_id: ast::DefId) {
+ pub fn collect_item(&mut self, item_index: uint,
+ item_def_id: ast::DefId, span: Span) {
// Check for duplicates.
match self.items.items.get(item_index) {
&Some(original_def_id) if original_def_id != item_def_id => {
- self.session.err(format!("duplicate entry for `{}`",
- LanguageItems::item_name(
- item_index)).as_slice());
+ span_err!(self.session, span, E0152,
+ "duplicate entry for `{}`", LanguageItems::item_name(item_index));
}
&Some(_) | &None => {
// OK.
crate_store.iter_crate_data(|crate_number, _crate_metadata| {
each_lang_item(crate_store, crate_number, |node_id, item_index| {
let def_id = ast::DefId { krate: crate_number, node: node_id };
- self.collect_item(item_index, def_id);
+ self.collect_item(item_index, def_id, DUMMY_SP);
true
});
})
this.record_def(path_id, (def, lp));
}
Some((DefStruct(_), _)) => {
- this.session.span_err(t.span,
- "super-struct is defined \
- in a different crate")
+ span_err!(this.session, t.span, E0154,
+ "super-struct is defined in a different crate");
},
- Some(_) => this.session.span_err(t.span,
- "super-struct is not a struct type"),
- None => this.session.span_err(t.span,
- "super-struct could not be resolved"),
+ Some(_) => {
+ span_err!(this.session, t.span, E0155,
+ "super-struct is not a struct type");
+ }
+ None => {
+ span_err!(this.session, t.span, E0156,
+ "super-struct could not be resolved");
+ }
}
},
_ => this.session.span_bug(t.span, "path not mapped to a TyPath")
if path.segments
.iter()
.any(|s| !s.lifetimes.is_empty()) {
- self.session.span_err(path.span,
- "lifetime parameters \
- are not allowed on \
- this type")
+ span_err!(self.session, path.span, E0157,
+ "lifetime parameters are not allowed on this type");
} else if path.segments
.iter()
.any(|s| s.types.len() > 0) {
- self.session.span_err(path.span,
- "type parameters are \
- not allowed on this \
- type")
+ span_err!(self.session, path.span, E0153,
+ "type parameters are not allowed on this type");
}
}
None => {
match rscope.anon_regions(default_span, 1) {
Err(()) => {
debug!("optional region in illegal location");
- this.tcx().sess.span_err(
- default_span, "missing lifetime specifier");
+ span_err!(this.tcx().sess, default_span, E0106,
+ "missing lifetime specifier");
ty::ReStatic
}
rscope.anon_regions(path.span, expected_num_region_params);
if supplied_num_region_params != 0 || anon_regions.is_err() {
- tcx.sess.span_err(
- path.span,
- format!("wrong number of lifetime parameters: \
- expected {} but found {}",
- expected_num_region_params,
- supplied_num_region_params).as_slice());
+ span_err!(tcx.sess, path.span, E0107,
+ "wrong number of lifetime parameters: expected {} but found {}",
+ expected_num_region_params, supplied_num_region_params);
}
match anon_regions {
if supplied_ty_param_count > required_ty_param_count
&& !this.tcx().sess.features.default_type_params.get() {
- this.tcx().sess.span_err(path.span, "default type parameters are \
- experimental and possibly buggy");
- this.tcx().sess.span_note(path.span, "add #![feature(default_type_params)] \
- to the crate attributes to enable");
+ span_err!(this.tcx().sess, path.span, E0108,
+ "default type parameters are experimental and possibly buggy");
+ span_note!(this.tcx().sess, path.span,
+ "add #![feature(default_type_params)] to the crate attributes to enable");
}
let tps = path.segments.iter().flat_map(|s| s.types.iter())
flags: uint) {
if (flags & NO_TPS) != 0u {
if !path.segments.iter().all(|s| s.types.is_empty()) {
- tcx.sess.span_err(
- path.span,
+ span_err!(tcx.sess, path.span, E0109,
"type parameters are not allowed on this type");
}
}
if (flags & NO_REGIONS) != 0u {
if !path.segments.last().unwrap().lifetimes.is_empty() {
- tcx.sess.span_err(
- path.span,
+ span_err!(tcx.sess, path.span, E0110,
"region parameters are not allowed on this type");
}
}
Some(ty::mk_mach_float(ft))
}
ast::TyStr => {
- tcx.sess.span_err(ast_ty.span,
- "bare `str` is not a type");
+ span_err!(tcx.sess, ast_ty.span, E0037,
+ "bare `str` is not a type");
// return /something/ so they can at least get more errors
Some(ty::mk_uniq(tcx, ty::mk_str(tcx)))
}
.iter()
.flat_map(|s| s.types.iter())
.count() > 1 {
- this.tcx()
- .sess
- .span_err(path.span,
- "`Box` has only one type parameter")
+ span_err!(this.tcx().sess, path.span, E0047,
+ "`Box` has only one type parameter");
}
for inner_ast_type in path.segments
|typ| {
match ty::get(typ).sty {
ty::ty_str => {
- this.tcx()
- .sess
- .span_err(path.span,
- "`Box<str>` is not a type");
+ span_err!(this.tcx().sess, path.span, E0111,
+ "`Box<str>` is not a type");
ty::mk_err()
}
ty::ty_vec(_, None) => {
- this.tcx()
- .sess
- .span_err(path.span,
+ span_err!(this.tcx().sess, path.span, E0112,
"`Box<[T]>` is not a type");
ty::mk_err()
}
}
}))
}
- this.tcx().sess.span_err(path.span,
- "not enough type parameters \
- supplied to `Box<T>`");
+ span_err!(this.tcx().sess, path.span, E0113,
+ "not enough type parameters supplied to `Box<T>`");
Some(ty::mk_err())
}
def::DefTy(did) | def::DefStruct(did)
.iter()
.flat_map(|s| s.types.iter())
.count() > 1 {
- this.tcx()
- .sess
- .span_err(path.span,
- "`Gc` has only one type parameter")
+ span_err!(this.tcx().sess, path.span, E0048,
+ "`Gc` has only one type parameter");
}
for inner_ast_type in path.segments
|typ| {
match ty::get(typ).sty {
ty::ty_str => {
- this.tcx()
- .sess
- .span_err(path.span,
- "`Gc<str>` is not a type");
+ span_err!(this.tcx().sess, path.span, E0114,
+ "`Gc<str>` is not a type");
ty::mk_err()
}
ty::ty_vec(_, None) => {
- this.tcx()
- .sess
- .span_err(path.span,
- "`Gc<[T]>` is not a type");
+ span_err!(this.tcx().sess, path.span, E0115,
+ "`Gc<[T]>` is not a type");
ty::mk_err()
}
_ => ty::mk_box(this.tcx(), typ),
!ty::trait_ref_contains_error(&r_exp_trait_ref)
{
let tcx = vcx.tcx();
- tcx.sess.span_err(span,
- format!("expected {}, but found {} ({})",
- ppaux::trait_ref_to_string(tcx, &r_exp_trait_ref),
- ppaux::trait_ref_to_string(tcx, &r_act_trait_ref),
- ty::type_err_to_str(tcx, err)).as_slice());
+ span_err!(tcx.sess, span, E0095, "expected {}, but found {} ({})",
+ ppaux::trait_ref_to_string(tcx, &r_exp_trait_ref),
+ ppaux::trait_ref_to_string(tcx, &r_act_trait_ref),
+ ty::type_err_to_str(tcx, err));
}
}
}
1 => return Some(found.get(0).clone()),
_ => {
if !is_early {
- vcx.tcx().sess.span_err(span, "multiple applicable methods in scope");
+ span_err!(vcx.tcx().sess, span, E0096,
+ "multiple applicable methods in scope");
}
return Some(found.get(0).clone());
}
if !mutability_allowed(mt.mutbl, mutbl) => {
match ty::get(ty).sty {
ty::ty_trait(..) => {
- fcx.tcx()
- .sess
- .span_err(ex.span, "types differ in mutability");
+ span_err!(fcx.tcx().sess, ex.span, E0097, "types differ in mutability");
}
_ => {}
}
(&ty::ty_uniq(ty), _) => {
match ty::get(ty).sty {
ty::ty_trait(..) => {
- fcx.ccx.tcx.sess.span_err(
- ex.span,
- format!("can only cast an boxed pointer \
- to a boxed object, not a {}",
- ty::ty_sort_string(fcx.tcx(), src_ty)).as_slice());
+ span_err!(fcx.ccx.tcx.sess, ex.span, E0098,
+ "can only cast an boxed pointer to a boxed object, not a {}",
+ ty::ty_sort_string(fcx.tcx(), src_ty));
}
_ => {}
}
(&ty::ty_rptr(_, ty::mt{ty, ..}), _) => {
match ty::get(ty).sty {
ty::ty_trait(..) => {
- fcx.ccx.tcx.sess.span_err(
- ex.span,
- format!("can only cast an &-pointer \
- to an &-object, not a {}",
- ty::ty_sort_string(fcx.tcx(), src_ty)).as_slice());
+ span_err!(fcx.ccx.tcx.sess, ex.span, E0099,
+ "can only cast an &-pointer to an &-object, not a {}",
+ ty::ty_sort_string(fcx.tcx(), src_ty));
}
_ => {}
}
Some(&def::DefStruct(_)) => {
}
_ => {
- self.tcx().sess.span_err(
- reason.span(self.tcx()),
- "cannot coerce non-statically resolved bare fn")
+ span_err!(self.tcx().sess, reason.span(self.tcx()), E0100,
+ "cannot coerce non-statically resolved bare fn");
}
}
if !self.tcx.sess.has_errors() {
match self.reason {
ResolvingExpr(span) => {
- self.tcx.sess.span_err(
- span,
- format!("cannot determine a type for \
- this expression: {}",
- infer::fixup_err_to_string(e)).as_slice())
+ span_err!(self.tcx.sess, span, E0101,
+ "cannot determine a type for this expression: {}",
+ infer::fixup_err_to_string(e));
}
ResolvingLocal(span) => {
- self.tcx.sess.span_err(
- span,
- format!("cannot determine a type for \
- this local variable: {}",
- infer::fixup_err_to_string(e)).as_slice())
+ span_err!(self.tcx.sess, span, E0102,
+ "cannot determine a type for this local variable: {}",
+ infer::fixup_err_to_string(e));
}
ResolvingPattern(span) => {
- self.tcx.sess.span_err(
- span,
- format!("cannot determine a type for \
- this pattern binding: {}",
- infer::fixup_err_to_string(e)).as_slice())
+ span_err!(self.tcx.sess, span, E0103,
+ "cannot determine a type for this pattern binding: {}",
+ infer::fixup_err_to_string(e));
}
ResolvingUpvar(upvar_id) => {
let span = self.reason.span(self.tcx);
- self.tcx.sess.span_err(
- span,
- format!("cannot resolve lifetime for \
- captured variable `{}`: {}",
- ty::local_var_name_str(
- self.tcx,
- upvar_id.var_id).get().to_string(),
- infer::fixup_err_to_string(e)).as_slice());
+ span_err!(self.tcx.sess, span, E0104,
+ "cannot resolve lifetime for captured variable `{}`: {}",
+ ty::local_var_name_str(self.tcx, upvar_id.var_id).get().to_string(),
+ infer::fixup_err_to_string(e));
}
ResolvingImplRes(span) => {
- self.tcx
- .sess
- .span_err(span,
- "cannot determine a type for impl \
- supertrait");
+ span_err!(self.tcx.sess, span, E0105,
+ "cannot determine a type for impl supertrait");
}
}
}
if !self.cc.ast_type_is_defined_in_local_crate(&**ast_ty) {
// This is an error.
let session = &self.cc.crate_context.tcx.sess;
- session.span_err(item.span,
- "cannot associate methods with a type outside the \
- crate the type is defined in; define and implement \
- a trait or new type instead");
+ span_err!(session, item.span, E0116,
+ "cannot associate methods with a type outside the \
+ crate the type is defined in; define and implement \
+ a trait or new type instead");
}
}
ItemImpl(_, Some(ref trait_ref), _, _) => {
if trait_def_id.krate != LOCAL_CRATE {
let session = &self.cc.crate_context.tcx.sess;
- session.span_err(item.span,
- "cannot provide an extension implementation \
- where both trait and type are not defined in this crate");
+ span_err!(session, item.span, E0117,
+ "cannot provide an extension implementation \
+ where both trait and type are not defined in this crate");
}
}
self_type.ty) {
None => {
let session = &self.crate_context.tcx.sess;
- session.span_err(item.span,
- "no base type found for inherent implementation; \
- implement a trait or new type instead");
+ span_err!(session, item.span, E0118,
+ "no base type found for inherent implementation; \
+ implement a trait or new type instead");
}
Some(_) => {
// Nothing to do.
if self.polytypes_unify(polytype_a.clone(), polytype_b) {
let session = &self.crate_context.tcx.sess;
- session.span_err(
- self.span_of_impl(impl_a),
- format!("conflicting implementations for trait `{}`",
- ty::item_path_str(
- self.crate_context.tcx,
- trait_def_id)).as_slice());
+ span_err!(session, self.span_of_impl(impl_a), E0119,
+ "conflicting implementations for trait `{}`",
+ ty::item_path_str(self.crate_context.tcx, trait_def_id));
if impl_b.krate == LOCAL_CRATE {
- session.span_note(self.span_of_impl(impl_b),
- "note conflicting implementation here");
+ span_note!(session, self.span_of_impl(impl_b),
+ "note conflicting implementation here");
} else {
let crate_store = &self.crate_context.tcx.sess.cstore;
let cdata = crate_store.get_crate_data(impl_b.krate);
- session.note(
- format!("conflicting implementation in crate \
- `{}`",
- cdata.name).as_slice());
+ span_note!(session, self.span_of_impl(impl_a),
+ "conflicting implementation in crate `{}`",
+ cdata.name);
}
}
}
{
match tcx.map.find(impl_did.node) {
Some(ast_map::NodeItem(item)) => {
- tcx.sess.span_err((*item).span,
- "the Drop trait may \
- only be implemented \
- on structures");
+ span_err!(tcx.sess, item.span, E0120,
+ "the Drop trait may only be implemented on structures");
}
_ => {
tcx.sess.bug("didn't find impl in ast \
}
fn ty_infer(&self, span: Span) -> ty::t {
- self.tcx.sess.span_err(span, "the type placeholder `_` is not \
- allowed within types on item \
- signatures.");
+ span_err!(self.tcx.sess, span, E0121,
+ "the type placeholder `_` is not allowed within types on item signatures.");
ty::mk_err()
}
}
thing: &'static str) {
for ty_param in generics.ty_params.iter() {
if ty_param.bounds.len() > 0 {
- ccx.tcx.sess.span_err(
- span,
- format!("trait bounds are not allowed in {} definitions",
- thing).as_slice());
+ span_err!(ccx.tcx.sess, span, E0122,
+ "trait bounds are not allowed in {} definitions", thing);
}
}
}
generics: &ast::Generics) {
if generics.ty_params.len() > 0 &&
!(abi == abi::Rust || abi == abi::RustIntrinsic) {
- ccx.tcx.sess.span_err(span,
- "foreign functions may not use type parameters");
+ span_err!(ccx.tcx.sess, span, E0123,
+ "foreign functions may not use type parameters");
}
}
if result.name != special_idents::unnamed_field.name {
let dup = match seen_fields.find(&result.name) {
Some(prev_span) => {
- tcx.sess.span_err(
- f.span,
- format!("field `{}` is already declared",
- token::get_name(result.name)).as_slice());
- tcx.sess.span_note(*prev_span,
- "previously declared here");
+ span_err!(tcx.sess, f.span, E0124,
+ "field `{}` is already declared",
+ token::get_name(result.name));
+ span_note!(tcx.sess, *prev_span, "previously declared here");
true
},
None => false,
Some(ast_map::NodeItem(i)) => match i.node {
ast::ItemStruct(struct_def, _) => {
if !struct_def.is_virtual {
- tcx.sess.span_err(t.span,
- "struct inheritance is only \
- allowed from virtual structs");
+ span_err!(tcx.sess, t.span, E0126,
+ "struct inheritance is only \
+ allowed from virtual structs");
}
},
_ => {},
{
// This means a trait inherited from the same
// supertrait more than once.
- tcx.sess.span_err(sp, "duplicate supertrait in \
- trait declaration");
+ span_err!(tcx.sess, sp, E0127,
+ "duplicate supertrait in trait declaration");
break;
} else {
ty_trait_refs.push(trait_ref);
ty::walk_ty(ty, |t| {
match ty::get(t).sty {
ty::ty_param(p) => if p.idx > cur_idx {
- ccx.tcx.sess.span_err(
- path.span,
- "type parameters with a default cannot use \
- forward declared identifiers")
+ span_err!(ccx.tcx.sess, path.span, E0128,
+ "type parameters with a default cannot use \
+ forward declared identifiers");
},
_ => {}
}
|trait_ref| {
let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id);
if trait_def.bounds.contains_elem(ty::BoundSized) {
- tcx.sess.span_err(span,
- format!("incompatible bounds on type parameter {}, \
- bound {} does not allow unsized type",
- token::get_ident(ident),
- ppaux::trait_ref_to_string(tcx,
- &*trait_ref)).as_slice());
+ span_err!(tcx.sess, span, E0129,
+ "incompatible bounds on type parameter {}, \
+ bound {} does not allow unsized type",
+ token::get_ident(ident),
+ ppaux::trait_ref_to_string(tcx, &*trait_ref));
}
true
});
match (*i).pat.node {
ast::PatIdent(_, _, _) => (),
ast::PatWild => (),
- _ => ccx.tcx.sess.span_err((*i).pat.span,
- "patterns aren't allowed in foreign function declarations")
+ _ => {
+ span_err!(ccx.tcx.sess, (*i).pat.span, E0130,
+ "patterns aren't allowed in foreign function declarations");
+ }
}
}
match it.node {
ast::ItemFn(_, _, _, ref ps, _)
if ps.is_parameterized() => {
- tcx.sess.span_err(
- main_span,
- "main function is not allowed to have type parameters");
+ span_err!(ccx.tcx.sess, main_span, E0131,
+ "main function is not allowed to have type parameters");
return;
}
_ => ()
match it.node {
ast::ItemFn(_,_,_,ref ps,_)
if ps.is_parameterized() => {
- tcx.sess.span_err(
- start_span,
- "start function is not allowed to have type parameters");
+ span_err!(tcx.sess, start_span, E0132,
+ "start function is not allowed to have type parameters");
return;
}
_ => ()
#[macro_export]
macro_rules! span_err(
- ($session:expr, $span:expr, $code:ident, $($arg:expr),*) => ({
+ ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
__diagnostic_used!($code);
- ($session).span_err_with_code($span, format!($($arg),*).as_slice(), stringify!($code))
+ $session.span_err_with_code($span, format!($($message)*).as_slice(), stringify!($code))
})
)
#[macro_export]
macro_rules! span_warn(
- ($session:expr, $span:expr, $code:ident, $($arg:expr),*) => ({
+ ($session:expr, $span:expr, $code:ident, $($message:tt)*) => ({
__diagnostic_used!($code);
- ($session).span_warn_with_code($span, format!($($arg),*).as_slice(), stringify!($code))
+ $session.span_warn_with_code($span, format!($($message)*).as_slice(), stringify!($code))
})
)
#[macro_export]
macro_rules! span_note(
- ($session:expr, $span:expr, $($arg:expr),*) => ({
- ($session).span_note($span, format!($($arg),*).as_slice())
+ ($session:expr, $span:expr, $($message:tt)*) => ({
+ ($session).span_note($span, format!($($message)*).as_slice())
})
)
}
#[main]
-fn foo() { //~ ERROR multiple 'main' functions
+fn foo() { //~ ERROR multiple functions with a #[main] attribute
}
mod foo {
#[main]
- fn main2() { //~ ERROR multiple 'main' functions
+ fn main2() { //~ ERROR multiple functions with a #[main] attribute
}
}