Skip to content

Commit

Permalink
Use static strings
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed May 2, 2013
1 parent d1f7220 commit 35b91e2
Show file tree
Hide file tree
Showing 26 changed files with 201 additions and 256 deletions.
6 changes: 3 additions & 3 deletions src/librustc/middle/borrowck/loan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,15 @@ pub impl LoanContext {
if cmt.lp.is_none() {
self.bccx.tcx.sess.span_bug(
cmt.span,
~"loan() called with non-lendable value");
"loan() called with non-lendable value");
}

match cmt.cat {
cat_binding(_) | cat_rvalue | cat_special(_) => {
// should never be loanable
self.bccx.tcx.sess.span_bug(
cmt.span,
~"rvalue with a non-none lp");
"rvalue with a non-none lp");
}
cat_local(local_id) | cat_arg(local_id) | cat_self(local_id) => {
// FIXME(#4903)
Expand Down Expand Up @@ -188,7 +188,7 @@ pub impl LoanContext {
// Aliased data is simply not lendable.
self.bccx.tcx.sess.span_bug(
cmt.span,
~"aliased ptr with a non-none lp");
"aliased ptr with a non-none lp");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/borrowck/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,11 @@ pub impl BorrowckCtxt {
self.note_and_explain_bckerr(err);
}

fn span_err(&self, s: span, m: ~str) {
fn span_err(&self, s: span, m: &str) {
self.tcx.sess.span_err(s, m);
}

fn span_note(&self, s: span, m: ~str) {
fn span_note(&self, s: span, m: &str) {
self.tcx.sess.span_note(s, m);
}

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/borrowck/preserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pub impl<'self> PreserveCtxt<'self> {
if self.root_managed_data {
self.tcx().sess.span_bug(
cmt.span,
~"preserve() called with local and !root_managed_data");
"preserve() called with local and !root_managed_data");
}
let local_region = self.tcx().region_maps.encl_region(local_id);
self.compare_scope(cmt, local_region)
Expand Down
3 changes: 1 addition & 2 deletions src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,7 @@ pub fn enter_opt<'r>(bcx: block,
struct_id = found_struct_id;
}
_ => {
tcx.sess.span_bug(p.span, ~"expected enum \
variant def");
tcx.sess.span_bug(p.span, "expected enum variant def");
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/librustc/middle/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1125,10 +1125,11 @@ pub fn init_local(bcx: block, local: @ast::local) -> block {
}

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

Expand Down
4 changes: 1 addition & 3 deletions src/librustc/middle/trans/callee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,7 @@ pub fn trans_method_call(in_cx: block,
origin)
}
None => {
cx.tcx().sess.span_bug(call_ex.span,
~"method call expr wasn't in \
method map")
cx.tcx().sess.span_bug(call_ex.span, "method call expr wasn't in method map")
}
}
},
Expand Down
35 changes: 13 additions & 22 deletions src/librustc/middle/trans/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ pub fn const_lit(cx: @CrateContext, e: @ast::expr, lit: ast::lit)
}
_ => {
cx.sess.span_bug(lit.span,
~"floating point literal doesn't have the right \
type");
"floating point literal doesn't have the right type");
}
}
}
Expand Down Expand Up @@ -281,7 +280,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
else { llvm::LLVMConstURem(te1, te2) }
}
ast::and |
ast::or => cx.sess.span_unimpl(e.span, ~"binop logic"),
ast::or => cx.sess.span_unimpl(e.span, "binop logic"),
ast::bitxor => llvm::LLVMConstXor(te1, te2),
ast::bitand => llvm::LLVMConstAnd(te1, te2),
ast::bitor => llvm::LLVMConstOr(te1, te2),
Expand All @@ -295,7 +294,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
ast::le |
ast::ne |
ast::ge |
ast::gt => cx.sess.span_unimpl(e.span, ~"binop comparator")
ast::gt => cx.sess.span_unimpl(e.span, "binop comparator")
}
}
ast::expr_unary(u, e) => {
Expand Down Expand Up @@ -344,8 +343,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
const_eval::const_int(i) => i as u64,
const_eval::const_uint(u) => u,
_ => cx.sess.span_bug(index.span,
~"index is not an integer-constant \
expression")
"index is not an integer-constant expression")
};
let (arr, len) = match ty::get(bt).sty {
ty::ty_evec(_, vstore) | ty::ty_estr(vstore) =>
Expand All @@ -363,12 +361,10 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
unit_sz))
},
_ => cx.sess.span_bug(base.span,
~"index-expr base must be \
fixed-size or slice")
"index-expr base must be fixed-size or slice")
},
_ => cx.sess.span_bug(base.span,
~"index-expr base must be \
a vector or string type")
"index-expr base must be a vector or string type")
};

let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
Expand All @@ -380,7 +376,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
// FIXME #3170: report this earlier on in the const-eval
// pass. Reporting here is a bit late.
cx.sess.span_err(e.span,
~"const index-expr is out of bounds");
"const index-expr is out of bounds");
}
const_get_elt(cx, arr, [iv as c_uint])
}
Expand Down Expand Up @@ -454,8 +450,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
match fs.find(|f| field_ty.ident == f.node.ident) {
Some(ref f) => const_expr(cx, (*f).node.expr),
None => {
cx.tcx.sess.span_bug(
e.span, ~"missing struct field");
cx.tcx.sess.span_bug(e.span, "missing struct field");
}
}
});
Expand All @@ -471,8 +466,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
ast::expr_lit(ref lit) => {
match lit.node {
ast::lit_str(*) => { const_expr(cx, sub) }
_ => { cx.sess.span_bug(e.span,
~"bad const-slice lit") }
_ => { cx.sess.span_bug(e.span, "bad const-slice lit") }
}
}
ast::expr_vec(ref es, ast::m_imm) => {
Expand All @@ -487,8 +481,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
let p = const_ptrcast(cx, gv, llunitty);
C_struct(~[p, sz])
}
_ => cx.sess.span_bug(e.span,
~"bad const-slice expr")
_ => cx.sess.span_bug(e.span, "bad const-slice expr")
}
}
ast::expr_path(pth) => {
Expand Down Expand Up @@ -520,8 +513,7 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
C_null(llty)
}
_ => {
cx.sess.span_bug(e.span, ~"expected a const, fn, \
struct, or variant def")
cx.sess.span_bug(e.span, "expected a const, fn, struct, or variant def")
}
}
}
Expand All @@ -542,13 +534,12 @@ fn const_expr_unadjusted(cx: @CrateContext, e: @ast::expr) -> ValueRef {
adt::trans_const(cx, repr, vinfo.disr_val,
args.map(|a| const_expr(cx, *a)))
}
_ => cx.sess.span_bug(e.span, ~"expected a struct or \
variant def")
_ => cx.sess.span_bug(e.span, "expected a struct or variant def")
}
}
ast::expr_paren(e) => { return const_expr(cx, e); }
_ => cx.sess.span_bug(e.span,
~"bad constant expression type in consts::const_expr")
"bad constant expression type in consts::const_expr")
};
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/datum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,8 +761,8 @@ pub impl Datum {
match self.try_deref(bcx, expr.id, derefs, false) {
(Some(lvres), bcx) => DatumBlock { bcx: bcx, datum: lvres },
(None, _) => {
bcx.ccx().sess.span_bug(
expr.span, ~"Cannot deref this expression");
bcx.ccx().sess.span_bug(expr.span,
"Cannot deref this expression");
}
}
}
Expand Down
23 changes: 9 additions & 14 deletions src/librustc/middle/trans/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
}
},
ty::ty_enum(_did, ref _substs) => {
cx.sess.span_bug(span, ~"debuginfo for enum NYI")
cx.sess.span_bug(span, "debuginfo for enum NYI")
}
ty::ty_box(ref mt) | ty::ty_uniq(ref mt) => {
let boxed = create_ty(cx, mt.ty, span);
Expand All @@ -782,18 +782,18 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
create_pointer_type(cx, t, span, pointee)
},
ty::ty_rptr(ref _region, ref _mt) => {
cx.sess.span_bug(span, ~"debuginfo for rptr NYI")
cx.sess.span_bug(span, "debuginfo for rptr NYI")
},
ty::ty_bare_fn(ref barefnty) => {
let inputs = do barefnty.sig.inputs.map |a| { a.ty };
let output = barefnty.sig.output;
create_fn_ty(cx, t, inputs, output, span)
},
ty::ty_closure(ref _closurety) => {
cx.sess.span_bug(span, ~"debuginfo for closure NYI")
cx.sess.span_bug(span, "debuginfo for closure NYI")
},
ty::ty_trait(_did, ref _substs, ref _vstore, _) => {
cx.sess.span_bug(span, ~"debuginfo for trait NYI")
cx.sess.span_bug(span, "debuginfo for trait NYI")
},
ty::ty_struct(did, ref substs) => {
let fields = ty::struct_fields(cx.tcx, did, substs);
Expand Down Expand Up @@ -860,14 +860,12 @@ pub fn create_local_var(bcx: block, local: @ast::local)
let llptr = match bcx.fcx.lllocals.find(&local.node.id) {
option::Some(&local_mem(v)) => v,
option::Some(_) => {
bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
something weird");
bcx.tcx().sess.span_bug(local.span, "local is bound to something weird");
}
option::None => {
match *bcx.fcx.lllocals.get(&local.node.pat.id) {
local_imm(v) => v,
_ => bcx.tcx().sess.span_bug(local.span, ~"local is bound to \
something weird")
_ => bcx.tcx().sess.span_bug(local.span, "local is bound to something weird")
}
}
};
Expand Down Expand Up @@ -966,8 +964,7 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
ast::item_fn(ref decl, _, _, _, _) => {
(item.ident, decl.output, item.id)
}
_ => fcx.ccx.sess.span_bug(item.span, ~"create_function: item \
bound to non-function")
_ => fcx.ccx.sess.span_bug(item.span, "create_function: item bound to non-function")
}
}
ast_map::node_method(method, _, _) => {
Expand All @@ -979,12 +976,10 @@ pub fn create_function(fcx: fn_ctxt) -> @Metadata<SubProgramMetadata> {
((dbg_cx.names)(~"fn"), decl.output, expr.id)
}
_ => fcx.ccx.sess.span_bug(expr.span,
~"create_function: \
expected an expr_fn_block here")
"create_function: expected an expr_fn_block here")
}
}
_ => fcx.ccx.sess.bug(~"create_function: unexpected \
sort of node")
_ => fcx.ccx.sess.bug("create_function: unexpected sort of node")
};

debug!("%?", ident);
Expand Down
11 changes: 5 additions & 6 deletions src/librustc/middle/trans/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
}
_ => {
bcx.tcx().sess.span_bug(expr.span,
~"expr_cast of non-trait");
"expr_cast of non-trait");
}
}
}
Expand All @@ -700,8 +700,7 @@ fn trans_rvalue_dps_unadjusted(bcx: block, expr: @ast::expr,
_ => {
bcx.tcx().sess.span_bug(
expr.span,
fmt!("trans_rvalue_dps_unadjusted reached \
fall-through case: %?",
fmt!("trans_rvalue_dps_unadjusted reached fall-through case: %?",
expr.node));
}
}
Expand Down Expand Up @@ -1202,7 +1201,7 @@ fn trans_rec_or_struct(bcx: block,
}
None => {
tcx.sess.span_bug(field.span,
~"Couldn't find field in struct type")
"Couldn't find field in struct type")
}
}
};
Expand Down Expand Up @@ -1478,15 +1477,15 @@ fn trans_eager_binop(bcx: block,
} else {
if !ty::type_is_scalar(rhs_t) {
bcx.tcx().sess.span_bug(binop_expr.span,
~"non-scalar comparison");
"non-scalar comparison");
}
let cmpr = base::compare_scalar_types(bcx, lhs, rhs, rhs_t, op);
bcx = cmpr.bcx;
ZExt(bcx, cmpr.val, T_i8())
}
}
_ => {
bcx.tcx().sess.span_bug(binop_expr.span, ~"unexpected binop");
bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ pub fn trans_intrinsic(ccx: @CrateContext,
_ => {
// Could we make this an enum rather than a string? does it get
// checked earlier?
ccx.sess.span_bug(item.span, ~"unknown intrinsic");
ccx.sess.span_bug(item.span, "unknown intrinsic");
}
}
build_return(bcx);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/monomorphize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
// causing an infinite expansion.
if depth > 30 {
ccx.sess.span_fatal(
span, ~"overly deep expansion of inlined function");
span, "overly deep expansion of inlined function");
}
ccx.monomorphizing.insert(fn_id, depth + 1);

Expand Down
10 changes: 6 additions & 4 deletions src/librustc/middle/trans/reachable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ fn traverse_inline_body(cx: &ctx, body: &blk) {
expr_path(_) => {
match cx.tcx.def_map.find(&e.id) {
Some(&d) => {
traverse_def_id(cx, def_id_of_def(d));
traverse_def_id(cx, def_id_of_def(d));
}
None => cx.tcx.sess.span_bug(e.span, fmt!("Unbound node \
id %? while traversing %s", e.id,
expr_to_str(e, cx.tcx.sess.intr())))
None => cx.tcx.sess.span_bug(
e.span,
fmt!("Unbound node id %? while traversing %s",
e.id,
expr_to_str(e, cx.tcx.sess.intr())))
}
}
expr_field(_, _, _) => {
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/middle/trans/tvec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ pub fn write_content(bcx: block,
}
_ => {
bcx.tcx().sess.span_bug(content_expr.span,
~"Unexpected evec content");
"Unexpected evec content");
}
}
}
Expand Down Expand Up @@ -503,7 +503,7 @@ pub fn elements_required(bcx: block, content_expr: @ast::expr) -> uint {
ty::eval_repeat_count(bcx.tcx(), count_expr)
}
_ => bcx.tcx().sess.span_bug(content_expr.span,
~"Unexpected evec content")
"Unexpected evec content")
}
}

Expand Down
Loading

0 comments on commit 35b91e2

Please sign in to comment.