Continue to use struct_span_err! macro
This commit is contained in:
parent
9f7cc5faa0
commit
71f9e2e4d2
2 changed files with 11 additions and 24 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(_) |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue