Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3c86755

Browse files
committedJul 5, 2017
Auto merge of #43008 - zackmdavis:field_init_shorthand_in_librustc, r=<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,`)
2 parents 3610a70 + 83d5fbf commit 3c86755

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+374
-374
lines changed
 

‎src/librustc/cfg/construct.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@ pub fn construct<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
5858
let tables = tcx.typeck_tables_of(owner_def_id);
5959

6060
let mut cfg_builder = CFGBuilder {
61-
tcx: tcx,
61+
tcx,
6262
owner_def_id,
63-
tables: tables,
64-
graph: graph,
65-
fn_exit: fn_exit,
63+
tables,
64+
graph,
65+
fn_exit,
6666
loop_scopes: Vec::new(),
6767
breakable_block_scopes: Vec::new(),
6868
};
6969
body_exit = cfg_builder.expr(&body.value, entry);
7070
cfg_builder.add_contained_edge(body_exit, fn_exit);
7171
let CFGBuilder { graph, .. } = cfg_builder;
7272
CFG {
73-
graph: graph,
74-
entry: entry,
73+
graph,
74+
entry,
7575
exit: fn_exit,
7676
}
7777
}

‎src/librustc/dep_graph/dep_tracking_map.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl<M: DepTrackingMapConfig> DepTrackingMap<M> {
3636
pub fn new(graph: DepGraph) -> DepTrackingMap<M> {
3737
DepTrackingMap {
3838
phantom: PhantomData,
39-
graph: graph,
39+
graph,
4040
map: FxHashMap(),
4141
}
4242
}

0 commit comments

Comments
 (0)
Please sign in to comment.