diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-07-30 01:43:52 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-07-30 01:43:52 +0530 |
| commit | 56bb9ed8054c4774c52c8799c78787154ac4cd84 (patch) | |
| tree | 760fda16dc7bd8344ada7728beec689e82669ea2 | |
| parent | 523ee8d37cb3aed6bbad16760850fa94253c2072 (diff) | |
| parent | a067b4588aabfab1de57829cdfe5d660733a158d (diff) | |
| download | rust-56bb9ed8054c4774c52c8799c78787154ac4cd84.tar.gz rust-56bb9ed8054c4774c52c8799c78787154ac4cd84.zip | |
Rollup merge of #26778 - jawline:master, r=pnkfelix
Print the error message and then what is expected by the repeat count so the output makes more sense when there is an error in the const expression
| -rw-r--r-- | src/librustc/middle/ty.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index a3b67941741..88fc6181f92 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -44,7 +44,7 @@ use metadata::csearch; use middle; use middle::cast; use middle::check_const; -use middle::const_eval::{self, ConstVal}; +use middle::const_eval::{self, ConstVal, ErrKind}; use middle::const_eval::EvalHint::UncheckedExprHint; use middle::def::{self, DefMap, ExportMap}; use middle::dependency_format; @@ -6107,20 +6107,20 @@ impl<'tcx> ctxt<'tcx> { found); } Err(err) => { - let err_description = err.description(); - let found = match count_expr.node { + let err_msg = match count_expr.node { ast::ExprPath(None, ast::Path { global: false, ref segments, .. }) if segments.len() == 1 => - format!("{}", "found variable"), - _ => - format!("but {}", err_description), + format!("found variable"), + _ => match err.kind { + ErrKind::MiscCatchAll => format!("but found {}", err.description()), + _ => format!("but {}", err.description()) + } }; span_err!(self.sess, count_expr.span, E0307, - "expected constant integer for repeat count, {}", - found); + "expected constant integer for repeat count, {}", err_msg); } } 0 |
