Skip to content
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

Use static strings #6174

Merged
merged 2 commits into from
May 2, 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
28 changes: 14 additions & 14 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,16 @@ pub struct Session_ {
pub type Session = @Session_;

pub impl Session_ {
fn span_fatal(@self, sp: span, msg: ~str) -> ! {
fn span_fatal(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_fatal(sp, msg)
}
fn fatal(@self, msg: ~str) -> ! {
fn fatal(@self, msg: &str) -> ! {
self.span_diagnostic.handler().fatal(msg)
}
fn span_err(@self, sp: span, msg: ~str) {
fn span_err(@self, sp: span, msg: &str) {
self.span_diagnostic.span_err(sp, msg)
}
fn err(@self, msg: ~str) {
fn err(@self, msg: &str) {
self.span_diagnostic.handler().err(msg)
}
fn has_errors(@self) -> bool {
Expand All @@ -193,31 +193,31 @@ pub impl Session_ {
fn abort_if_errors(@self) {
self.span_diagnostic.handler().abort_if_errors()
}
fn span_warn(@self, sp: span, msg: ~str) {
fn span_warn(@self, sp: span, msg: &str) {
self.span_diagnostic.span_warn(sp, msg)
}
fn warn(@self, msg: ~str) {
fn warn(@self, msg: &str) {
self.span_diagnostic.handler().warn(msg)
}
fn span_note(@self, sp: span, msg: ~str) {
fn span_note(@self, sp: span, msg: &str) {
self.span_diagnostic.span_note(sp, msg)
}
fn note(@self, msg: ~str) {
fn note(@self, msg: &str) {
self.span_diagnostic.handler().note(msg)
}
fn span_bug(@self, sp: span, msg: ~str) -> ! {
fn span_bug(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_bug(sp, msg)
}
fn bug(@self, msg: ~str) -> ! {
fn bug(@self, msg: &str) -> ! {
self.span_diagnostic.handler().bug(msg)
}
fn span_unimpl(@self, sp: span, msg: ~str) -> ! {
fn span_unimpl(@self, sp: span, msg: &str) -> ! {
self.span_diagnostic.span_unimpl(sp, msg)
}
fn unimpl(@self, msg: ~str) -> ! {
fn unimpl(@self, msg: &str) -> ! {
self.span_diagnostic.handler().unimpl(msg)
}
fn span_lint_level(@self, level: lint::level, sp: span, msg: ~str) {
fn span_lint_level(@self, level: lint::level, sp: span, msg: &str) {
match level {
lint::allow => { },
lint::warn => self.span_warn(sp, msg),
Expand All @@ -230,7 +230,7 @@ pub impl Session_ {
expr_id: ast::node_id,
item_id: ast::node_id,
span: span,
msg: ~str) {
msg: &str) {
let level = lint::get_lint_settings_level(
self.lint_settings, lint_mode, expr_id, item_id);
self.span_lint_level(level, span, msg);
Expand Down
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