diff options
Diffstat (limited to 'cli/proc_state.rs')
-rw-r--r-- | cli/proc_state.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/cli/proc_state.rs b/cli/proc_state.rs index fe707754f..e45e7c539 100644 --- a/cli/proc_state.rs +++ b/cli/proc_state.rs @@ -622,8 +622,14 @@ impl SourceMapGetter for ProcState { // Do NOT use .lines(): it skips the terminating empty line. // (due to internally using .split_terminator() instead of .split()) let lines: Vec<&str> = out.source.split('\n').collect(); - assert!(lines.len() > line_number); - lines[line_number].to_string() + if line_number >= lines.len() { + format!( + "{} Couldn't format source line: Line {} is out of bounds (source may have changed at runtime)", + crate::colors::yellow("Warning"), line_number + 1, + ) + } else { + lines[line_number].to_string() + } }) } else { None |