summaryrefslogtreecommitdiff
path: root/cli/fmt_errors.rs
diff options
context:
space:
mode:
authorKevin (Kun) "Kassimo" Qian <kevinkassimo@gmail.com>2020-03-24 20:53:48 -0700
committerGitHub <noreply@github.com>2020-03-24 23:53:48 -0400
commit3d228f5f9ec729d1b027588ccf36987c82f53516 (patch)
treedf7bc53204d8eef5df25875bb0eeb3b8d9182e3a /cli/fmt_errors.rs
parentaddfdc4cd0ffa0e0f6b284379c8873a202af7d5b (diff)
hide source line if error message longer than 150 chars (#4487)
Diffstat (limited to 'cli/fmt_errors.rs')
-rw-r--r--cli/fmt_errors.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/cli/fmt_errors.rs b/cli/fmt_errors.rs
index 73d6bb2d2..0a22b4625 100644
--- a/cli/fmt_errors.rs
+++ b/cli/fmt_errors.rs
@@ -10,6 +10,8 @@ use std::error::Error;
use std::fmt;
use std::ops::Deref;
+const SOURCE_ABBREV_THRESHOLD: usize = 150;
+
/// A trait which specifies parts of a diagnostic like item needs to be able to
/// generate to conform its display to other diagnostic like items
pub trait DisplayFormatter {
@@ -74,8 +76,9 @@ pub fn format_maybe_source_line(
let source_line = source_line.as_ref().unwrap();
// sometimes source_line gets set with an empty string, which then outputs
- // an empty source line when displayed, so need just short circuit here
- if source_line.is_empty() {
+ // an empty source line when displayed, so need just short circuit here.
+ // Also short-circuit on error line too long.
+ if source_line.is_empty() || source_line.len() > SOURCE_ABBREV_THRESHOLD {
return "".to_string();
}