E0161,
E0162,
E0165,
- E0170
+ E0170,
+ E0261, // use of undeclared lifetime name
+ E0262, // illegal lifetime parameter name
+ E0263, // lifetime name declared twice in same scope
+ E0264, // unknown external lang item
+ E0265, // recursive constant
+ E0266, // expected item
+ E0267, // thing inside of a closure
+ E0268, // thing outside of a loop
+ E0269, // not all control paths return a value
+ E0270, // computation may converge in a function marked as diverging
+ E0271, // type mismatch resolving
+ E0272, // rustc_on_unimplemented attribute refers to non-existent type parameter
+ E0273, // rustc_on_unimplemented must have named format arguments
+ E0274, // rustc_on_unimplemented must have a value
+ E0275, // overflow evaluating requirement
+ E0276, // requirement appears on impl method but not on corresponding trait method
+ E0277, // trait is not implemented for type
+ E0278, // requirement is not satisfied
+ E0279, // requirement is not satisfied
+ E0280, // requirement is not satisfied
+ E0281, // type implements trait but other trait is required
+ E0282, // unable to infer enough type information about
+ E0283, // cannot resolve type
+ E0284, // cannot resolve type
+ E0285, // overflow evaluation builtin bounds
+ E0296, // malformed recursion limit attribute
+ E0297, // refutable pattern in for loop binding
+ E0298, // mismatched types between arms
+ E0299, // mismatched types between arms
+ E0300, // unexpanded macro
+ E0301, // cannot mutable borrow in a pattern guard
+ E0302, // cannot assign in a pattern guard
+ E0303, // pattern bindings are not allowed after an `@`
+ E0304, // expected signed integer constant
+ E0305, // expected constant
+ E0306, // expected positive integer for repeat count
+ E0307, // expected constant integer for repeat count
+ E0308,
+ E0309, // thing may not live long enough
+ E0310, // thing may not live long enough
+ E0311, // thing may not live long enough
+ E0312, // lifetime of reference outlives lifetime of borrowed content
+ E0313, // lifetime of borrowed pointer outlives lifetime of captured variable
+ E0314, // closure outlives stack frame
+ E0315 // cannot invoke closure outside of its lifetime
}
__build_diagnostic_array! { DIAGNOSTICS }
match self.cx {
Loop => {}
Closure => {
- self.sess.span_err(span,
- &format!("`{}` inside of a closure", name)[]);
+ span_err!(self.sess, span, E0267,
+ "`{}` inside of a closure", name);
}
Normal => {
- self.sess.span_err(span,
- &format!("`{}` outside of loop", name)[]);
+ span_err!(self.sess, span, E0268,
+ "`{}` outside of loop", name);
}
}
}
ast::ExprForLoop(ref pat, _, _, _) => {
let mut static_inliner = StaticInliner::new(cx.tcx);
is_refutable(cx, &*static_inliner.fold_pat((*pat).clone()), |uncovered_pat| {
- cx.tcx.sess.span_err(
- pat.span,
- &format!("refutable pattern in `for` loop binding: \
+ span_err!(cx.tcx.sess, pat.span, E0297,
+ "refutable pattern in `for` loop binding: \
`{}` not covered",
- pat_to_string(uncovered_pat))[]);
+ pat_to_string(uncovered_pat));
});
// Check legality of move bindings.
Some(true) => Some(vec![]),
Some(false) => None,
None => {
- cx.tcx.sess.span_err(pat_span, "mismatched types between arms");
+ span_err!(cx.tcx.sess, pat_span, E0298, "mismatched types between arms");
None
}
}
Some(true) => Some(vec![]),
Some(false) => None,
None => {
- cx.tcx.sess.span_err(pat_span, "mismatched types between arms");
+ span_err!(cx.tcx.sess, pat_span, E0299, "mismatched types between arms");
None
}
}
}
ast::PatMac(_) => {
- cx.tcx.sess.span_err(pat_span, "unexpanded macro");
+ span_err!(cx.tcx.sess, pat_span, E0300, "unexpanded macro");
None
}
};
_: LoanCause) {
match kind {
MutBorrow => {
- self.cx
- .tcx
- .sess
- .span_err(span,
- "cannot mutably borrow in a pattern guard")
+ span_err!(self.cx.tcx.sess, span, E0301,
+ "cannot mutably borrow in a pattern guard")
}
ImmBorrow | UniqueImmBorrow => {}
}
fn mutate(&mut self, _: NodeId, span: Span, _: cmt, mode: MutateMode) {
match mode {
JustWrite | WriteAndRead => {
- self.cx
- .tcx
- .sess
- .span_err(span, "cannot assign in a pattern guard")
+ span_err!(self.cx.tcx.sess, span, E0302, "cannot assign in a pattern guard")
}
Init => {}
}
impl<'a, 'b, 'tcx, 'v> Visitor<'v> for AtBindingPatternVisitor<'a, 'b, 'tcx> {
fn visit_pat(&mut self, pat: &Pat) {
if !self.bindings_allowed && pat_is_binding(&self.cx.tcx.def_map, pat) {
- self.cx.tcx.sess.span_err(pat.span,
+ span_err!(self.cx.tcx.sess, pat.span, E0303,
"pattern bindings are not allowed \
after an `@`");
}
impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
fn visit_item(&mut self, it: &ast::Item) {
if self.idstack.iter().any(|x| x == &(it.id)) {
- self.sess.span_err(self.root_it.span, "recursive constant");
+ span_err!(self.sess, self.root_it.span, E0265, "recursive constant");
return;
}
self.idstack.push(it.id);
self.visit_item(item),
ast_map::NodeForeignItem(_) => {},
_ => {
- self.sess.span_err(e.span,
- &format!("expected item, found {}",
- self.ast_map.node_to_string(def_id.node))[]);
+ span_err!(self.sess, e.span, E0266,
+ "expected item, found {}",
+ self.ast_map.node_to_string(def_id.node));
return;
},
}
infer::EquatePredicate(_) => "equality predicate not satisfied",
};
- self.tcx.sess.span_err(
- trace.origin.span(),
- &format!("{}: {} ({})",
+ span_err!(self.tcx.sess, trace.origin.span(), E0308,
+ "{}: {} ({})",
message_root_str,
expected_found_str,
- ty::type_err_to_str(self.tcx, terr))[]);
+ ty::type_err_to_str(self.tcx, terr));
match trace.origin {
infer::MatchExpressionArm(_, arm_span) =>
match sub {
ty::ReFree(ty::FreeRegion {bound_region: ty::BrNamed(..), ..}) => {
// Does the required lifetime have a nice name we can print?
- self.tcx.sess.span_err(
- origin.span(),
- &format!("{} may not live long enough", labeled_user_string)[]);
+ span_err!(self.tcx.sess, origin.span(), E0309,
+ "{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
ty::ReStatic => {
// Does the required lifetime have a nice name we can print?
- self.tcx.sess.span_err(
- origin.span(),
- &format!("{} may not live long enough", labeled_user_string)[]);
+ span_err!(self.tcx.sess, origin.span(), E0310,
+ "{} may not live long enough", labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
_ => {
// If not, be less specific.
- self.tcx.sess.span_err(
- origin.span(),
- &format!(
+ span_err!(self.tcx.sess, origin.span(), E0311,
"{} may not live long enough",
- labeled_user_string)[]);
+ labeled_user_string);
self.tcx.sess.span_help(
origin.span(),
&format!(
self.report_and_explain_type_error(trace, &terr);
}
infer::Reborrow(span) => {
- self.tcx.sess.span_err(
- span,
+ span_err!(self.tcx.sess, span, E0312,
"lifetime of reference outlines \
lifetime of borrowed content...");
note_and_explain_region(
"");
}
infer::ReborrowUpvar(span, ref upvar_id) => {
- self.tcx.sess.span_err(
- span,
- &format!("lifetime of borrowed pointer outlives \
+ span_err!(self.tcx.sess, span, E0313,
+ "lifetime of borrowed pointer outlives \
lifetime of captured variable `{}`...",
ty::local_var_name_str(self.tcx,
upvar_id.var_id)
.get()
- .to_string())[]);
+ .to_string());
note_and_explain_region(
self.tcx,
"...the borrowed pointer is valid for ",
"");
}
infer::InfStackClosure(span) => {
- self.tcx.sess.span_err(
- span,
+ span_err!(self.tcx.sess, span, E0314,
"closure outlives stack frame");
note_and_explain_region(
self.tcx,
"");
}
infer::InvokeClosure(span) => {
- self.tcx.sess.span_err(
- span,
+ span_err!(self.tcx.sess, span, E0315,
"cannot invoke closure outside of its lifetime");
note_and_explain_region(
self.tcx,
},
_ => false
};
- self.ir.tcx.sess.span_err(
- sp, "not all control paths return a value");
+ span_err!(self.ir.tcx.sess, sp, E0269, "not all control paths return a value");
if ends_with_stmt {
let last_stmt = body.stmts.first().unwrap();
let original_span = original_sp(self.ir.tcx.sess.codemap(),
}
ty::FnDiverging
if self.live_on_entry(entry_ln, self.s.clean_exit_var).is_some() => {
- self.ir.tcx.sess.span_err(sp,
+ span_err!(self.ir.tcx.sess, sp, E0270,
"computation may converge in a function marked as diverging");
}
}
}
- sess.span_err(attr.span, "malformed recursion limit attribute, \
+ span_err!(sess, attr.span, E0296, "malformed recursion limit attribute, \
expected #![recursion_limit=\"N\"]");
}
}
}
fn unresolved_lifetime_ref(&self, lifetime_ref: &ast::Lifetime) {
- self.sess.span_err(
- lifetime_ref.span,
- &format!("use of undeclared lifetime name `{}`",
- token::get_name(lifetime_ref.name))[]);
+ span_err!(self.sess, lifetime_ref.span, E0261,
+ "use of undeclared lifetime name `{}`",
+ token::get_name(lifetime_ref.name));
}
fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
let special_idents = [special_idents::static_lifetime];
for lifetime in lifetimes.iter() {
if special_idents.iter().any(|&i| i.name == lifetime.lifetime.name) {
- self.sess.span_err(
- lifetime.lifetime.span,
- &format!("illegal lifetime parameter name: `{}`",
- token::get_name(lifetime.lifetime.name))
- []);
+ span_err!(self.sess, lifetime.lifetime.span, E0262,
+ "illegal lifetime parameter name: `{}`",
+ token::get_name(lifetime.lifetime.name));
}
}
let lifetime_j = &lifetimes[j];
if lifetime_i.lifetime.name == lifetime_j.lifetime.name {
- self.sess.span_err(
- lifetime_j.lifetime.span,
- &format!("lifetime name `{}` declared twice in \
+ span_err!(self.sess, lifetime_j.lifetime.span, E0263,
+ "lifetime name `{}` declared twice in \
the same scope",
- token::get_name(lifetime_j.lifetime.name))
- []);
+ token::get_name(lifetime_j.lifetime.name));
}
}
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
if !predicate.references_error() {
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0271,
"type mismatch resolving `{}`: {}",
predicate.user_string(infcx.tcx),
- ty::type_err_to_str(infcx.tcx, &error.err)).as_slice());
+ ty::type_err_to_str(infcx.tcx, &error.err));
note_obligation_cause(infcx, obligation);
}
}
Position::ArgumentNamed(s) => match generic_map.get(s) {
Some(val) => Some(val.as_slice()),
None => {
- infcx.tcx.sess
- .span_err(err_sp,
- format!("the #[rustc_on_unimplemented] \
+ span_err!(infcx.tcx.sess, err_sp, E0272,
+ "the #[rustc_on_unimplemented] \
attribute on \
trait definition for {} refers to \
non-existent type parameter {}",
- trait_str, s)
- .as_slice());
+ trait_str, s);
errored = true;
None
}
},
_ => {
- infcx.tcx.sess
- .span_err(err_sp,
- format!("the #[rustc_on_unimplemented] \
+ span_err!(infcx.tcx.sess, err_sp, E0273,
+ "the #[rustc_on_unimplemented] \
attribute on \
trait definition for {} must have named \
format arguments, \
eg `#[rustc_on_unimplemented = \
\"foo {{T}}\"]`",
- trait_str).as_slice());
+ trait_str);
errored = true;
None
}
report = Some(err);
}
} else {
- infcx.tcx.sess.span_err(err_sp,
- format!("the #[rustc_on_unimplemented] attribute on \
+ span_err!(infcx.tcx.sess, err_sp, E0274,
+ "the #[rustc_on_unimplemented] attribute on \
trait definition for {} must have a value, \
eg `#[rustc_on_unimplemented = \"foo\"]`",
- trait_str).as_slice());
+ trait_str);
}
break;
}
// We could track the stack here more precisely if we wanted, I imagine.
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0275,
"overflow evaluating the requirement `{}`",
- predicate.user_string(infcx.tcx)).as_slice());
+ predicate.user_string(infcx.tcx));
suggest_new_overflow_limit(infcx.tcx, obligation.cause.span);
SelectionError::Unimplemented => {
match &obligation.cause.code {
&ObligationCauseCode::CompareImplMethodObligation => {
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0276,
"the requirement `{}` appears on the impl \
method but not on the corresponding trait method",
- obligation.predicate.user_string(infcx.tcx)).as_slice());
+ obligation.predicate.user_string(infcx.tcx));;
}
_ => {
match obligation.predicate {
if !trait_predicate.references_error() {
let trait_ref = trait_predicate.to_poly_trait_ref();
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0277,
"the trait `{}` is not implemented for the type `{}`",
trait_ref.user_string(infcx.tcx),
- trait_ref.self_ty().user_string(infcx.tcx)).as_slice());
+ trait_ref.self_ty().user_string(infcx.tcx));
// Check if it has a custom "#[rustc_on_unimplemented]"
// error message, report with that message if it does
let custom_note = report_on_unimplemented(infcx, &*trait_ref.0,
let predicate = infcx.resolve_type_vars_if_possible(predicate);
let err = infcx.equality_predicate(obligation.cause.span,
&predicate).unwrap_err();
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0278,
"the requirement `{}` is not satisfied (`{}`)",
predicate.user_string(infcx.tcx),
- ty::type_err_to_str(infcx.tcx, &err)).as_slice());
+ ty::type_err_to_str(infcx.tcx, &err));
}
ty::Predicate::RegionOutlives(ref predicate) => {
let predicate = infcx.resolve_type_vars_if_possible(predicate);
let err = infcx.region_outlives_predicate(obligation.cause.span,
&predicate).unwrap_err();
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0279,
"the requirement `{}` is not satisfied (`{}`)",
predicate.user_string(infcx.tcx),
- ty::type_err_to_str(infcx.tcx, &err)).as_slice());
+ ty::type_err_to_str(infcx.tcx, &err));
}
ty::Predicate::Projection(..) | ty::Predicate::TypeOutlives(..) => {
let predicate =
infcx.resolve_type_vars_if_possible(&obligation.predicate);
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0280,
"the requirement `{}` is not satisfied",
- predicate.user_string(infcx.tcx)).as_slice());
+ predicate.user_string(infcx.tcx));
}
}
}
let expected_trait_ref = infcx.resolve_type_vars_if_possible(&*expected_trait_ref);
let actual_trait_ref = infcx.resolve_type_vars_if_possible(&*actual_trait_ref);
if !ty::type_is_error(actual_trait_ref.self_ty()) {
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0281,
"type mismatch: the type `{}` implements the trait `{}`, \
but the trait `{}` is required ({})",
expected_trait_ref.self_ty().user_string(infcx.tcx),
expected_trait_ref.user_string(infcx.tcx),
actual_trait_ref.user_string(infcx.tcx),
- ty::type_err_to_str(infcx.tcx, e)).as_slice());
+ ty::type_err_to_str(infcx.tcx, e));
note_obligation_cause(infcx, obligation);
}
}
infcx.tcx.lang_items.sized_trait()
.map_or(false, |sized_id| sized_id == trait_ref.def_id())
{
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0282,
"unable to infer enough type information about `{}`; \
type annotations required",
- self_ty.user_string(infcx.tcx)).as_slice());
+ self_ty.user_string(infcx.tcx));
} else {
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0283,
"type annotations required: cannot resolve `{}`",
- predicate.user_string(infcx.tcx)).as_slice());
+ predicate.user_string(infcx.tcx));;
note_obligation_cause(infcx, obligation);
}
}
_ => {
if !infcx.tcx.sess.has_errors() {
- infcx.tcx.sess.span_err(
- obligation.cause.span,
- format!(
+ span_err!(infcx.tcx.sess, obligation.cause.span, E0284,
"type annotations required: cannot resolve `{}`",
- predicate.user_string(infcx.tcx)).as_slice());
+ predicate.user_string(infcx.tcx));;
note_obligation_cause(infcx, obligation);
}
}
false
}
Err(Overflow) => {
- infcx.tcx.sess.span_err(
- span,
- format!("overflow evaluating whether `{}` is `{}`",
- ty.user_string(infcx.tcx),
- bound.user_string(infcx.tcx)).as_slice());
+ span_err!(infcx.tcx.sess, span, E0285,
+ "overflow evaluating whether `{}` is `{}`",
+ ty.user_string(infcx.tcx),
+ bound.user_string(infcx.tcx));
suggest_new_overflow_limit(infcx.tcx, span);
false
}
discriminant = val as Disr
}
Ok(_) => {
- cx.sess
- .span_err(e.span,
+ span_err!(cx.sess, e.span, E0304,
"expected signed integer constant");
}
Err(ref err) => {
- cx.sess
- .span_err(e.span,
- &format!("expected constant: {}",
- *err)[]);
+ span_err!(cx.sess, e.span, E0305,
+ "expected constant: {}",
+ *err);
}
},
None => {}
const_eval::const_binary(_) =>
"binary array"
};
- tcx.sess.span_err(count_expr.span, &format!(
+ span_err!(tcx.sess, count_expr.span, E0306,
"expected positive integer for repeat count, found {}",
- found)[]);
+ found);
}
Err(_) => {
let found = match count_expr.node {
_ =>
"non-constant expression"
};
- tcx.sess.span_err(count_expr.span, &format!(
+ span_err!(tcx.sess, count_expr.span, E0307,
"expected constant integer for repeat count, found {}",
- found)[]);
+ found);
}
}
0
self.items.missing.push(lang_items::$item);
}
} else)* {
- self.sess.span_err(span,
- format!("unknown external lang item: `{}`",
- name).as_slice());
+ span_err!(self.sess, span, E0264,
+ "unknown external lang item: `{}`",
+ name);
}
}
}