mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-03 02:23:20 +00:00
Add error codes to rustc
This commit is contained in:
parent
cf629e7cfa
commit
9f59f7e052
@ -53,7 +53,52 @@ register_diagnostics! {
|
||||
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 }
|
||||
|
@ -73,12 +73,12 @@ impl<'a> CheckLoopVisitor<'a> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,11 +226,10 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
|
||||
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.
|
||||
@ -869,7 +868,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -882,7 +881,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||
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
|
||||
}
|
||||
}
|
||||
@ -921,7 +920,7 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
|
||||
}
|
||||
|
||||
ast::PatMac(_) => {
|
||||
cx.tcx.sess.span_err(pat_span, "unexpanded macro");
|
||||
span_err!(cx.tcx.sess, pat_span, E0300, "unexpanded macro");
|
||||
None
|
||||
}
|
||||
};
|
||||
@ -1082,11 +1081,8 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
||||
_: 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 => {}
|
||||
}
|
||||
@ -1095,10 +1091,7 @@ impl<'a, 'tcx> Delegate<'tcx> for MutationChecker<'a, 'tcx> {
|
||||
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 => {}
|
||||
}
|
||||
@ -1120,7 +1113,7 @@ struct AtBindingPatternVisitor<'a, 'b:'a, 'tcx:'b> {
|
||||
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 `@`");
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ pub fn check_item_recursion<'a>(sess: &'a Session,
|
||||
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);
|
||||
@ -103,9 +103,9 @@ impl<'a, 'ast, 'v> Visitor<'v> for CheckItemRecursionVisitor<'a, 'ast> {
|
||||
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;
|
||||
},
|
||||
}
|
||||
|
@ -371,12 +371,11 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
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) =>
|
||||
@ -443,9 +442,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
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!(
|
||||
@ -456,9 +454,8 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
||||
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!(
|
||||
@ -468,11 +465,9 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
|
||||
_ => {
|
||||
// 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!(
|
||||
@ -499,8 +494,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
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(
|
||||
@ -515,14 +509,13 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
"");
|
||||
}
|
||||
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 ",
|
||||
@ -539,8 +532,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
"");
|
||||
}
|
||||
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,
|
||||
@ -554,8 +546,7 @@ impl<'a, 'tcx> ErrorReporting<'tcx> for InferCtxt<'a, '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,
|
||||
|
@ -1557,8 +1557,7 @@ impl<'a, 'tcx> Liveness<'a, '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(),
|
||||
@ -1575,7 +1574,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ pub fn update_recursion_limit(sess: &Session, krate: &ast::Crate) {
|
||||
}
|
||||
}
|
||||
|
||||
sess.span_err(attr.span, "malformed recursion limit attribute, \
|
||||
span_err!(sess, attr.span, E0296, "malformed recursion limit attribute, \
|
||||
expected #![recursion_limit=\"N\"]");
|
||||
}
|
||||
}
|
||||
|
@ -396,10 +396,9 @@ impl<'a> LifetimeContext<'a> {
|
||||
}
|
||||
|
||||
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>) {
|
||||
@ -409,11 +408,9 @@ impl<'a> LifetimeContext<'a> {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
@ -422,12 +419,10 @@ impl<'a> LifetimeContext<'a> {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,12 +55,10 @@ pub fn report_projection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -97,28 +95,25 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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
|
||||
}
|
||||
@ -130,11 +125,11 @@ fn report_on_unimplemented<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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;
|
||||
}
|
||||
@ -151,11 +146,9 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
// 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);
|
||||
|
||||
@ -165,12 +158,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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 {
|
||||
@ -180,12 +171,10 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
|
||||
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,
|
||||
@ -201,34 +190,28 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,15 +222,13 @@ pub fn report_selection_error<'a, 'tcx>(infcx: &InferCtxt<'a, '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);
|
||||
}
|
||||
}
|
||||
@ -293,18 +274,14 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -323,11 +300,9 @@ pub fn maybe_report_ambiguity<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
|
||||
|
||||
_ => {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -379,11 +379,10 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
|
||||
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
|
||||
}
|
||||
|
@ -5369,15 +5369,13 @@ pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
|
||||
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 => {}
|
||||
@ -5851,9 +5849,9 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
|
||||
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 {
|
||||
@ -5866,9 +5864,9 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
|
||||
_ =>
|
||||
"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
|
||||
|
@ -99,9 +99,9 @@ impl<'a> Context<'a> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user