-
Notifications
You must be signed in to change notification settings - Fork 931
Closed
Labels
Milestone
Description
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
/// 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)
):
rustfmt/src/config/file_lines.rs
Lines 218 to 221 in 26d370e
/// 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 into_json_spans
(sincevec![]
returned forFileLines(None)
won't be parsed back into theFileLines(None)
but ratherFileLines(Some(HashMap::new))
- Somehow discern or accept
null
lines in--file-lines JSON
and maketo_json_spans()
returnOption<Vec<JsonSpan>>
Thoughts?
ljw1004