Skip to content

Commit

Permalink
Continue to use struct_span_err! macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Oct 3, 2016
1 parent 9f7cc5f commit 71f9e2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
16 changes: 11 additions & 5 deletions src/librustc/infer/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,17 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
terr: &TypeError<'tcx>)
-> DiagnosticBuilder<'tcx>
{
let mut diag = self.tcx.sess.struct_span_err_with_code(
trace.origin.span(),
trace.origin.as_failure_str(),
trace.origin.as_error_code()
);
let span = trace.origin.span();
let failure_str = trace.origin.as_failure_str();
let mut diag = match trace.origin {
// FIXME: use distinct codes for each case
TypeOrigin::IfExpressionWithNoElse(_) => {
struct_span_err!(self.tcx.sess, span, E0317, "{}", failure_str)
},
_ => {
struct_span_err!(self.tcx.sess, span, E0308, "{}", failure_str)
},
};
self.note_type_err(&mut diag, trace.origin, None, Some(trace.values), terr);
diag
}
Expand Down
19 changes: 0 additions & 19 deletions src/librustc/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,25 +219,6 @@ pub enum TypeOrigin {
}

impl TypeOrigin {
fn as_error_code(&self) -> &'static str {
match self {
// FIXME: use distinct codes for each case
&TypeOrigin::Misc(_) => "E0308",
&TypeOrigin::RelateOutputImplTypes(_) => "E0308",
&TypeOrigin::ExprAssignable(_) => "E0308",
&TypeOrigin::MethodCompatCheck(_) => "E0308",
&TypeOrigin::MatchExpressionArm(..) => "E0308",
&TypeOrigin::IfExpression(_) => "E0308",
&TypeOrigin::IfExpressionWithNoElse(_) => "E0317",
&TypeOrigin::RangeExpression(_) => "E0308",
&TypeOrigin::EquatePredicate(_) => "E0308",
&TypeOrigin::MainFunctionType(_) => "E0308",
&TypeOrigin::StartFunctionType(_) => "E0308",
&TypeOrigin::IntrinsicType(_) => "E0308",
&TypeOrigin::MethodReceiver(_) => "E0308",
}
}

fn as_failure_str(&self) -> &'static str {
match self {
&TypeOrigin::Misc(_) |
Expand Down

0 comments on commit 71f9e2e

Please sign in to comment.