Skip to content

Commit c34ef5d

Browse files
committed
auto merge of #11255 : klutzy/rust/small-cleanup, r=pcwalton
This patchset removes some `@`s and unnecessary traits, and replaces a function (`dummy_sp()`) returning constant value by static variable.
2 parents 51ace54 + 9cdad68 commit c34ef5d

38 files changed

+194
-226
lines changed

src/librustc/driver/driver.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ pub fn host_triple() -> ~str {
686686
(env!("CFG_COMPILER")).to_owned()
687687
}
688688

689-
pub fn build_session_options(binary: @str,
689+
pub fn build_session_options(binary: ~str,
690690
matches: &getopts::Matches,
691691
demitter: @diagnostic::Emitter)
692692
-> @session::options {
@@ -883,7 +883,7 @@ pub fn build_session(sopts: @session::options, demitter: @diagnostic::Emitter)
883883
pub fn build_session_(sopts: @session::options,
884884
cm: @codemap::CodeMap,
885885
demitter: @diagnostic::Emitter,
886-
span_diagnostic_handler: @mut diagnostic::span_handler)
886+
span_diagnostic_handler: @mut diagnostic::SpanHandler)
887887
-> Session {
888888
let target_cfg = build_target_config(sopts, demitter);
889889
let p_s = parse::new_parse_sess_special_handler(span_diagnostic_handler,
@@ -1105,7 +1105,7 @@ pub fn build_output_filenames(input: &input,
11051105
}
11061106
}
11071107

1108-
pub fn early_error(emitter: @diagnostic::Emitter, msg: &str) -> ! {
1108+
pub fn early_error(emitter: &diagnostic::Emitter, msg: &str) -> ! {
11091109
emitter.emit(None, msg, diagnostic::fatal);
11101110
fail!();
11111111
}
@@ -1135,7 +1135,7 @@ mod test {
11351135
Err(f) => fail!("test_switch_implies_cfg_test: {}", f.to_err_msg())
11361136
};
11371137
let sessopts = build_session_options(
1138-
@"rustc",
1138+
~"rustc",
11391139
matches,
11401140
@diagnostic::DefaultEmitter as @diagnostic::Emitter);
11411141
let sess = build_session(sessopts,
@@ -1158,7 +1158,7 @@ mod test {
11581158
}
11591159
};
11601160
let sessopts = build_session_options(
1161-
@"rustc",
1161+
~"rustc",
11621162
matches,
11631163
@diagnostic::DefaultEmitter as @diagnostic::Emitter);
11641164
let sess = build_session(sessopts,

src/librustc/driver/session.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub struct options {
163163
// will be added to the crate AST node. This should not be used for
164164
// anything except building the full crate config prior to parsing.
165165
cfg: ast::CrateConfig,
166-
binary: @str,
166+
binary: ~str,
167167
test: bool,
168168
parse_only: bool,
169169
no_trans: bool,
@@ -209,7 +209,7 @@ pub struct Session_ {
209209
// For a library crate, this is always none
210210
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,
211211
entry_type: Cell<Option<EntryFnType>>,
212-
span_diagnostic: @mut diagnostic::span_handler,
212+
span_diagnostic: @mut diagnostic::SpanHandler,
213213
filesearch: @filesearch::FileSearch,
214214
building_library: Cell<bool>,
215215
working_dir: Path,
@@ -292,7 +292,7 @@ impl Session_ {
292292

293293
v
294294
}
295-
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
295+
pub fn diagnostic(&self) -> @mut diagnostic::SpanHandler {
296296
self.span_diagnostic
297297
}
298298
pub fn debugging_opt(&self, opt: uint) -> bool {
@@ -395,7 +395,7 @@ pub fn basic_options() -> @options {
395395
target_cpu: ~"generic",
396396
target_feature: ~"",
397397
cfg: ~[],
398-
binary: @"rustc",
398+
binary: ~"rustc",
399399
test: false,
400400
parse_only: false,
401401
no_trans: false,

src/librustc/front/std_inject.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use driver::session::Session;
1414
use std::vec;
1515
use syntax::ast;
1616
use syntax::attr;
17-
use syntax::codemap::dummy_sp;
17+
use syntax::codemap::DUMMY_SP;
1818
use syntax::codemap;
1919
use syntax::fold::ast_fold;
2020
use syntax::fold;
@@ -47,7 +47,7 @@ fn no_prelude(attrs: &[ast::Attribute]) -> bool {
4747
fn spanned<T>(x: T) -> codemap::Spanned<T> {
4848
codemap::Spanned {
4949
node: x,
50-
span: dummy_sp(),
50+
span: DUMMY_SP,
5151
}
5252
}
5353

@@ -66,7 +66,7 @@ impl fold::ast_fold for StandardLibraryInjector {
6666
ast::DUMMY_NODE_ID),
6767
attrs: ~[],
6868
vis: ast::private,
69-
span: dummy_sp()
69+
span: DUMMY_SP
7070
}];
7171

7272
if use_uv(&crate) && !self.sess.building_library.get() {
@@ -77,7 +77,7 @@ impl fold::ast_fold for StandardLibraryInjector {
7777
ast::DUMMY_NODE_ID),
7878
attrs: ~[],
7979
vis: ast::private,
80-
span: dummy_sp()
80+
span: DUMMY_SP
8181
});
8282
vis.push(ast::view_item {
8383
node: ast::view_item_extern_mod(self.sess.ident_of("rustuv"),
@@ -86,7 +86,7 @@ impl fold::ast_fold for StandardLibraryInjector {
8686
ast::DUMMY_NODE_ID),
8787
attrs: ~[],
8888
vis: ast::private,
89-
span: dummy_sp()
89+
span: DUMMY_SP
9090
});
9191
}
9292

@@ -121,7 +121,7 @@ impl fold::ast_fold for StandardLibraryInjector {
121121

122122
fn fold_mod(&mut self, module: &ast::_mod) -> ast::_mod {
123123
let prelude_path = ast::Path {
124-
span: dummy_sp(),
124+
span: DUMMY_SP,
125125
global: false,
126126
segments: ~[
127127
ast::PathSegment {
@@ -143,7 +143,7 @@ impl fold::ast_fold for StandardLibraryInjector {
143143
node: ast::view_item_use(~[vp]),
144144
attrs: ~[],
145145
vis: ast::private,
146-
span: dummy_sp(),
146+
span: DUMMY_SP,
147147
};
148148

149149
let vis = vec::append(~[vi2], module.view_items);

src/librustc/front/test.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::vec;
1919
use syntax::ast_util::*;
2020
use syntax::attr::AttrMetaMethods;
2121
use syntax::attr;
22-
use syntax::codemap::{dummy_sp, Span, ExpnInfo, NameAndSpan, MacroAttribute};
22+
use syntax::codemap::{DUMMY_SP, Span, ExpnInfo, NameAndSpan, MacroAttribute};
2323
use syntax::codemap;
2424
use syntax::ext::base::ExtCtxt;
2525
use syntax::fold::ast_fold;
@@ -164,7 +164,7 @@ fn generate_test_harness(sess: session::Session, crate: ast::Crate)
164164
};
165165

166166
cx.ext_cx.bt_push(ExpnInfo {
167-
call_site: dummy_sp(),
167+
call_site: DUMMY_SP,
168168
callee: NameAndSpan {
169169
name: @"test",
170170
format: MacroAttribute,
@@ -298,7 +298,7 @@ fn mk_std(cx: &TestCtxt) -> ast::view_item {
298298
node: vi,
299299
attrs: ~[],
300300
vis: ast::public,
301-
span: dummy_sp()
301+
span: DUMMY_SP
302302
}
303303
}
304304

@@ -335,7 +335,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
335335
id: ast::DUMMY_NODE_ID,
336336
node: item_,
337337
vis: ast::public,
338-
span: dummy_sp(),
338+
span: DUMMY_SP,
339339
};
340340

341341
debug!("Synthetic test module:\n{}\n",
@@ -345,12 +345,12 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
345345
}
346346

347347
fn nospan<T>(t: T) -> codemap::Spanned<T> {
348-
codemap::Spanned { node: t, span: dummy_sp() }
348+
codemap::Spanned { node: t, span: DUMMY_SP }
349349
}
350350

351351
fn path_node(ids: ~[ast::Ident]) -> ast::Path {
352352
ast::Path {
353-
span: dummy_sp(),
353+
span: DUMMY_SP,
354354
global: false,
355355
segments: ids.move_iter().map(|identifier| ast::PathSegment {
356356
identifier: identifier,
@@ -362,7 +362,7 @@ fn path_node(ids: ~[ast::Ident]) -> ast::Path {
362362

363363
fn path_node_global(ids: ~[ast::Ident]) -> ast::Path {
364364
ast::Path {
365-
span: dummy_sp(),
365+
span: DUMMY_SP,
366366
global: true,
367367
segments: ids.move_iter().map(|identifier| ast::PathSegment {
368368
identifier: identifier,
@@ -403,13 +403,13 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
403403
let inner_expr = @ast::Expr {
404404
id: ast::DUMMY_NODE_ID,
405405
node: ast::ExprVec(descs, ast::MutImmutable),
406-
span: dummy_sp(),
406+
span: DUMMY_SP,
407407
};
408408

409409
@ast::Expr {
410410
id: ast::DUMMY_NODE_ID,
411411
node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice),
412-
span: dummy_sp(),
412+
span: DUMMY_SP,
413413
}
414414
}
415415

src/librustc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub fn describe_debug_flags() {
197197

198198
pub fn run_compiler(args: &[~str], demitter: @diagnostic::Emitter) {
199199
let mut args = args.to_owned();
200-
let binary = args.shift().to_managed();
200+
let binary = args.shift();
201201

202202
if args.is_empty() { usage(binary); return; }
203203

@@ -348,7 +348,7 @@ struct RustcEmitter {
348348

349349
impl diagnostic::Emitter for RustcEmitter {
350350
fn emit(&self,
351-
cmsp: Option<(@codemap::CodeMap, codemap::Span)>,
351+
cmsp: Option<(&codemap::CodeMap, codemap::Span)>,
352352
msg: &str,
353353
lvl: diagnostic::level) {
354354
if lvl == diagnostic::fatal {

src/librustc/metadata/creader.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use syntax::ast;
2121
use syntax::abi;
2222
use syntax::attr;
2323
use syntax::attr::AttrMetaMethods;
24-
use syntax::codemap::{Span, dummy_sp};
25-
use syntax::diagnostic::span_handler;
24+
use syntax::codemap::{Span, DUMMY_SP};
25+
use syntax::diagnostic::SpanHandler;
2626
use syntax::parse::token;
2727
use syntax::parse::token::ident_interner;
2828
use syntax::crateid::CrateId;
@@ -86,7 +86,7 @@ fn dump_crates(crate_cache: &[cache_entry]) {
8686
}
8787

8888
fn warn_if_multiple_versions(e: &mut Env,
89-
diag: @mut span_handler,
89+
diag: @mut SpanHandler,
9090
crate_cache: &[cache_entry]) {
9191
if crate_cache.len() != 0u {
9292
let name = crate_cache[crate_cache.len() - 1].crateid.name.clone();
@@ -346,7 +346,7 @@ fn resolve_crate_deps(e: &mut Env, cdata: &[u8]) -> cstore::cnum_map {
346346
// This is a new one so we've got to load it
347347
// FIXME (#2404): Need better error reporting than just a bogus
348348
// span.
349-
let fake_span = dummy_sp();
349+
let fake_span = DUMMY_SP;
350350
let local_cnum = resolve_crate(e, cname_str, cname_str, dep.vers,
351351
dep.hash, fake_span);
352352
cnum_map.insert(extrn_cnum, local_cnum);

src/librustc/metadata/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1099,7 +1099,7 @@ fn get_attributes(md: ebml::Doc) -> ~[ast::Attribute] {
10991099
value: meta_item,
11001100
is_sugared_doc: false,
11011101
},
1102-
span: codemap::dummy_sp()
1102+
span: codemap::DUMMY_SP
11031103
});
11041104
true
11051105
});

src/librustc/metadata/encoder.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use syntax::ast_map;
3939
use syntax::ast_util::*;
4040
use syntax::attr;
4141
use syntax::attr::AttrMetaMethods;
42-
use syntax::diagnostic::span_handler;
42+
use syntax::diagnostic::SpanHandler;
4343
use syntax::parse::token::special_idents;
4444
use syntax::ast_util;
4545
use syntax::visit::Visitor;
@@ -57,7 +57,7 @@ pub type encode_inlined_item<'a> = 'a |ecx: &EncodeContext,
5757
ii: ast::inlined_item|;
5858

5959
pub struct EncodeParams<'a> {
60-
diag: @mut span_handler,
60+
diag: @mut SpanHandler,
6161
tcx: ty::ctxt,
6262
reexports2: middle::resolve::ExportMap2,
6363
item_symbols: &'a RefCell<HashMap<ast::NodeId, ~str>>,
@@ -83,7 +83,7 @@ struct Stats {
8383
}
8484

8585
pub struct EncodeContext<'a> {
86-
diag: @mut span_handler,
86+
diag: @mut SpanHandler,
8787
tcx: ty::ctxt,
8888
stats: @Stats,
8989
reexports2: middle::resolve::ExportMap2,

src/librustc/metadata/loader.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use metadata::encoder;
1919
use metadata::filesearch::{FileMatches, FileDoesntMatch};
2020
use metadata::filesearch;
2121
use syntax::codemap::Span;
22-
use syntax::diagnostic::span_handler;
22+
use syntax::diagnostic::SpanHandler;
2323
use syntax::parse::token::ident_interner;
2424
use syntax::crateid::CrateId;
2525
use syntax::attr;
@@ -231,8 +231,8 @@ impl Context {
231231
}
232232
}
233233

234-
pub fn note_crateid_attr(diag: @mut span_handler,
235-
crateid: &CrateId) {
234+
pub fn note_crateid_attr(diag: @mut SpanHandler,
235+
crateid: &CrateId) {
236236
diag.handler().note(format!("crate_id: {}", crateid.to_str()));
237237
}
238238

src/librustc/metadata/tyencode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ use middle::ty;
2424
use syntax::abi::AbiSet;
2525
use syntax::ast;
2626
use syntax::ast::*;
27-
use syntax::diagnostic::span_handler;
27+
use syntax::diagnostic::SpanHandler;
2828
use syntax::print::pprust::*;
2929

3030
macro_rules! mywrite( ($wr:expr, $($arg:tt)*) => (
3131
format_args!(|a| { mywrite($wr, a) }, $($arg)*)
3232
) )
3333

3434
pub struct ctxt {
35-
diag: @mut span_handler,
35+
diag: @mut SpanHandler,
3636
// Def -> str Callback:
3737
ds: extern "Rust" fn(DefId) -> ~str,
3838
// The type context.

src/librustc/middle/astencode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl ExtendedDecodeContext {
218218
ast::DefId { crate: ast::LOCAL_CRATE, node: self.tr_id(did.node) }
219219
}
220220
pub fn tr_span(&self, _span: Span) -> Span {
221-
codemap::dummy_sp() // FIXME (#1972): handle span properly
221+
codemap::DUMMY_SP // FIXME (#1972): handle span properly
222222
}
223223
}
224224

src/librustc/middle/check_match.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::num;
2323
use std::vec;
2424
use syntax::ast::*;
2525
use syntax::ast_util::{unguarded_pat, walk_pat};
26-
use syntax::codemap::{Span, dummy_sp, Spanned};
26+
use syntax::codemap::{Span, DUMMY_SP, Spanned};
2727
use syntax::visit;
2828
use syntax::visit::{Visitor,fn_kind};
2929

@@ -536,11 +536,11 @@ fn ctor_arity(cx: &MatchCheckCtxt, ctor: &ctor, ty: ty::t) -> uint {
536536
}
537537

538538
fn wild() -> @Pat {
539-
@Pat {id: 0, node: PatWild, span: dummy_sp()}
539+
@Pat {id: 0, node: PatWild, span: DUMMY_SP}
540540
}
541541

542542
fn wild_multi() -> @Pat {
543-
@Pat {id: 0, node: PatWildMulti, span: dummy_sp()}
543+
@Pat {id: 0, node: PatWildMulti, span: DUMMY_SP}
544544
}
545545

546546
fn specialize(cx: &MatchCheckCtxt,

0 commit comments

Comments
 (0)