diff options
| author | bors <bors@rust-lang.org> | 2017-07-06 07:49:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-07-06 07:49:44 +0000 |
| commit | afb853a3d742ada964ea06cccd422b08ea250cd3 (patch) | |
| tree | 9eca5fee8b6c60c730e1f542dff755e3a276faeb /src/rustllvm/RustWrapper.cpp | |
| parent | 7f1c4beb68d1834e86d4e1d087fd4b9757bb3675 (diff) | |
| parent | f668999153d78903658b6937a099819e0b634a06 (diff) | |
| download | rust-afb853a3d742ada964ea06cccd422b08ea250cd3.tar.gz rust-afb853a3d742ada964ea06cccd422b08ea250cd3.zip | |
Auto merge of #43008 - zackmdavis:field_init_shorthand_in_librustc, r=estebank
use field init shorthand in src/librustc/
Commentary on #37340 [suggested](https://github.com/rust-lang/rust/issues/37340#issuecomment-255513390) using the new field init syntax in the compiler. Do we care about this? If so, here's a pull request for the librustc/ directory. While [`rustfmt` might do this in the future](https://github.com/rust-lang/rust/issues/37340#issuecomment-255513712), in the meantime, some simple Python will do:
```python
#!/usr/bin/env python3
import os, re, sys
OPPORTUNITY = re.compile(r" (\w+): \1,?\n")
def field_init_shorthand_substitution(filename):
with open(filename) as f:
text = f.read()
revised = OPPORTUNITY.sub(r" \1,\n", text)
with open(filename, 'w') as f:
f.write(revised)
def substitute_in_directory(path):
for dirname, _subdirs, basenames in os.walk(path):
for basename in basenames:
field_init_shorthand_substitution(os.path.join(dirname, basename))
if __name__ == "__main__":
substitute_in_directory(sys.argv[1])
```
**Update 3 July**: edited the search (respectively replace) regex to ` (\w+): \1,?\n` (` \1,\n`) from ` (\w+): \1,` (` \1,`)
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
