Skip to content

Commit

Permalink
Use static strings
Browse files Browse the repository at this point in the history
  • Loading branch information
sanxiyn committed May 2, 2013
1 parent 0c34cab commit 4294aed
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 132 deletions.
30 changes: 15 additions & 15 deletions src/librustc/middle/check_const.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ pub fn check_expr(sess: Session,
expr_unary(deref, _) => { }
expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
sess.span_err(e.span,
~"disallowed operator in constant expression");
"disallowed operator in constant expression");
return;
}
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 \
sess.span_err(e.span, "user-defined operators are not \
allowed in constant expressions");
}
}
Expand All @@ -118,8 +118,8 @@ pub fn check_expr(sess: Session,
// a path in trans::callee that only works in block contexts.
if pth.types.len() != 0 {
sess.span_err(
e.span, ~"paths in constants may only refer to \
items without type parameters");
e.span, "paths in constants may only refer to \
items without type parameters");
}
match def_map.find(&e.id) {
Some(&def_const(_)) |
Expand All @@ -131,11 +131,11 @@ pub fn check_expr(sess: Session,
debug!("(checking const) found bad def: %?", def);
sess.span_err(
e.span,
fmt!("paths in constants may only refer to \
constants or functions"));
"paths in constants may only refer to \
constants or functions");
}
None => {
sess.span_bug(e.span, ~"unbound path in const?!");
sess.span_bug(e.span, "unbound path in const?!");
}
}
}
Expand All @@ -146,8 +146,8 @@ pub fn check_expr(sess: Session,
_ => {
sess.span_err(
e.span,
~"function calls in constants are limited to \
struct and enum constructors");
"function calls in constants are limited to \
struct and enum constructors");
}
}
}
Expand All @@ -163,12 +163,12 @@ pub fn check_expr(sess: Session,
expr_addr_of(*) => {
sess.span_err(
e.span,
~"borrowed pointers in constants may only refer to \
immutable values");
"borrowed pointers in constants may only refer to \
immutable values");
}
_ => {
sess.span_err(e.span,
~"constant contains unimplemented expression type");
"constant contains unimplemented expression type");
return;
}
}
Expand All @@ -178,14 +178,14 @@ pub fn check_expr(sess: Session,
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");
sess.span_err(e.span, "literal out of range for its type");
}
}
}
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");
sess.span_err(e.span, "literal out of range for its type");
}
}
_ => ()
Expand Down Expand Up @@ -224,7 +224,7 @@ pub fn check_item_recursion(sess: Session,

fn visit_item(it: @item, env: env, v: visit::vt<env>) {
if env.idstack.contains(&(it.id)) {
env.sess.span_fatal(env.root_it.span, ~"recursive constant");
env.sess.span_fatal(env.root_it.span, "recursive constant");
}
env.idstack.push(it.id);
visit::visit_item(it, env, v);
Expand Down
6 changes: 3 additions & 3 deletions src/librustc/middle/check_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,17 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
}
expr_break(_) => {
if !cx.in_loop {
tcx.sess.span_err(e.span, ~"`break` outside of loop");
tcx.sess.span_err(e.span, "`break` outside of loop");
}
}
expr_again(_) => {
if !cx.in_loop {
tcx.sess.span_err(e.span, ~"`again` outside of loop");
tcx.sess.span_err(e.span, "`again` outside of loop");
}
}
expr_ret(oe) => {
if !cx.can_ret {
tcx.sess.span_err(e.span, ~"`return` in block function");
tcx.sess.span_err(e.span, "`return` in block function");
}
visit::visit_expr_opt(oe, cx, v);
}
Expand Down
28 changes: 14 additions & 14 deletions src/librustc/middle/check_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, s: (), v: visit::vt<()>) {
}
let arms = vec::concat(arms.filter_mapped(unguarded_pat));
if arms.is_empty() {
cx.tcx.sess.span_err(ex.span, ~"non-exhaustive patterns");
cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns");
} else {
check_exhaustive(cx, ex.span, arms);
}
Expand All @@ -111,7 +111,7 @@ pub fn check_arms(cx: @MatchCheckCtxt, arms: &[arm]) {
let v = ~[*pat];
match is_useful(cx, &seen, v) {
not_useful => {
cx.tcx.sess.span_err(pat.span, ~"unreachable pattern");
cx.tcx.sess.span_err(pat.span, "unreachable pattern");
}
_ => ()
}
Expand Down Expand Up @@ -685,7 +685,7 @@ pub fn check_local(cx: @MatchCheckCtxt,
visit::visit_local(loc, s, v);
if is_refutable(cx, loc.node.pat) {
cx.tcx.sess.span_err(loc.node.pat.span,
~"refutable pattern in local binding");
"refutable pattern in local binding");
}

// Check legality of move bindings.
Expand All @@ -708,7 +708,7 @@ pub fn check_fn(cx: @MatchCheckCtxt,
for decl.inputs.each |input| {
if is_refutable(cx, input.pat) {
cx.tcx.sess.span_err(input.pat.span,
~"refutable pattern in function argument");
"refutable pattern in function argument");
}
}
}
Expand Down Expand Up @@ -780,24 +780,24 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
if sub.is_some() {
tcx.sess.span_err(
p.span,
~"cannot bind by-move with sub-bindings");
"cannot bind by-move with sub-bindings");
} else if has_guard {
tcx.sess.span_err(
p.span,
~"cannot bind by-move into a pattern guard");
"cannot bind by-move into a pattern guard");
} else if by_ref_span.is_some() {
tcx.sess.span_err(
p.span,
~"cannot bind by-move and by-ref \
in the same pattern");
"cannot bind by-move and by-ref \
in the same pattern");
tcx.sess.span_note(
by_ref_span.get(),
~"by-ref binding occurs here");
"by-ref binding occurs here");
} else if is_lvalue {
tcx.sess.span_err(
p.span,
~"cannot bind by-move when \
matching an lvalue");
"cannot bind by-move when \
matching an lvalue");
}
};

Expand Down Expand Up @@ -837,9 +837,9 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
{
cx.tcx.sess.span_err(
pat.span,
~"by-move pattern \
bindings may not occur \
behind @ or & bindings");
"by-move pattern \
bindings may not occur \
behind @ or & bindings");
}

match sub {
Expand Down
42 changes: 21 additions & 21 deletions src/librustc/middle/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,21 +97,21 @@ fn check_struct_safe_for_destructor(cx: Context,
});
if !ty::type_is_owned(cx.tcx, struct_ty) {
cx.tcx.sess.span_err(span,
~"cannot implement a destructor on a struct \
that is not Owned");
"cannot implement a destructor on a struct \
that is not Owned");
cx.tcx.sess.span_note(span,
~"use \"#[unsafe_destructor]\" on the \
implementation to force the compiler to \
allow this");
"use \"#[unsafe_destructor]\" on the \
implementation to force the compiler to \
allow this");
}
} else {
cx.tcx.sess.span_err(span,
~"cannot implement a destructor on a struct \
with type parameters");
"cannot implement a destructor on a struct \
with type parameters");
cx.tcx.sess.span_note(span,
~"use \"#[unsafe_destructor]\" on the \
implementation to force the compiler to \
allow this");
"use \"#[unsafe_destructor]\" on the \
implementation to force the compiler to \
allow this");
}
}

Expand Down Expand Up @@ -143,10 +143,10 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
}
_ => {
cx.tcx.sess.span_bug(self_type.span,
~"the self type for \
the Drop trait \
impl is not a \
path");
"the self type for \
the Drop trait \
impl is not a \
path");
}
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ fn with_appropriate_checker(cx: Context, id: node_id, b: &fn(check_fn)) {
fn check_for_bare(cx: Context, fv: @freevar_entry) {
cx.tcx.sess.span_err(
fv.span,
~"attempted dynamic environment capture");
"attempted dynamic environment capture");
}

let fty = ty::node_id_to_type(cx.tcx, id);
Expand Down Expand Up @@ -409,7 +409,7 @@ fn check_imm_free_var(cx: Context, def: def, sp: span) {
if is_mutbl {
cx.tcx.sess.span_err(
sp,
~"mutable variables cannot be implicitly captured");
"mutable variables cannot be implicitly captured");
}
}
def_arg(*) => { /* ok */ }
Expand Down Expand Up @@ -451,12 +451,12 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
if !ty::type_is_durable(tcx, ty) {
match ty::get(ty).sty {
ty::ty_param(*) => {
tcx.sess.span_err(sp, ~"value may contain borrowed \
pointers; use `'static` bound");
tcx.sess.span_err(sp, "value may contain borrowed \
pointers; use `'static` bound");
}
_ => {
tcx.sess.span_err(sp, ~"value may contain borrowed \
pointers");
tcx.sess.span_err(sp, "value may contain borrowed \
pointers");
}
}
false
Expand Down Expand Up @@ -581,7 +581,7 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) {
if !ty::type_is_owned(cx.tcx, source_ty) {
cx.tcx.sess.span_err(
target.span,
~"uniquely-owned trait objects must be sendable");
"uniquely-owned trait objects must be sendable");
}
}
_ => {} // Nothing to do.
Expand Down
Loading

5 comments on commit 4294aed

@bors
Copy link
Contributor

@bors bors commented on 4294aed May 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from brson
at sanxiyn@4294aed

@bors
Copy link
Contributor

@bors bors commented on 4294aed May 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging sanxiyn/rust/static-string = 4294aed into auto

@bors
Copy link
Contributor

@bors bors commented on 4294aed May 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sanxiyn/rust/static-string = 4294aed merged ok, testing candidate = b42ea7f

@bors
Copy link
Contributor

@bors bors commented on 4294aed May 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 4294aed May 2, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = b42ea7f

Please sign in to comment.