Skip to content

Commit 35b91e2

Browse files
committed
Use static strings
1 parent d1f7220 commit 35b91e2

26 files changed

+201
-256
lines changed

src/librustc/middle/borrowck/loan.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,15 @@ pub impl LoanContext {
115115
if cmt.lp.is_none() {
116116
self.bccx.tcx.sess.span_bug(
117117
cmt.span,
118-
~"loan() called with non-lendable value");
118+
"loan() called with non-lendable value");
119119
}
120120

121121
match cmt.cat {
122122
cat_binding(_) | cat_rvalue | cat_special(_) => {
123123
// should never be loanable
124124
self.bccx.tcx.sess.span_bug(
125125
cmt.span,
126-
~"rvalue with a non-none lp");
126+
"rvalue with a non-none lp");
127127
}
128128
cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => {
129129
// FIXME(#4903)
@@ -188,7 +188,7 @@ pub impl LoanContext {
188188
// Aliased data is simply not lendable.
189189
self.bccx.tcx.sess.span_bug(
190190
cmt.span,
191-
~"aliased ptr with a non-none lp");
191+
"aliased ptr with a non-none lp");
192192
}
193193
}
194194
}

src/librustc/middle/borrowck/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -525,11 +525,11 @@ pub impl BorrowckCtxt {
525525
self.note_and_explain_bckerr(err);
526526
}
527527

528-
fn span_err(&self, s: span, m: ~str) {
528+
fn span_err(&self, s: span, m: &str) {
529529
self.tcx.sess.span_err(s, m);
530530
}
531531

532-
fn span_note(&self, s: span, m: ~str) {
532+
fn span_note(&self, s: span, m: &str) {
533533
self.tcx.sess.span_note(s, m);
534534
}
535535

src/librustc/middle/borrowck/preserve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub impl<'self> PreserveCtxt<'self> {
124124
if self.root_managed_data {
125125
self.tcx().sess.span_bug(
126126
cmt.span,
127-
~"preserve() called with local and !root_managed_data");
127+
"preserve() called with local and !root_managed_data");
128128
}
129129
let local_region = self.tcx().region_maps.encl_region(local_id);
130130
self.compare_scope(cmt, local_region)

src/librustc/middle/trans/_match.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,7 @@ pub fn enter_opt<'r>(bcx: block,
557557
struct_id = found_struct_id;
558558
}
559559
_ => {
560-
tcx.sess.span_bug(p.span, ~"expected enum \
561-
variant def");
560+
tcx.sess.span_bug(p.span, "expected enum variant def");
562561
}
563562
}
564563

src/librustc/middle/trans/base.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1125,10 +1125,11 @@ pub fn init_local(bcx: block, local: @ast::local) -> block {
11251125
}
11261126

11271127
let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
1128-
Some(&local_mem(v)) => v,
1129-
_ => { bcx.tcx().sess.span_bug(local.span,
1130-
~"init_local: Someone forgot to document why it's\
1131-
safe to assume local.node.init must be local_mem!");
1128+
Some(&local_mem(v)) => v,
1129+
_ => {
1130+
bcx.tcx().sess.span_bug(local.span,
1131+
"init_local: Someone forgot to document why it's\
1132+
safe to assume local.node.init must be local_mem!");
11321133
}
11331134
};
11341135

src/librustc/middle/trans/callee.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,7 @@ pub fn trans_method_call(in_cx: block,
356356
origin)
357357
}
358358
None => {
359-
cx.tcx().sess.span_bug(call_ex.span,
360-
~"method call expr wasn't in \
361-
method map")
359+
cx.tcx().sess.span_bug(call_ex.span, "method call expr wasn't in method map")
362360
}
363361
}
364362
},

src/librustc/middle/trans/consts.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
5858
}
5959
_ => {
6060
cx.sess.span_bug(lit.span,
61-
~"floating point literal doesn't have the right \
62-
type");
61+
"floating point literal doesn't have the right type");
6362
}
6463
}
6564
}
@@ -281,7 +280,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
281280
else { llvm::LLVMConstURem(te1, te2) }
282281
}
283282
ast::and |
284-
ast::or => cx.sess.span_unimpl(e.span, ~"binop logic"),
283+
ast::or => cx.sess.span_unimpl(e.span, "binop logic"),
285284
ast::bitxor => llvm::LLVMConstXor(te1, te2),
286285
ast::bitand => llvm::LLVMConstAnd(te1, te2),
287286
ast::bitor => llvm::LLVMConstOr(te1, te2),
@@ -295,7 +294,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
295294
ast::le |
296295
ast::ne |
297296
ast::ge |
298-
ast::gt => cx.sess.span_unimpl(e.span, ~"binop comparator")
297+
ast::gt => cx.sess.span_unimpl(e.span, "binop comparator")
299298
}
300299
}
301300
ast::expr_unary(u, e) => {
@@ -344,8 +343,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
344343
const_eval::const_int(i) => i as u64,
345344
const_eval::const_uint(u) => u,
346345
_ => cx.sess.span_bug(index.span,
347-
~"index is not an integer-constant \
348-
expression")
346+
"index is not an integer-constant expression")
349347
};
350348
let (arr, len) = match ty::get(bt).sty {
351349
ty::ty_evec(_, vstore) | ty::ty_estr(vstore) =>
@@ -363,12 +361,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
363361
unit_sz))
364362
},
365363
_ => cx.sess.span_bug(base.span,
366-
~"index-expr base must be \
367-
fixed-size or slice")
364+
"index-expr base must be fixed-size or slice")
368365
},
369366
_ => cx.sess.span_bug(base.span,
370-
~"index-expr base must be \
371-
a vector or string type")
367+
"index-expr base must be a vector or string type")
372368
};
373369

374370
let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
@@ -380,7 +376,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
380376
// FIXME #3170: report this earlier on in the const-eval
381377
// pass. Reporting here is a bit late.
382378
cx.sess.span_err(e.span,
383-
~"const index-expr is out of bounds");
379+
"const index-expr is out of bounds");
384380
}
385381
const_get_elt(cx, arr, [iv as c_uint])
386382
}
@@ -454,8 +450,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
454450
match fs.find(|f| field_ty.ident == f.node.ident) {
455451
Some(ref f) => const_expr(cx, (*f).node.expr),
456452
None => {
457-
cx.tcx.sess.span_bug(
458-
e.span, ~"missing struct field");
453+
cx.tcx.sess.span_bug(e.span, "missing struct field");
459454
}
460455
}
461456
});
@@ -471,8 +466,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
471466
ast::expr_lit(ref lit) => {
472467
match lit.node {
473468
ast::lit_str(*) => { const_expr(cx, sub) }
474-
_ => { cx.sess.span_bug(e.span,
475-
~"bad const-slice lit") }
469+
_ => { cx.sess.span_bug(e.span, "bad const-slice lit") }
476470
}
477471
}
478472
ast::expr_vec(ref es, ast::m_imm) => {
@@ -487,8 +481,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
487481
let p = const_ptrcast(cx, gv, llunitty);
488482
C_struct(~[p, sz])
489483
}
490-
_ => cx.sess.span_bug(e.span,
491-
~"bad const-slice expr")
484+
_ => cx.sess.span_bug(e.span, "bad const-slice expr")
492485
}
493486
}
494487
ast::expr_path(pth) => {
@@ -520,8 +513,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
520513
C_null(llty)
521514
}
522515
_ => {
523-
cx.sess.span_bug(e.span, ~"expected a const, fn, \
524-
struct, or variant def")
516+
cx.sess.span_bug(e.span, "expected a const, fn, struct, or variant def")
525517
}
526518
}
527519
}
@@ -542,13 +534,12 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
542534
adt::trans_const(cx, repr, vinfo.disr_val,
543535
args.map(|a| const_expr(cx, *a)))
544536
}
545-
_ => cx.sess.span_bug(e.span, ~"expected a struct or \
546-
variant def")
537+
_ => cx.sess.span_bug(e.span, "expected a struct or variant def")
547538
}
548539
}
549540
ast::expr_paren(e) => { return const_expr(cx, e); }
550541
_ => cx.sess.span_bug(e.span,
551-
~"bad constant expression type in consts::const_expr")
542+
"bad constant expression type in consts::const_expr")
552543
};
553544
}
554545
}

src/librustc/middle/trans/datum.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -761,8 +761,8 @@ pub impl Datum {
761761
match self.try_deref(bcx, expr.id, derefs, false) {
762762
(Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
763763
(None, _) => {
764-
bcx.ccx().sess.span_bug(
765-
expr.span, ~"Cannot deref this expression");
764+
bcx.ccx().sess.span_bug(expr.span,
765+
"Cannot deref this expression");
766766
}
767767
}
768768
}

src/librustc/middle/trans/debuginfo.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
756756
}
757757
},
758758
ty::ty_enum(_did, ref _substs) => {
759-
cx.sess.span_bug(span, ~"debuginfo for enum NYI")
759+
cx.sess.span_bug(span, "debuginfo for enum NYI")
760760
}
761761
ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => {
762762
let boxed = create_ty(cx, mt.ty, span);
@@ -782,18 +782,18 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
782782
create_pointer_type(cx, t, span, pointee)
783783
},
784784
ty::ty_rptr(ref _region, ref _mt) => {
785-
cx.sess.span_bug(span, ~"debuginfo for rptr NYI")
785+
cx.sess.span_bug(span, "debuginfo for rptr NYI")
786786
},
787787
ty::ty_bare_fn(ref barefnty) => {
788788
let inputs = do barefnty.sig.inputs.map |a| { a.ty };
789789
let output = barefnty.sig.output;
790790
create_fn_ty(cx, t, inputs, output, span)
791791
},
792792
ty::ty_closure(ref _closurety) => {
793-
cx.sess.span_bug(span, ~"debuginfo for closure NYI")
793+
cx.sess.span_bug(span, "debuginfo for closure NYI")
794794
},
795795
ty::ty_trait(_did, ref _substs, ref _vstore, _) => {
796-
cx.sess.span_bug(span, ~"debuginfo for trait NYI")
796+
cx.sess.span_bug(span, "debuginfo for trait NYI")
797797
},
798798
ty::ty_struct(did, ref substs) => {
799799
let fields = ty::struct_fields(cx.tcx, did, substs);
@@ -860,14 +860,12 @@ pub fn create_local_var(bcx: block, local: @ast::local)
860860
let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
861861
option::Some(&local_mem(v)) => v,
862862
option::Some(_) => {
863-
bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
864-
something weird");
863+
bcx.tcx().sess.span_bug(local.span, "local is bound to something weird");
865864
}
866865
option::None => {
867866
match *bcx.fcx.lllocals.get(&local.node.pat.id) {
868867
local_imm(v) => v,
869-
_ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
870-
something weird")
868+
_ => bcx.tcx().sess.span_bug(local.span, "local is bound to something weird")
871869
}
872870
}
873871
};
@@ -966,8 +964,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
966964
ast::item_fn(ref decl, _, _, _, _) => {
967965
(item.ident, decl.output, item.id)
968966
}
969-
_ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \
970-
bound to non-function")
967+
_ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
971968
}
972969
}
973970
ast_map::node_method(method, _, _) => {
@@ -979,12 +976,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
979976
((dbg_cx.names)(~"fn"), decl.output, expr.id)
980977
}
981978
_ => fcx.ccx.sess.span_bug(expr.span,
982-
~"create_function: \
983-
expected an expr_fn_block here")
979+
"create_function: expected an expr_fn_block here")
984980
}
985981
}
986-
_ => fcx.ccx.sess.bug(~"create_function: unexpected \
987-
sort of node")
982+
_ => fcx.ccx.sess.bug("create_function: unexpected sort of node")
988983
};
989984

990985
debug!("%?", ident);

src/librustc/middle/trans/expr.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
690690
}
691691
_ => {
692692
bcx.tcx().sess.span_bug(expr.span,
693-
~"expr_cast of non-trait");
693+
"expr_cast of non-trait");
694694
}
695695
}
696696
}
@@ -700,8 +700,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
700700
_ => {
701701
bcx.tcx().sess.span_bug(
702702
expr.span,
703-
fmt!("trans_rvalue_dps_unadjusted reached \
704-
fall-through case: %?",
703+
fmt!("trans_rvalue_dps_unadjusted reached fall-through case: %?",
705704
expr.node));
706705
}
707706
}
@@ -1202,7 +1201,7 @@ fn trans_rec_or_struct(bcx: block,
12021201
}
12031202
None => {
12041203
tcx.sess.span_bug(field.span,
1205-
~"Couldn't find field in struct type")
1204+
"Couldn't find field in struct type")
12061205
}
12071206
}
12081207
};
@@ -1478,15 +1477,15 @@ fn trans_eager_binop(bcx: block,
14781477
} else {
14791478
if !ty::type_is_scalar(rhs_t) {
14801479
bcx.tcx().sess.span_bug(binop_expr.span,
1481-
~"non-scalar comparison");
1480+
"non-scalar comparison");
14821481
}
14831482
let cmpr = base::compare_scalar_types(bcx, lhs, rhs, rhs_t, op);
14841483
bcx = cmpr.bcx;
14851484
ZExt(bcx, cmpr.val, T_i8())
14861485
}
14871486
}
14881487
_ => {
1489-
bcx.tcx().sess.span_bug(binop_expr.span, ~"unexpected binop");
1488+
bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
14901489
}
14911490
};
14921491

src/librustc/middle/trans/foreign.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
10801080
_ => {
10811081
// Could we make this an enum rather than a string? does it get
10821082
// checked earlier?
1083-
ccx.sess.span_bug(item.span, ~"unknown intrinsic");
1083+
ccx.sess.span_bug(item.span, "unknown intrinsic");
10841084
}
10851085
}
10861086
build_return(bcx);

src/librustc/middle/trans/monomorphize.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
160160
// causing an infinite expansion.
161161
if depth > 30 {
162162
ccx.sess.span_fatal(
163-
span, ~"overly deep expansion of inlined function");
163+
span, "overly deep expansion of inlined function");
164164
}
165165
ccx.monomorphizing.insert(fn_id, depth + 1);
166166

src/librustc/middle/trans/reachable.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,13 @@ fn traverse_inline_body(cx: &ctx, body: &blk) {
170170
expr_path(_) => {
171171
match cx.tcx.def_map.find(&e.id) {
172172
Some(&d) => {
173-
traverse_def_id(cx, def_id_of_def(d));
173+
traverse_def_id(cx, def_id_of_def(d));
174174
}
175-
None => cx.tcx.sess.span_bug(e.span, fmt!("Unbound node \
176-
id %? while traversing %s", e.id,
177-
expr_to_str(e, cx.tcx.sess.intr())))
175+
None => cx.tcx.sess.span_bug(
176+
e.span,
177+
fmt!("Unbound node id %? while traversing %s",
178+
e.id,
179+
expr_to_str(e, cx.tcx.sess.intr())))
178180
}
179181
}
180182
expr_field(_, _, _) => {

src/librustc/middle/trans/tvec.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ pub fn write_content(bcx: block,
469469
}
470470
_ => {
471471
bcx.tcx().sess.span_bug(content_expr.span,
472-
~"Unexpected evec content");
472+
"Unexpected evec content");
473473
}
474474
}
475475
}
@@ -503,7 +503,7 @@ pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
503503
ty::eval_repeat_count(bcx.tcx(), count_expr)
504504
}
505505
_ => bcx.tcx().sess.span_bug(content_expr.span,
506-
~"Unexpected evec content")
506+
"Unexpected evec content")
507507
}
508508
}
509509

0 commit comments

Comments
 (0)