Skip to content

Commit e897130

Browse files
hovinenbcopybara-github
authored andcommitted
Add the configuration for rustfmt which has been used thus far to the package.
This ensures that contributors can run the autoformatter and get results which are compatible with the existing code. Otherwise, the autoformatter will run with its default configuration, heavily modifying existing formatting and obscuring the real changes. Unfortunately, the current configuration depends on features which are available only in nightly. This fact has been noted both in rustfmt.toml and CONTRIBUTING.md. See also https://rust-lang.github.io/rustfmt/?version=v1.5.1&search= PiperOrigin-RevId: 517365782
1 parent 2ba375e commit e897130

File tree

2 files changed

+41
-0
lines changed

2 files changed

+41
-0
lines changed

CONTRIBUTING.md

+12
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,15 @@ information on using pull requests.
2626

2727
This project follows [Google's Open Source Community
2828
Guidelines](https://opensource.google/conduct/).
29+
30+
## Running the autoformatter rustfmt
31+
32+
This repository uses a custom configuration for rustfmt which currently requires
33+
that one run the *nightly* version:
34+
35+
```
36+
cargo +nightly fmt
37+
```
38+
39+
The stable version will generate error messages and modify a lot of the
40+
existing formatting, obscuring any real changes you are making.

rustfmt.toml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2023 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
edition = "2021"
16+
17+
# Because of this, one must use the *nightly* version of rustfmt, e.g.
18+
# cargo +nightly fmt
19+
version = "Two"
20+
21+
use_small_heuristics = "Max"
22+
23+
newline_style = "Unix"
24+
25+
# This is required to keep the autoformatter from clobbering the markdown table
26+
# in the crate-level documentation in googletest/src/lib.rs.
27+
wrap_comments = false
28+
29+
format_generated_files = false

0 commit comments

Comments
 (0)