Avoid unsafe unwrap of line_numbers, gracefully handle non-existing matches
Fixes #1044.
This commit is contained in:
parent
93d0191489
commit
2b7ca0e4a1
|
@ -9,6 +9,7 @@
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- **aiken**: Rename `--filter_traces` to `--trace_filter` for more consistency with `--trace_level`. An alias for `--filter_traces` still exists for backward compatibility. @KtorZ
|
- **aiken**: Rename `--filter_traces` to `--trace_filter` for more consistency with `--trace_level`. An alias for `--filter_traces` still exists for backward compatibility. @KtorZ
|
||||||
|
- **aiken-project**: Fix `aiken docs` source linking crashing when generating docs for config modules. See [#1044](https://github.com/aiken-lang/aiken/issues/1044). @KtorZ
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -60,9 +60,16 @@ impl SourceLinker {
|
||||||
pub fn url(&self, span: Span) -> String {
|
pub fn url(&self, span: Span) -> String {
|
||||||
match &self.url_pattern {
|
match &self.url_pattern {
|
||||||
Some((base, line_sep)) => {
|
Some((base, line_sep)) => {
|
||||||
let start_line = self.line_numbers.line_number(span.start).unwrap();
|
match (
|
||||||
let end_line = self.line_numbers.line_number(span.end).unwrap();
|
self.line_numbers.line_number(span.start),
|
||||||
format!("{base}{start_line}{line_sep}{end_line}")
|
self.line_numbers.line_number(span.end),
|
||||||
|
) {
|
||||||
|
(Some(start_line), Some(end_line)) => {
|
||||||
|
format!("{base}{start_line}{line_sep}{end_line}")
|
||||||
|
}
|
||||||
|
(Some(start_line), None) => format!("{base}{start_line}"),
|
||||||
|
_ => base.to_string(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
None => "".into(),
|
None => "".into(),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue