Skip to content

Commit 52b7fc1

Browse files
committed
auto merge of #7903 : michaelwoerister/rust/end_of_spanned, r=jdm
Continuation of #7826. AST spanned<T> refactoring, AST type renamings: `crate => Crate` `local => Local` `blk => Block` `crate_num => CrateNum` `crate_cfg => CrateConfig` `field => Field` Also, Crate, Field and Local are not wrapped in spanned<T> anymore.
2 parents 7a3eaf8 + 5aee3e0 commit 52b7fc1

Some content is hidden

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

84 files changed

+553
-564
lines changed

src/librustc/back/link.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ pub mod write {
488488
*/
489489

490490
pub fn build_link_meta(sess: Session,
491-
c: &ast::crate,
491+
c: &ast::Crate,
492492
output: &Path,
493493
symbol_hasher: &mut hash::State)
494494
-> LinkMeta {
@@ -498,12 +498,12 @@ pub fn build_link_meta(sess: Session,
498498
cmh_items: ~[@ast::MetaItem]
499499
}
500500

501-
fn provided_link_metas(sess: Session, c: &ast::crate) ->
501+
fn provided_link_metas(sess: Session, c: &ast::Crate) ->
502502
ProvidedMetas {
503503
let mut name = None;
504504
let mut vers = None;
505505
let mut cmh_items = ~[];
506-
let linkage_metas = attr::find_linkage_metas(c.node.attrs);
506+
let linkage_metas = attr::find_linkage_metas(c.attrs);
507507
attr::require_unique_names(sess.diagnostic(), linkage_metas);
508508
for linkage_metas.iter().advance |meta| {
509509
match meta.name_str_pair() {

src/librustc/driver/driver.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn source_name(input: &input) -> @str {
6464
}
6565
6666
pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
67-
ast::crate_cfg {
67+
ast::CrateConfig {
6868
let (libc, tos) = match sess.targ_cfg.os {
6969
session::os_win32 => (@"msvcrt.dll", @"win32"),
7070
session::os_macos => (@"libc.dylib", @"macos"),
@@ -96,14 +96,14 @@ pub fn default_configuration(sess: Session, argv0: @str, input: &input) ->
9696
mk(@"build_input", source_name(input))];
9797
}
9898

99-
pub fn append_configuration(cfg: &mut ast::crate_cfg, name: @str) {
99+
pub fn append_configuration(cfg: &mut ast::CrateConfig, name: @str) {
100100
if !cfg.iter().any(|mi| mi.name() == name) {
101101
cfg.push(attr::mk_word_item(name))
102102
}
103103
}
104104

105105
pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
106-
ast::crate_cfg {
106+
ast::CrateConfig {
107107
// Combine the configuration requested by the session (command line) with
108108
// some default and generated configuration items
109109
let default_cfg = default_configuration(sess, argv0, input);
@@ -117,11 +117,11 @@ pub fn build_configuration(sess: Session, argv0: @str, input: &input) ->
117117

118118
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
119119
fn parse_cfgspecs(cfgspecs: ~[~str],
120-
demitter: diagnostic::Emitter) -> ast::crate_cfg {
120+
demitter: diagnostic::Emitter) -> ast::CrateConfig {
121121
do cfgspecs.consume_iter().transform |s| {
122122
let sess = parse::new_parse_sess(Some(demitter));
123123
parse::parse_meta_from_source_str(@"cfgspec", s.to_managed(), ~[], sess)
124-
}.collect::<ast::crate_cfg>()
124+
}.collect::<ast::CrateConfig>()
125125
}
126126

127127
pub enum input {
@@ -132,8 +132,8 @@ pub enum input {
132132
str_input(@str)
133133
}
134134

135-
pub fn parse_input(sess: Session, cfg: ast::crate_cfg, input: &input)
136-
-> @ast::crate {
135+
pub fn parse_input(sess: Session, cfg: ast::CrateConfig, input: &input)
136+
-> @ast::Crate {
137137
match *input {
138138
file_input(ref file) => {
139139
parse::parse_crate_from_file(&(*file), cfg, sess.parse_sess)
@@ -167,11 +167,11 @@ pub enum compile_phase {
167167

168168
#[fixed_stack_segment]
169169
pub fn compile_rest(sess: Session,
170-
cfg: ast::crate_cfg,
170+
cfg: ast::CrateConfig,
171171
phases: compile_upto,
172172
outputs: Option<@OutputFilenames>,
173-
curr: Option<@ast::crate>)
174-
-> (Option<@ast::crate>, Option<ty::ctxt>) {
173+
curr: Option<@ast::Crate>)
174+
-> (Option<@ast::Crate>, Option<ty::ctxt>) {
175175

176176
let time_passes = sess.time_passes();
177177

@@ -372,11 +372,11 @@ pub fn compile_rest(sess: Session,
372372
}
373373

374374
pub fn compile_upto(sess: Session,
375-
cfg: ast::crate_cfg,
375+
cfg: ast::CrateConfig,
376376
input: &input,
377377
upto: compile_phase,
378378
outputs: Option<@OutputFilenames>)
379-
-> (Option<@ast::crate>, Option<ty::ctxt>) {
379+
-> (Option<@ast::Crate>, Option<ty::ctxt>) {
380380
let time_passes = sess.time_passes();
381381
let crate = time(time_passes,
382382
~"parsing",
@@ -395,7 +395,7 @@ pub fn compile_upto(sess: Session,
395395
Some(crate))
396396
}
397397

398-
pub fn compile_input(sess: Session, cfg: ast::crate_cfg, input: &input,
398+
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
399399
outdir: &Option<Path>, output: &Option<Path>) {
400400
let upto = if sess.opts.parse_only { cu_parse }
401401
else if sess.opts.no_trans { cu_no_trans }
@@ -404,7 +404,7 @@ pub fn compile_input(sess: Session, cfg: ast::crate_cfg, input: &input,
404404
compile_upto(sess, cfg, input, upto, Some(outputs));
405405
}
406406

407-
pub fn pretty_print_input(sess: Session, cfg: ast::crate_cfg, input: &input,
407+
pub fn pretty_print_input(sess: Session, cfg: ast::CrateConfig, input: &input,
408408
ppm: pp_mode) {
409409
fn ann_paren_for_expr(node: pprust::ann_node) {
410410
match node {

src/librustc/driver/session.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub struct options {
158158
// items to the crate config, and during parsing the entire crate config
159159
// will be added to the crate AST node. This should not be used for
160160
// anything except building the full crate config prior to parsing.
161-
cfg: ast::crate_cfg,
161+
cfg: ast::CrateConfig,
162162
binary: @str,
163163
test: bool,
164164
parse_only: bool,
@@ -357,7 +357,7 @@ pub fn expect<T:Clone>(sess: Session, opt: Option<T>, msg: &fn() -> ~str)
357357
}
358358

359359
pub fn building_library(req_crate_type: crate_type,
360-
crate: &ast::crate,
360+
crate: &ast::Crate,
361361
testing: bool) -> bool {
362362
match req_crate_type {
363363
bin_crate => false,
@@ -367,7 +367,7 @@ pub fn building_library(req_crate_type: crate_type,
367367
false
368368
} else {
369369
match syntax::attr::first_attr_value_str_by_name(
370-
crate.node.attrs,
370+
crate.attrs,
371371
"crate_type") {
372372
Some(s) => "lib" == s,
373373
_ => false
@@ -402,19 +402,20 @@ mod test {
402402
attr::mk_attr(attr::mk_name_value_item_str(@"crate_type", t))
403403
}
404404

405-
fn make_crate(with_bin: bool, with_lib: bool) -> @ast::crate {
405+
fn make_crate(with_bin: bool, with_lib: bool) -> @ast::Crate {
406406
let mut attrs = ~[];
407407
if with_bin {
408408
attrs.push(make_crate_type_attr(@"bin"));
409409
}
410410
if with_lib {
411411
attrs.push(make_crate_type_attr(@"lib"));
412412
}
413-
@codemap::respan(codemap::dummy_sp(), ast::crate_ {
413+
@ast::Crate {
414414
module: ast::_mod { view_items: ~[], items: ~[] },
415415
attrs: attrs,
416-
config: ~[]
417-
})
416+
config: ~[],
417+
span: codemap::dummy_sp(),
418+
}
418419
}
419420

420421
#[test]

src/librustc/front/config.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ struct Context {
2020

2121
// Support conditional compilation by transforming the AST, stripping out
2222
// any items that do not belong in the current configuration
23-
pub fn strip_unconfigured_items(crate: @ast::crate) -> @ast::crate {
23+
pub fn strip_unconfigured_items(crate: @ast::Crate) -> @ast::Crate {
2424
do strip_items(crate) |attrs| {
25-
in_cfg(crate.node.config, attrs)
25+
in_cfg(crate.config, attrs)
2626
}
2727
}
2828

29-
pub fn strip_items(crate: &ast::crate, in_cfg: in_cfg_pred)
30-
-> @ast::crate {
29+
pub fn strip_items(crate: &ast::Crate, in_cfg: in_cfg_pred)
30+
-> @ast::Crate {
3131

3232
let ctxt = @Context { in_cfg: in_cfg };
3333

@@ -131,16 +131,16 @@ fn filter_stmt(cx: @Context, stmt: @ast::stmt) ->
131131

132132
fn fold_block(
133133
cx: @Context,
134-
b: &ast::blk,
134+
b: &ast::Block,
135135
fld: @fold::ast_fold
136-
) -> ast::blk {
136+
) -> ast::Block {
137137
let resulting_stmts = do b.stmts.iter().filter_map |a| {
138138
filter_stmt(cx, *a).chain(|stmt| fld.fold_stmt(stmt))
139139
}.collect();
140140
let filtered_view_items = do b.view_items.iter().filter_map |a| {
141141
filter_view_item(cx, a).map(|&x| fld.fold_view_item(x))
142142
}.collect();
143-
ast::blk {
143+
ast::Block {
144144
view_items: filtered_view_items,
145145
stmts: resulting_stmts,
146146
expr: b.expr.map(|x| fld.fold_expr(*x)),

src/librustc/front/std_inject.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,29 +20,30 @@ use syntax::fold;
2020

2121
static STD_VERSION: &'static str = "0.8-pre";
2222

23-
pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::crate)
24-
-> @ast::crate {
23+
pub fn maybe_inject_libstd_ref(sess: Session, crate: @ast::Crate)
24+
-> @ast::Crate {
2525
if use_std(crate) {
2626
inject_libstd_ref(sess, crate)
2727
} else {
2828
crate
2929
}
3030
}
3131

32-
fn use_std(crate: &ast::crate) -> bool {
33-
!attr::contains_name(crate.node.attrs, "no_std")
32+
fn use_std(crate: &ast::Crate) -> bool {
33+
!attr::contains_name(crate.attrs, "no_std")
3434
}
35+
3536
fn no_prelude(attrs: &[ast::Attribute]) -> bool {
3637
attr::contains_name(attrs, "no_implicit_prelude")
3738
}
3839

39-
fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
40+
fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate {
4041
fn spanned<T>(x: T) -> codemap::spanned<T> {
4142
codemap::spanned { node: x, span: dummy_sp() }
4243
}
4344

4445
let precursor = @fold::AstFoldFns {
45-
fold_crate: |crate, span, fld| {
46+
fold_crate: |crate, fld| {
4647
let n1 = sess.next_node_id();
4748
let vi1 = ast::view_item {
4849
node: ast::view_item_extern_mod(
@@ -68,11 +69,10 @@ fn inject_libstd_ref(sess: Session, crate: &ast::crate) -> @ast::crate {
6869
}
6970

7071
// FIXME #2543: Bad copy.
71-
let new_crate = ast::crate_ {
72+
ast::Crate {
7273
module: new_module,
7374
..(*crate).clone()
74-
};
75-
(new_crate, span)
75+
}
7676
},
7777
fold_item: |item, fld| {
7878
if !no_prelude(item.attrs) {

src/librustc/front/test.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ struct Test {
3737

3838
struct TestCtxt {
3939
sess: session::Session,
40-
crate: @ast::crate,
40+
crate: @ast::Crate,
4141
path: ~[ast::ident],
4242
ext_cx: @ExtCtxt,
4343
testfns: ~[Test]
@@ -46,12 +46,12 @@ struct TestCtxt {
4646
// Traverse the crate, collecting all the test functions, eliding any
4747
// existing main functions, and synthesizing a main test harness
4848
pub fn modify_for_testing(sess: session::Session,
49-
crate: @ast::crate)
50-
-> @ast::crate {
49+
crate: @ast::Crate)
50+
-> @ast::Crate {
5151
// We generate the test harness when building in the 'test'
5252
// configuration, either with the '--test' or '--cfg test'
5353
// command line options.
54-
let should_test = attr::contains_name(crate.node.config, "test");
54+
let should_test = attr::contains_name(crate.config, "test");
5555

5656
if should_test {
5757
generate_test_harness(sess, crate)
@@ -61,8 +61,8 @@ pub fn modify_for_testing(sess: session::Session,
6161
}
6262

6363
fn generate_test_harness(sess: session::Session,
64-
crate: @ast::crate)
65-
-> @ast::crate {
64+
crate: @ast::Crate)
65+
-> @ast::Crate {
6666
let cx: @mut TestCtxt = @mut TestCtxt {
6767
sess: sess,
6868
crate: crate,
@@ -81,7 +81,7 @@ fn generate_test_harness(sess: session::Session,
8181
});
8282

8383
let precursor = @fold::AstFoldFns {
84-
fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),
84+
fold_crate: |a,b| fold_crate(cx, a, b),
8585
fold_item: |a,b| fold_item(cx, a, b),
8686
fold_mod: |a,b| fold_mod(cx, a, b),.. *fold::default_ast_fold()};
8787

@@ -91,7 +91,7 @@ fn generate_test_harness(sess: session::Session,
9191
return res;
9292
}
9393

94-
fn strip_test_functions(crate: &ast::crate) -> @ast::crate {
94+
fn strip_test_functions(crate: &ast::Crate) -> @ast::Crate {
9595
// When not compiling with --test we should not compile the
9696
// #[test] functions
9797
do config::strip_items(crate) |attrs| {
@@ -132,13 +132,13 @@ fn fold_mod(cx: @mut TestCtxt,
132132
fold::noop_fold_mod(&mod_nomain, fld)
133133
}
134134

135-
fn fold_crate(cx: @mut TestCtxt, c: &ast::crate_, fld: @fold::ast_fold)
136-
-> ast::crate_ {
135+
fn fold_crate(cx: @mut TestCtxt, c: &ast::Crate, fld: @fold::ast_fold)
136+
-> ast::Crate {
137137
let folded = fold::noop_fold_crate(c, fld);
138138

139139
// Add a special __test module to the crate that will contain code
140140
// generated for the test harness
141-
ast::crate_ {
141+
ast::Crate {
142142
module: add_test_module(cx, &folded.module),
143143
.. folded
144144
}
@@ -236,7 +236,7 @@ fn is_ignored(cx: @mut TestCtxt, i: @ast::item) -> bool {
236236
do i.attrs.iter().any |attr| {
237237
// check ignore(cfg(foo, bar))
238238
"ignore" == attr.name() && match attr.meta_item_list() {
239-
Some(ref cfgs) => attr::test_cfg(cx.crate.node.config, cfgs.iter().transform(|x| *x)),
239+
Some(ref cfgs) => attr::test_cfg(cx.crate.config, cfgs.iter().transform(|x| *x)),
240240
None => true
241241
}
242242
}
@@ -370,7 +370,7 @@ fn mk_tests(cx: &TestCtxt) -> @ast::item {
370370
}
371371

372372
fn is_extra(cx: &TestCtxt) -> bool {
373-
let items = attr::find_linkage_metas(cx.crate.node.attrs);
373+
let items = attr::find_linkage_metas(cx.crate.attrs);
374374
match attr::last_meta_item_value_str_by_name(items, "name") {
375375
Some(s) if "extra" == s => true,
376376
_ => false

src/librustc/metadata/creader.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use syntax::ast;
2929
// Traverses an AST, reading all the information about use'd crates and extern
3030
// libraries necessary for later resolving, typechecking, linking, etc.
3131
pub fn read_crates(diag: @span_handler,
32-
crate: &ast::crate,
32+
crate: &ast::Crate,
3333
cstore: @mut cstore::CStore,
3434
filesearch: @FileSearch,
3535
os: loader::os,
@@ -118,14 +118,14 @@ struct Env {
118118
os: loader::os,
119119
statik: bool,
120120
crate_cache: @mut ~[cache_entry],
121-
next_crate_num: ast::crate_num,
121+
next_crate_num: ast::CrateNum,
122122
intr: @ident_interner
123123
}
124124

125-
fn visit_crate(e: &Env, c: &ast::crate) {
125+
fn visit_crate(e: &Env, c: &ast::Crate) {
126126
let cstore = e.cstore;
127127

128-
for c.node.attrs.iter().filter(|m| "link_args" == m.name()).advance |a| {
128+
for c.attrs.iter().filter(|m| "link_args" == m.name()).advance |a| {
129129
match a.value_str() {
130130
Some(ref linkarg) => {
131131
cstore::add_used_link_args(cstore, *linkarg);
@@ -237,7 +237,7 @@ fn resolve_crate(e: @mut Env,
237237
metas: ~[@ast::MetaItem],
238238
hash: @str,
239239
span: span)
240-
-> ast::crate_num {
240+
-> ast::CrateNum {
241241
let metas = metas_with_ident(token::ident_to_str(&ident), metas);
242242

243243
match existing_match(e, metas, hash) {

0 commit comments

Comments
 (0)