-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
use field init shorthand in src/librustc/ #43008
use field init shorthand in src/librustc/ #43008
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
(haven't built this locally, it being convenient to just let our friend Travis decide if this actually works) |
src/librustc/dep_graph/query.rs
Outdated
@@ -36,7 +36,7 @@ impl DepGraphQuery { | |||
} | |||
|
|||
DepGraphQuery { | |||
graph: graph, | |||
graph, | |||
indices: indices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can also be shortened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, yes, regex should've probably been (\w+): \1,?\n
rather than (\w+): \1,
Is there a reason this is limited to just librustc? It seems appropriate to either run this everywhere or nowhere. |
It seemed less "dramatic", and less likely to collide with other PRs? Maybe that's not very compelling. |
I'm happy with starting with just librustc and then expanding to others. |
377425d
to
83d5fbf
Compare
(Travis passed on the initial submission; I've added a newline to the regex (to catch cases like the one Tim points out), reapplied (on master), and force-pushed.) |
Quick shell command to do the same thing as the Python version:
If you want to specify a directory, put it right after the |
@bors try |
…=<try> use field init shorthand in src/librustc/ Commentary on #37340 [suggested](#37340 (comment)) 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](#37340 (comment)), 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,`)
☀️ Test successful - status-travis |
@bors r+ |
📌 Commit 83d5fbf has been approved by |
For the record, try builds should not be used except to obtain artifacts for cargobomb -- they don't actually test much more than the standard PR builder (just dist, I think). |
@Mark-Simulacrum thanks for the clarification! Going forward, should I just r+ and let travis catch any issues then? |
@bors: retry |
1 similar comment
@bors: retry |
🔒 Merge conflict |
The field init shorthand syntax was stabilized in 1.17.0 (aebd94f); we are now free to use it in the compiler.
83d5fbf
to
f668999
Compare
I don't understand why Git seems to think master's deletion of the libcompiler_builtins directory is a merge conflict?
Anyway, rebased and force-pushed. |
@bors r+ |
📌 Commit f668999 has been approved by |
…=estebank use field init shorthand in src/librustc/ Commentary on #37340 [suggested](#37340 (comment)) 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](#37340 (comment)), 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,`)
☀️ Test successful - status-appveyor, status-travis |
Like rust-lang#43008 (f668999), but _much more aggressive_.
…Mark-Simulacrum use field init shorthand EVERYWHERE Like #43008 (f668999), but [(lacking reasons to be more timid)](#43008 (comment)) _much more aggressive_. r? @Mark-Simulacrum
…Mark-Simulacrum use field init shorthand EVERYWHERE Like #43008 (f668999), but [(lacking reasons to be more timid)](rust-lang/rust#43008 (comment)) _much more aggressive_. r? @Mark-Simulacrum
Commentary on #37340 suggested 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, in the meantime, some simple Python will do:Update 3 July: edited the search (respectively replace) regex to
(\w+): \1,?\n
(\1,\n
) from(\w+): \1,
(\1,
)