This surfaced at rust-lang/rls#1463 (fixed in rust-lang/rls#1497).
The underlying data structure discerns a missing/"all" state in addition to actual set (possibly empty) of lines:
|
/// A set of lines in files. |
|
/// |
|
/// It is represented as a multimap keyed on file names, with values a collection of |
|
/// non-overlapping ranges sorted by their start point. An inner `None` is interpreted to mean all |
|
/// lines in all files. |
|
#[derive(Clone, Debug, Default, PartialEq)] |
|
pub struct FileLines(Option<HashMap<FileName, Vec<Range>>>); |
whereas to_json_span only encodes a specified set of those changes (can't represent FileLines(None)):
|
/// Returns JSON representation as accepted by the `--file-lines JSON` arg. |
|
pub fn to_json_spans(&self) -> Vec<JsonSpan> { |
|
match &self.0 { |
|
None => vec![], |
I think we should either:
- panic/return err on
None match in to_json_spans (since vec![] returned for FileLines(None) won't be parsed back into the FileLines(None) but rather FileLines(Some(HashMap::new))
- Somehow discern or accept
null lines in --file-lines JSON and make to_json_spans() return Option<Vec<JsonSpan>>
Thoughts?
cc @jsgf @ljw1004
This surfaced at rust-lang/rls#1463 (fixed in rust-lang/rls#1497).
The underlying data structure discerns a missing/"all" state in addition to actual set (possibly empty) of lines:
rustfmt/src/config/file_lines.rs
Lines 151 to 157 in 26d370e
whereas
to_json_spanonly encodes a specified set of those changes (can't representFileLines(None)):rustfmt/src/config/file_lines.rs
Lines 218 to 221 in 26d370e
I think we should either:
Nonematch into_json_spans(sincevec![]returned forFileLines(None)won't be parsed back into theFileLines(None)but ratherFileLines(Some(HashMap::new))nulllines in--file-lines JSONand maketo_json_spans()returnOption<Vec<JsonSpan>>Thoughts?
cc @jsgf @ljw1004