Skip to content

Syntactic cleanup #4720

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

Merged
merged 3 commits into from
Feb 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -851,6 +851,9 @@ mod quux {

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

Also note that the paths contained in `use` items are relative to the crate root; so, in the previous
example, the use refers to `quux::foo::*`, and not simply to `foo::*`.

### Functions

A _function item_ defines a sequence of [statements](#statements) and an optional final [expression](#expressions), along with a name and a set of parameters.
Expand Down
4 changes: 2 additions & 2 deletions src/libcargo/cargo.rc
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ pub fn load_link(mis: ~[@ast::meta_item]) -> (Option<~str>,
let mut uuid = None;
for mis.each |a| {
match a.node {
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(s),
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(s),
_ }) => {
match v {
~"name" => name = Some(*s),
Expand Down Expand Up @@ -314,7 +314,7 @@ pub fn load_crate(filename: &Path) -> Option<Crate> {

for c.node.attrs.each |a| {
match a.node.value.node {
ast::meta_name_value(v, ast::spanned { node: ast::lit_str(_),
ast::meta_name_value(v, codemap::spanned { node: ast::lit_str(_),
_ }) => {
match v {
~"desc" => desc = Some(v),
Expand Down
4 changes: 2 additions & 2 deletions src/libfuzzer/fuzzer.rc
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ pub fn common_exprs() -> ~[ast::expr] {
id: 0,
callee_id: -1,
node: e,
span: ast_util::dummy_sp(),
span: codemap::dummy_sp(),
}
}

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

~[dse(ast::expr_break(option::None)),
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,14 +344,15 @@ pub mod test {

use syntax::ast;
use syntax::ast_util;
use syntax::codemap;

pub fn make_crate_type_attr(+t: ~str) -> ast::attribute {
ast_util::respan(ast_util::dummy_sp(), ast::attribute_ {
codemap::respan(codemap::dummy_sp(), ast::attribute_ {
style: ast::attr_outer,
value: ast_util::respan(ast_util::dummy_sp(),
value: codemap::respan(codemap::dummy_sp(),
ast::meta_name_value(
~"crate_type",
ast_util::respan(ast_util::dummy_sp(),
codemap::respan(codemap::dummy_sp(),
ast::lit_str(@t)))),
is_sugared_doc: false
})
Expand All @@ -361,7 +362,7 @@ pub mod test {
let mut attrs = ~[];
if with_bin { attrs += ~[make_crate_type_attr(~"bin")]; }
if with_lib { attrs += ~[make_crate_type_attr(~"lib")]; }
@ast_util::respan(ast_util::dummy_sp(), ast::crate_ {
@codemap::respan(codemap::dummy_sp(), ast::crate_ {
module: ast::_mod { view_items: ~[], items: ~[] },
attrs: attrs,
config: ~[]
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/front/core_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use syntax::ast;
use syntax::ast_util::*;
use syntax::attr;
use syntax::codemap;
use syntax::codemap::dummy_sp;
use syntax::fold;

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

fn inject_libcore_ref(sess: Session,
crate: @ast::crate) -> @ast::crate {
fn spanned<T: Copy>(x: T) -> ast::spanned<T> {
ast::spanned { node: x, span: dummy_sp() }
fn spanned<T: Copy>(x: T) -> codemap::spanned<T> {
codemap::spanned { node: x, span: dummy_sp() }
}

let precursor = @fold::AstFoldFns {
Expand Down
3 changes: 2 additions & 1 deletion src/librustc/front/intrinsic_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use core::prelude::*;
use driver::session::Session;
use syntax::parse;
use syntax::ast;
use syntax::codemap::spanned;

use core::vec;

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

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

@ast::spanned {
@spanned {
node: ast::crate_ {
module: ast::_mod {
items: items,
Expand Down
9 changes: 5 additions & 4 deletions src/librustc/front/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ use core::option;
use core::vec;
use syntax::ast_util::*;
use syntax::attr;
use syntax::codemap::span;
use syntax::codemap::{dummy_sp, span};
use syntax::codemap;
use syntax::fold;
use syntax::print::pprust;
use syntax::{ast, ast_util};
Expand Down Expand Up @@ -237,8 +238,8 @@ fn mk_test_module(cx: test_ctxt) -> @ast::item {
return @item;
}

fn nospan<T: Copy>(t: T) -> ast::spanned<T> {
ast::spanned { node: t, span: dummy_sp() }
fn nospan<T: Copy>(t: T) -> codemap::spanned<T> {
codemap::spanned { node: t, span: dummy_sp() }
}

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

let item_ = ast::item_fn(decl, ast::impure_fn, ~[], body);
let item = ast::item {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/creader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use core::either;
use core::option;
use core::vec;
use syntax::attr;
use syntax::codemap::span;
use syntax::codemap::{span, dummy_sp};
use syntax::diagnostic::span_handler;
use syntax::parse::token::ident_interner;
use syntax::print::pprust;
Expand Down Expand Up @@ -294,7 +294,7 @@ fn resolve_crate_deps(e: env, cdata: @~[u8]) -> cstore::cnum_map {
// This is a new one so we've got to load it
// FIXME (#2404): Need better error reporting than just a bogus
// span.
let fake_span = ast_util::dummy_sp();
let fake_span = dummy_sp();
let local_cnum = resolve_crate(e, cname, cmetas,
/*bad*/copy dep.hash, fake_span);
cnum_map.insert(extrn_cnum, local_cnum);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/metadata/csearch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::ebml;
use std::map::HashMap;
use syntax::ast;
use syntax::ast_map;
use syntax::ast_util::dummy_sp;
use syntax::codemap::dummy_sp;
use syntax::ast_util;
use syntax::diagnostic::expect;
use syntax::diagnostic::span_handler;
Expand Down
5 changes: 3 additions & 2 deletions src/librustc/metadata/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ use syntax::diagnostic::span_handler;
use syntax::parse::token::ident_interner;
use syntax::print::pprust;
use syntax::{ast, ast_util};
use syntax::codemap;

// A function that takes a def_id relative to the crate being searched and
// returns a def_id relative to the compilation environment, i.e. if we hit a
Expand Down Expand Up @@ -981,13 +982,13 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::attribute] {
assert (vec::len(meta_items) == 1u);
let meta_item = meta_items[0];
attrs.push(
ast::spanned {
codemap::spanned {
node: ast::attribute_ {
style: ast::attr_outer,
value: /*bad*/copy *meta_item,
is_sugared_doc: false,
},
span: ast_util::dummy_sp()
span: codemap::dummy_sp()
});
};
}
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ use core::uint;
use core::vec;
use syntax::ast;
use syntax::ast::*;
use syntax::ast_util;
use syntax::ast_util::respan;
use syntax::codemap::{respan, dummy_sp};
use std::map::HashMap;

// Compact string representation for ty::t values. API ty_str &
Expand Down Expand Up @@ -114,7 +113,7 @@ fn parse_path(st: @pstate) -> @ast::path {
':' => { next(st); next(st); }
c => {
if c == '(' {
return @ast::path { span: ast_util::dummy_sp(),
return @ast::path { span: dummy_sp(),
global: false,
idents: idents,
rp: None,
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/middle/astencode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl extended_decode_ctxt {
ast::def_id { crate: ast::local_crate, node: self.tr_id(did.node) }
}
fn tr_span(_span: span) -> span {
ast_util::dummy_sp() // FIXME (#1972): handle span properly
codemap::dummy_sp() // FIXME (#1972): handle span properly
}
}

Expand Down Expand Up @@ -300,9 +300,9 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
let stmts_sans_items = do blk.stmts.filtered |stmt| {
match stmt.node {
ast::stmt_expr(_, _) | ast::stmt_semi(_, _) |
ast::stmt_decl(@ast::spanned { node: ast::decl_local(_),
ast::stmt_decl(@codemap::spanned { node: ast::decl_local(_),
span: _}, _) => true,
ast::stmt_decl(@ast::spanned { node: ast::decl_item(_),
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(_),
span: _}, _) => false,
ast::stmt_mac(*) => die!(~"unexpanded macro in astencode")
}
Expand Down Expand Up @@ -336,7 +336,7 @@ fn simplify_ast(ii: ast::inlined_item) -> ast::inlined_item {
ast::ii_dtor(ref dtor, nm, ref tps, parent_id) => {
let dtor_body = fld.fold_block((*dtor).node.body);
ast::ii_dtor(
ast::spanned {
codemap::spanned {
node: ast::struct_dtor_ { body: dtor_body,
.. /*bad*/copy (*dtor).node },
.. (/*bad*/copy *dtor) },
Expand Down Expand Up @@ -377,7 +377,7 @@ fn renumber_ast(xcx: extended_decode_ctxt, ii: ast::inlined_item)
let new_parent = xcx.tr_def_id(parent_id);
let new_self = fld.new_id((*dtor).node.self_id);
ast::ii_dtor(
ast::spanned {
codemap::spanned {
node: ast::struct_dtor_ { id: dtor_id,
attrs: dtor_attrs,
self_id: new_self,
Expand Down
12 changes: 8 additions & 4 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use core::dvec::DVec;
use core::option;
use std::map::HashMap;
use syntax::ast::*;
use syntax::codemap;
use syntax::{visit, ast_util, ast_map};

pub fn check_crate(sess: Session,
Expand Down Expand Up @@ -64,7 +65,10 @@ pub fn check_pat(p: @pat, &&_is_const: bool, v: visit::vt<bool>) {
fn is_str(e: @expr) -> bool {
match e.node {
expr_vstore(
@expr { node: expr_lit(@spanned { node: lit_str(_), _}), _ },
@expr { node: expr_lit(@codemap::spanned {
node: lit_str(_),
_}),
_ },
expr_vstore_uniq
) => true,
_ => false
Expand Down Expand Up @@ -96,7 +100,7 @@ pub fn check_expr(sess: Session,
~"disallowed operator in constant expression");
return;
}
expr_lit(@spanned {node: lit_str(_), _}) => { }
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
expr_binary(_, _, _) | expr_unary(_, _) => {
if method_map.contains_key(e.id) {
sess.span_err(e.span, ~"user-defined operators are not \
Expand Down Expand Up @@ -183,15 +187,15 @@ pub fn check_expr(sess: Session,
}
}
match e.node {
expr_lit(@spanned {node: lit_int(v, t), _}) => {
expr_lit(@codemap::spanned {node: lit_int(v, t), _}) => {
if t != ty_char {
if (v as u64) > ast_util::int_ty_max(
if t == ty_i { sess.targ_cfg.int_type } else { t }) {
sess.span_err(e.span, ~"literal out of range for its type");
}
}
}
expr_lit(@spanned {node: lit_uint(v, t), _}) => {
expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => {
if v > ast_util::uint_ty_max(
if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
sess.span_err(e.span, ~"literal out of range for its type");
Expand Down
7 changes: 3 additions & 4 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ use core::vec;
use std::map::HashMap;
use std::sort;
use syntax::ast::*;
use syntax::ast_util::{variant_def_ids, dummy_sp, unguarded_pat, walk_pat};
use syntax::ast_util;
use syntax::codemap::span;
use syntax::ast_util::{variant_def_ids, unguarded_pat, walk_pat};
use syntax::codemap::{span, dummy_sp, spanned};
use syntax::print::pprust::pat_to_str;
use syntax::visit;

Expand Down Expand Up @@ -464,7 +463,7 @@ pub fn ctor_arity(cx: @MatchCheckCtxt, ctor: ctor, ty: ty::t) -> uint {
}

pub fn wild() -> @pat {
@pat {id: 0, node: pat_wild, span: ast_util::dummy_sp()}
@pat {id: 0, node: pat_wild, span: dummy_sp()}
}

pub fn specialize(cx: @MatchCheckCtxt,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use core::str;
use core::vec;
use std::map::HashMap;
use syntax::ast::*;
use syntax::codemap::span;
use syntax::codemap::{span, spanned};
use syntax::print::pprust::expr_to_str;
use syntax::{visit, ast_util};

Expand Down
3 changes: 2 additions & 1 deletion src/librustc/middle/lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ use std::oldsmallintmap;
use syntax::ast_util::{path_to_ident};
use syntax::attr;
use syntax::codemap::span;
use syntax::codemap;
use syntax::print::pprust::{expr_to_str, mode_to_str, pat_to_str};
use syntax::{ast, ast_util, visit};

Expand Down Expand Up @@ -453,7 +454,7 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
match e.node {
ast::expr_while(cond, _) => {
match cond.node {
ast::expr_lit(@ast::spanned {
ast::expr_lit(@codemap::spanned {
node: ast::lit_bool(true), _}) =>
{
cx.sess.span_lint(
Expand Down
5 changes: 2 additions & 3 deletions src/librustc/middle/pat_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ use middle::resolve;
use middle::ty;

use syntax::ast::*;
use syntax::ast_util;
use syntax::ast_util::{path_to_ident, respan, walk_pat};
use syntax::ast_util::{path_to_ident, walk_pat};
use syntax::fold;
use syntax::fold::*;
use syntax::codemap::span;
use syntax::codemap::{span, respan};
use std::map::HashMap;

pub type PatIdMap = HashMap<ident, node_id>;
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ use syntax::ast::{variant, view_item, view_item_import};
use syntax::ast::{view_item_use, view_path_glob, view_path_list};
use syntax::ast::{view_path_simple, visibility, anonymous, named, not};
use syntax::ast::{unsafe_fn};
use syntax::ast_util::{def_id_of_def, dummy_sp, local_def};
use syntax::ast_util::{def_id_of_def, local_def};
use syntax::ast_util::{path_to_ident, walk_pat, trait_method_to_ty_method};
use syntax::ast_util::{Privacy, Public, Private};
use syntax::ast_util::{variant_visibility_to_privacy, visibility_to_privacy};
use syntax::attr::{attr_metas, contains_name, attrs_contains_name};
use syntax::parse::token::ident_interner;
use syntax::parse::token::special_idents;
use syntax::print::pprust::{pat_to_str, path_to_str};
use syntax::codemap::span;
use syntax::codemap::{span, dummy_sp};
use syntax::visit::{default_visitor, fk_method, mk_vt, Visitor, visit_block};
use syntax::visit::{visit_crate, visit_expr, visit_expr_opt, visit_fn};
use syntax::visit::{visit_foreign_item, visit_item, visit_method_helper};
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,7 @@ pub fn trans_enum_variant(ccx: @crate_ctxt,
ty: varg.ty,
pat: ast_util::ident_to_pat(
ccx.tcx.sess.next_node_id(),
ast_util::dummy_sp(),
codemap::dummy_sp(),
special_idents::arg),
id: varg.id,
}
Expand Down Expand Up @@ -1913,7 +1913,7 @@ pub fn trans_tuple_struct(ccx: @crate_ctxt,
is_mutbl: false,
ty: field.node.ty,
pat: ast_util::ident_to_pat(ccx.tcx.sess.next_node_id(),
ast_util::dummy_sp(),
codemap::dummy_sp(),
special_idents::arg),
id: field.node.id
}
Expand Down Expand Up @@ -2044,7 +2044,7 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
} else {
for vec::each((*body).node.stmts) |stmt| {
match stmt.node {
ast::stmt_decl(@ast::spanned { node: ast::decl_item(i),
ast::stmt_decl(@codemap::spanned { node: ast::decl_item(i),
_ }, _) => {
trans_item(ccx, *i);
}
Expand Down
Loading