diff options
author | Nadrieril Feneanar | 2020-02-04 18:55:37 +0000 |
---|---|---|
committer | GitHub | 2020-02-04 18:55:37 +0000 |
commit | eb9129312edf574948df777acb340189dc147724 (patch) | |
tree | b3297ae9f8a46f976274159aa7f4c8ee8662b6f1 /dhall/src/syntax | |
parent | 488bce275f104384282a0867aeaad011ae8cf48c (diff) | |
parent | f3bdd5ab32e112483da4c81d64ec14a116bf06cf (diff) |
Merge pull request #128 from Nadrieril/nice-errors-everywhere
Add basic pretty type errors to all errors
Diffstat (limited to '')
-rw-r--r-- | dhall/src/syntax/ast/span.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/dhall/src/syntax/ast/span.rs b/dhall/src/syntax/ast/span.rs index ffdd82c..fba6a2d 100644 --- a/dhall/src/syntax/ast/span.rs +++ b/dhall/src/syntax/ast/span.rs @@ -100,8 +100,10 @@ fn char_idx_from_byte_idx(input: &str, idx: usize) -> usize { .char_indices() .enumerate() .find(|(_, (i, _))| *i == idx) - .unwrap() - .0; + .map(|(i, (_, _))| i) + // We should be able to unwrap() here, but somehow it panics on an example from + // serde_dhall/lib.rs... + .unwrap_or(0); // Unix-style newlines are counted as two chars (see // https://github.com/rust-lang/annotate-snippets-rs/issues/24). let nbr_newlines = input[..idx].chars().filter(|c| *c == '\n').count(); |