Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange line breaks in method chains with 0.9 #1691

Closed
sfackler opened this issue Jun 15, 2017 · 2 comments
Closed

Strange line breaks in method chains with 0.9 #1691

sfackler opened this issue Jun 15, 2017 · 2 comments

Comments

@sfackler
Copy link
Member

Here are a couple of diffs we found when upgrading from rustfmt 0.8 to 0.9:

-        let inserted = self.map
-            .entry(key)
-            .or_insert_with(HashSet::new)
-            .insert(value);
+        let inserted = self.map.entry(key).or_insert_with(HashSet::new).insert(
+            value,
+        );
-        self.cache
-            .open(id, kind.storage_size())
-            .map(|o| o.map(|s| RawTimeSeries::new(kind, s)))
+        self.cache.open(id, kind.storage_size()).map(|o| {
+            o.map(|s| RawTimeSeries::new(kind, s))
+        })
-        self.series
-            .into_points((range.start().cloned(), range.end().cloned()))
+        self.series.into_points(
+            (range.start().cloned(), range.end().cloned()),
+        )

The old structure of breaking on each portion of the chain seems more readable than breaking as late as possible - in particular for the second example.

@nrc
Copy link
Member

nrc commented Jun 15, 2017

This is discussed in rust-lang/style-team#66 and I think the implementation matches the result of that discussion. There is an option for the maximum length of a chain that we will put on one line and we might want to make that shorter, or possibly we need to ensure that it applies to the chain prefix when only the last item is multi-lined. (I agree that the first two examples looked better before and we should try and preserve that. The third example I'm not sure about).

@sfackler
Copy link
Member Author

I don't feel particularly strongly about the last example either, yeah.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants