Skip to content

Commit a05bbb2

Browse files
committed
Merge pull request #4720 from jbclements/syntactic-cleanup
Syntactic cleanup
2 parents 959e382 + a283924 commit a05bbb2

Some content is hidden

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

57 files changed

+471
-308
lines changed

doc/rust.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,9 @@ mod quux {
851851

852852
In this example, the module `quux` re-exports all of the public names defined in `foo`.
853853

854+
Also note that the paths contained in `use` items are relative to the crate root; so, in the previous
855+
example, the use refers to `quux::foo::*`, and not simply to `foo::*`.
856+
854857
### Functions
855858

856859
A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters.

src/libcargo/cargo.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
286286
let mut uuid = None;
287287
for mis.each |a| {
288288
match a.node {
289-
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(s),
289+
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(s),
290290
_ }) => {
291291
match v {
292292
~"name" => name = Some(*s),
@@ -314,7 +314,7 @@ pub fn load_crate(filename: &Path) -> Option<Crate> {
314314

315315
for c.node.attrs.each |a| {
316316
match a.node.value.node {
317-
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(_),
317+
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(_),
318318
_ }) => {
319319
match v {
320320
~"desc" => desc = Some(v),

src/libfuzzer/fuzzer.rc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ pub fn common_exprs() -> ~[ast::expr] {
7474
id: 0,
7575
callee_id: -1,
7676
node: e,
77-
span: ast_util::dummy_sp(),
77+
span: codemap::dummy_sp(),
7878
}
7979
}
8080

8181
fn dsl(l: ast::lit_) -> ast::lit {
82-
ast::spanned { node: l, span: ast_util::dummy_sp() }
82+
codemap::spanned { node: l, span: codemap::dummy_sp() }
8383
}
8484

8585
~[dse(ast::expr_break(option::None)),

src/librustc/driver/session.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,15 @@ pub mod test {
344344

345345
use syntax::ast;
346346
use syntax::ast_util;
347+
use syntax::codemap;
347348

348349
pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {
349-
ast_util::respan(ast_util::dummy_sp(), ast::attribute_ {
350+
codemap::respan(codemap::dummy_sp(), ast::attribute_ {
350351
style: ast::attr_outer,
351-
value: ast_util::respan(ast_util::dummy_sp(),
352+
value: codemap::respan(codemap::dummy_sp(),
352353
ast::meta_name_value(
353354
~"crate_type",
354-
ast_util::respan(ast_util::dummy_sp(),
355+
codemap::respan(codemap::dummy_sp(),
355356
ast::lit_str(@t)))),
356357
is_sugared_doc: false
357358
})
@@ -361,7 +362,7 @@ pub mod test {
361362
let mut attrs = ~[];
362363
if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; }
363364
if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; }
364-
@ast_util::respan(ast_util::dummy_sp(), ast::crate_ {
365+
@codemap::respan(codemap::dummy_sp(), ast::crate_ {
365366
module: ast::_mod { view_items: ~[], items: ~[] },
366367
attrs: attrs,
367368
config: ~[]

src/librustc/front/core_inject.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use syntax::ast;
1717
use syntax::ast_util::*;
1818
use syntax::attr;
1919
use syntax::codemap;
20+
use syntax::codemap::dummy_sp;
2021
use syntax::fold;
2122

2223
const CORE_VERSION: &static/str = "0.6";
@@ -36,8 +37,8 @@ fn use_core(crate: @ast::crate) -> bool {
3637

3738
fn inject_libcore_ref(sess: Session,
3839
crate: @ast::crate) -> @ast::crate {
39-
fn spanned<T: Copy>(x: T) -> ast::spanned<T> {
40-
ast::spanned { node: x, span: dummy_sp() }
40+
fn spanned<T: Copy>(x: T) -> codemap::spanned<T> {
41+
codemap::spanned { node: x, span: dummy_sp() }
4142
}
4243

4344
let precursor = @fold::AstFoldFns {

src/librustc/front/intrinsic_inject.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use core::prelude::*;
1313
use driver::session::Session;
1414
use syntax::parse;
1515
use syntax::ast;
16+
use syntax::codemap::spanned;
1617

1718
use core::vec;
1819

@@ -34,7 +35,7 @@ pub fn inject_intrinsic(sess: Session, crate: @ast::crate) -> @ast::crate {
3435

3536
let items = vec::append(~[item], crate.node.module.items);
3637

37-
@ast::spanned {
38+
@spanned {
3839
node: ast::crate_ {
3940
module: ast::_mod {
4041
items: items,

src/librustc/front/test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ use core::option;
2121
use core::vec;
2222
use syntax::ast_util::*;
2323
use syntax::attr;
24-
use syntax::codemap::span;
24+
use syntax::codemap::{dummy_sp, span};
25+
use syntax::codemap;
2526
use syntax::fold;
2627
use syntax::print::pprust;
2728
use syntax::{ast, ast_util};
@@ -237,8 +238,8 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
237238
return @item;
238239
}
239240

240-
fn nospan<T: Copy>(t: T) -> ast::spanned<T> {
241-
ast::spanned { node: t, span: dummy_sp() }
241+
fn nospan<T: Copy>(t: T) -> codemap::spanned<T> {
242+
codemap::spanned { node: t, span: dummy_sp() }
242243
}
243244

244245
fn path_node(+ids: ~[ast::ident]) -> @ast::path {
@@ -535,7 +536,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
535536
let body_: ast::blk_ =
536537
default_block(~[], option::Some(test_main_call_expr),
537538
cx.sess.next_node_id());
538-
let body = ast::spanned { node: body_, span: dummy_sp() };
539+
let body = codemap::spanned { node: body_, span: dummy_sp() };
539540

540541
let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body);
541542
let item = ast::item {

src/librustc/metadata/creader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use core::either;
2424
use core::option;
2525
use core::vec;
2626
use syntax::attr;
27-
use syntax::codemap::span;
27+
use syntax::codemap::{span, dummy_sp};
2828
use syntax::diagnostic::span_handler;
2929
use syntax::parse::token::ident_interner;
3030
use syntax::print::pprust;
@@ -294,7 +294,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map {
294294
// This is a new one so we've got to load it
295295
// FIXME (#2404): Need better error reporting than just a bogus
296296
// span.
297-
let fake_span = ast_util::dummy_sp();
297+
let fake_span = dummy_sp();
298298
let local_cnum = resolve_crate(e, cname, cmetas,
299299
/*bad*/copy dep.hash, fake_span);
300300
cnum_map.insert(extrn_cnum, local_cnum);

src/librustc/metadata/csearch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::ebml;
2626
use std::map::HashMap;
2727
use syntax::ast;
2828
use syntax::ast_map;
29-
use syntax::ast_util::dummy_sp;
29+
use syntax::codemap::dummy_sp;
3030
use syntax::ast_util;
3131
use syntax::diagnostic::expect;
3232
use syntax::diagnostic::span_handler;

src/librustc/metadata/decoder.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ use syntax::diagnostic::span_handler;
4545
use syntax::parse::token::ident_interner;
4646
use syntax::print::pprust;
4747
use syntax::{ast, ast_util};
48+
use syntax::codemap;
4849

4950
// A function that takes a def_id relative to the crate being searched and
5051
// returns a def_id relative to the compilation environment, i.e. if we hit a
@@ -981,13 +982,13 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
981982
assert (vec::len(meta_items) == 1u);
982983
let meta_item = meta_items[0];
983984
attrs.push(
984-
ast::spanned {
985+
codemap::spanned {
985986
node: ast::attribute_ {
986987
style: ast::attr_outer,
987988
value: /*bad*/copy *meta_item,
988989
is_sugared_doc: false,
989990
},
990-
span: ast_util::dummy_sp()
991+
span: codemap::dummy_sp()
991992
});
992993
};
993994
}

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use core::uint;
2626
use core::vec;
2727
use syntax::ast;
2828
use syntax::ast::*;
29-
use syntax::ast_util;
30-
use syntax::ast_util::respan;
29+
use syntax::codemap::{respan, dummy_sp};
3130
use std::map::HashMap;
3231

3332
// Compact string representation for ty::t values. API ty_str &
@@ -114,7 +113,7 @@ fn parse_path(st: @pstate) -> @ast::path {
114113
':' => { next(st); next(st); }
115114
c => {
116115
if c == '(' {
117-
return @ast::path { span: ast_util::dummy_sp(),
116+
return @ast::path { span: dummy_sp(),
118117
global: false,
119118
idents: idents,
120119
rp: None,

src/librustc/middle/astencode.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl extended_decode_ctxt {
220220
ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) }
221221
}
222222
fn tr_span(_span: span) -> span {
223-
ast_util::dummy_sp() // FIXME (#1972): handle span properly
223+
codemap::dummy_sp() // FIXME (#1972): handle span properly
224224
}
225225
}
226226

@@ -300,9 +300,9 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
300300
let stmts_sans_items = do blk.stmts.filtered |stmt| {
301301
match stmt.node {
302302
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
303-
ast::stmt_decl(@ast::spanned { node: ast::decl_local(_),
303+
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_),
304304
span: _}, _) => true,
305-
ast::stmt_decl(@ast::spanned { node: ast::decl_item(_),
305+
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_),
306306
span: _}, _) => false,
307307
ast::stmt_mac(*) => die!(~"unexpanded macro in astencode")
308308
}
@@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
336336
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
337337
let dtor_body = fld.fold_block((*dtor).node.body);
338338
ast::ii_dtor(
339-
ast::spanned {
339+
codemap::spanned {
340340
node: ast::struct_dtor_ { body: dtor_body,
341341
.. /*bad*/copy (*dtor).node },
342342
.. (/*bad*/copy *dtor) },
@@ -377,7 +377,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
377377
let new_parent = xcx.tr_def_id(parent_id);
378378
let new_self = fld.new_id((*dtor).node.self_id);
379379
ast::ii_dtor(
380-
ast::spanned {
380+
codemap::spanned {
381381
node: ast::struct_dtor_ { id: dtor_id,
382382
attrs: dtor_attrs,
383383
self_id: new_self,

src/librustc/middle/check_const.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use core::dvec::DVec;
2020
use core::option;
2121
use std::map::HashMap;
2222
use syntax::ast::*;
23+
use syntax::codemap;
2324
use syntax::{visit, ast_util, ast_map};
2425

2526
pub fn check_crate(sess: Session,
@@ -64,7 +65,10 @@ pub fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
6465
fn is_str(e: @expr) -> bool {
6566
match e.node {
6667
expr_vstore(
67-
@expr { node: expr_lit(@spanned { node: lit_str(_), _}), _ },
68+
@expr { node: expr_lit(@codemap::spanned {
69+
node: lit_str(_),
70+
_}),
71+
_ },
6872
expr_vstore_uniq
6973
) => true,
7074
_ => false
@@ -96,7 +100,7 @@ pub fn check_expr(sess: Session,
96100
~"disallowed operator in constant expression");
97101
return;
98102
}
99-
expr_lit(@spanned {node: lit_str(_), _}) => { }
103+
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
100104
expr_binary(_, _, _) | expr_unary(_, _) => {
101105
if method_map.contains_key(e.id) {
102106
sess.span_err(e.span, ~"user-defined operators are not \
@@ -183,15 +187,15 @@ pub fn check_expr(sess: Session,
183187
}
184188
}
185189
match e.node {
186-
expr_lit(@spanned {node: lit_int(v, t), _}) => {
190+
expr_lit(@codemap::spanned {node: lit_int(v, t), _}) => {
187191
if t != ty_char {
188192
if (v as u64) > ast_util::int_ty_max(
189193
if t == ty_i { sess.targ_cfg.int_type } else { t }) {
190194
sess.span_err(e.span, ~"literal out of range for its type");
191195
}
192196
}
193197
}
194-
expr_lit(@spanned {node: lit_uint(v, t), _}) => {
198+
expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => {
195199
if v > ast_util::uint_ty_max(
196200
if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
197201
sess.span_err(e.span, ~"literal out of range for its type");

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ use core::vec;
2626
use std::map::HashMap;
2727
use std::sort;
2828
use syntax::ast::*;
29-
use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat};
30-
use syntax::ast_util;
31-
use syntax::codemap::span;
29+
use syntax::ast_util::{variant_def_ids, unguarded_pat, walk_pat};
30+
use syntax::codemap::{span, dummy_sp, spanned};
3231
use syntax::print::pprust::pat_to_str;
3332
use syntax::visit;
3433

@@ -464,7 +463,7 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
464463
}
465464
466465
pub fn wild() -> @pat {
467-
@pat {id: 0, node: pat_wild, span: ast_util::dummy_sp()}
466+
@pat {id: 0, node: pat_wild, span: dummy_sp()}
468467
}
469468
470469
pub fn specialize(cx: @MatchCheckCtxt,

src/librustc/middle/kind.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use core::str;
2626
use core::vec;
2727
use std::map::HashMap;
2828
use syntax::ast::*;
29-
use syntax::codemap::span;
29+
use syntax::codemap::{span, spanned};
3030
use syntax::print::pprust::expr_to_str;
3131
use syntax::{visit, ast_util};
3232

src/librustc/middle/lint.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use std::oldsmallintmap;
3939
use syntax::ast_util::{path_to_ident};
4040
use syntax::attr;
4141
use syntax::codemap::span;
42+
use syntax::codemap;
4243
use syntax::print::pprust::{expr_to_str, mode_to_str, pat_to_str};
4344
use syntax::{ast, ast_util, visit};
4445

@@ -453,7 +454,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
453454
match e.node {
454455
ast::expr_while(cond, _) => {
455456
match cond.node {
456-
ast::expr_lit(@ast::spanned {
457+
ast::expr_lit(@codemap::spanned {
457458
node: ast::lit_bool(true), _}) =>
458459
{
459460
cx.sess.span_lint(

src/librustc/middle/pat_util.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use middle::resolve;
1414
use middle::ty;
1515

1616
use syntax::ast::*;
17-
use syntax::ast_util;
18-
use syntax::ast_util::{path_to_ident, respan, walk_pat};
17+
use syntax::ast_util::{path_to_ident, walk_pat};
1918
use syntax::fold;
2019
use syntax::fold::*;
21-
use syntax::codemap::span;
20+
use syntax::codemap::{span, respan};
2221
use std::map::HashMap;
2322

2423
pub type PatIdMap = HashMap<ident, node_id>;

src/librustc/middle/resolve.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ use syntax::ast::{variant, view_item, view_item_import};
5858
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
5959
use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
6060
use syntax::ast::{unsafe_fn};
61-
use syntax::ast_util::{def_id_of_def, dummy_sp, local_def};
61+
use syntax::ast_util::{def_id_of_def, local_def};
6262
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
6363
use syntax::ast_util::{Privacy, Public, Private};
6464
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
6565
use syntax::attr::{attr_metas, contains_name, attrs_contains_name};
6666
use syntax::parse::token::ident_interner;
6767
use syntax::parse::token::special_idents;
6868
use syntax::print::pprust::{pat_to_str, path_to_str};
69-
use syntax::codemap::span;
69+
use syntax::codemap::{span, dummy_sp};
7070
use syntax::visit::{default_visitor, fk_method, mk_vt, Visitor, visit_block};
7171
use syntax::visit::{visit_crate, visit_expr, visit_expr_opt, visit_fn};
7272
use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};

src/librustc/middle/trans/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
18501850
ty: varg.ty,
18511851
pat: ast_util::ident_to_pat(
18521852
ccx.tcx.sess.next_node_id(),
1853-
ast_util::dummy_sp(),
1853+
codemap::dummy_sp(),
18541854
special_idents::arg),
18551855
id: varg.id,
18561856
}
@@ -1913,7 +1913,7 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt,
19131913
is_mutbl: false,
19141914
ty: field.node.ty,
19151915
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
1916-
ast_util::dummy_sp(),
1916+
codemap::dummy_sp(),
19171917
special_idents::arg),
19181918
id: field.node.id
19191919
}
@@ -2044,7 +2044,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
20442044
} else {
20452045
for vec::each((*body).node.stmts) |stmt| {
20462046
match stmt.node {
2047-
ast::stmt_decl(@ast::spanned { node: ast::decl_item(i),
2047+
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i),
20482048
_ }, _) => {
20492049
trans_item(ccx, *i);
20502050
}

0 commit comments

Comments
 (0)