提交 4294aed0 编写于 作者: S Seo Sanghyeon

Use static strings

上级 0c34cab3
......@@ -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");
}
}
......@@ -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(_)) |
......@@ -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?!");
}
}
}
......@@ -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");
}
}
}
......@@ -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;
}
}
......@@ -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");
}
}
_ => ()
......@@ -224,7 +224,7 @@ struct env {
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);
......
......@@ -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);
}
......
......@@ -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);
}
......@@ -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");
}
_ => ()
}
......@@ -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.
......@@ -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");
}
}
}
......@@ -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");
}
};
......@@ -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 {
......
......@@ -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");
}
}
......@@ -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");
}
}
}
......@@ -193,7 +193,7 @@ fn check_for_block(_cx: Context, _fv: @freevar_entry) {
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);
......@@ -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 */ }
......@@ -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
......@@ -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.
......
......@@ -338,14 +338,14 @@ fn with_lint_attrs(&self, attrs: ~[ast::attribute], f: &fn(Context)) {
_ => {
self.sess.span_err(
meta.span,
~"malformed lint attribute");
"malformed lint attribute");
}
}
}
}
_ => {
self.sess.span_err(meta.span,
~"malformed lint attribute");
"malformed lint attribute");
}
}
}
......@@ -485,8 +485,8 @@ fn check_item_while_true(cx: ty::ctxt, it: @ast::item) {
cx.sess.span_lint(
while_true, e.id, it.id,
e.span,
~"denote infinite loops \
with loop { ... }");
"denote infinite loops \
with loop { ... }");
}
_ => ()
}
......@@ -603,7 +603,7 @@ fn is_comparison(binop: ast::binop) -> bool {
&& !check_limits(cx, *binop, l, r) {
cx.sess.span_lint(
type_limits, e.id, it.id, e.span,
~"comparison is useless due to type limits");
"comparison is useless due to type limits");
}
}
_ => ()
......@@ -630,7 +630,7 @@ fn check_item_default_methods(cx: ty::ctxt, item: @ast::item) {
item.id,
item.id,
item.span,
~"default methods are experimental");
"default methods are experimental");
}
}
}
......@@ -649,7 +649,7 @@ fn check_item_deprecated_mutable_fields(cx: ty::ctxt, item: @ast::item) {
item.id,
item.id,
field.span,
~"mutable fields are deprecated");
"mutable fields are deprecated");
}
ast::named_field(*) | ast::unnamed_field => {}
}
......@@ -672,14 +672,14 @@ fn check_foreign_fn(cx: ty::ctxt, fn_id: ast::node_id,
cx.sess.span_lint(
ctypes, id, fn_id,
ty.span,
~"found rust type `int` in foreign module, while \
"found rust type `int` in foreign module, while \
libc::c_int or libc::c_long should be used");
}
ast::def_prim_ty(ast::ty_uint(ast::ty_u)) => {
cx.sess.span_lint(
ctypes, id, fn_id,
ty.span,
~"found rust type `uint` in foreign module, while \
"found rust type `uint` in foreign module, while \
libc::c_uint or libc::c_ulong should be used");
}
_ => ()
......@@ -795,7 +795,7 @@ fn check_item_path_statement(cx: ty::ctxt, it: @ast::item) {
cx.sess.span_lint(
path_statement, id, it.id,
s.span,
~"path statement with no effect");
"path statement with no effect");
}
_ => ()
}
......@@ -835,8 +835,8 @@ fn check_case(cx: ty::ctxt, ident: ast::ident,
if !is_camel_case(cx, ident) {
cx.sess.span_lint(
non_camel_case_types, expr_id, item_id, span,
~"type, variant, or trait should have \
a camel case identifier");
"type, variant, or trait should have \
a camel case identifier");
}
}
......@@ -863,7 +863,7 @@ fn check_item_unused_unsafe(cx: ty::ctxt, it: @ast::item) {
if !cx.used_unsafe.contains(&blk.node.id) {
cx.sess.span_lint(unused_unsafe, blk.node.id, it.id,
blk.span,
~"unnecessary `unsafe` block");
"unnecessary `unsafe` block");
}
}
_ => ()
......@@ -888,9 +888,9 @@ fn check_item_unused_mut(tcx: ty::ctxt, it: @ast::item) {
}
if !used {
let msg = if bindings == 1 {
~"variable does not need to be mutable"
"variable does not need to be mutable"
} else {
~"variables do not need to be mutable"
"variables do not need to be mutable"
};
tcx.sess.span_lint(unused_mut, p.id, it.id, p.span, msg);
}
......
......@@ -359,7 +359,7 @@ fn captures(&mut self, expr: @expr) -> @~[CaptureInfo] {
match self.capture_info_map.find(&expr.id) {
Some(&caps) => caps,
None => {
self.tcx.sess.span_bug(expr.span, ~"no registered caps");
self.tcx.sess.span_bug(expr.span, "no registered caps");
}
}
}
......@@ -687,7 +687,7 @@ fn variable_from_def_map(&self, node_id: node_id,
}
None => {
self.tcx.sess.span_bug(
span, ~"Not present in def map")
span, "Not present in def map")
}
}
}
......@@ -804,15 +804,15 @@ fn find_loop_scope(&self, opt_label: Option<ident>, id: node_id, sp: span)
// to find with one
match self.tcx.def_map.find(&id) {
Some(&def_label(loop_id)) => loop_id,
_ => self.tcx.sess.span_bug(sp, ~"Label on break/loop \
doesn't refer to a loop")
_ => self.tcx.sess.span_bug(sp, "Label on break/loop \
doesn't refer to a loop")
},
None => {
// Vanilla 'break' or 'loop', so use the enclosing
// loop scope
let loop_scope = &mut *self.loop_scope;
if loop_scope.len() == 0 {
self.tcx.sess.span_bug(sp, ~"break outside loop");
self.tcx.sess.span_bug(sp, "break outside loop");
}
else {
// FIXME(#5275): this shouldn't have to be a method...
......@@ -994,7 +994,7 @@ fn propagate_through_stmt(&self, stmt: @stmt, succ: LiveNode)
}
stmt_mac(*) => {
self.tcx.sess.span_bug(stmt.span, ~"unexpanded macro");
self.tcx.sess.span_bug(stmt.span, "unexpanded macro");
}
}
}
......@@ -1164,7 +1164,7 @@ fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
match self.break_ln.find(&sc) {
Some(&b) => b,
None => self.tcx.sess.span_bug(expr.span,
~"Break to unknown label")
"Break to unknown label")
}
}
......@@ -1178,7 +1178,7 @@ fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
match self.cont_ln.find(&sc) {
Some(&b) => b,
None => self.tcx.sess.span_bug(expr.span,
~"Loop to unknown label")
"Loop to unknown label")
}
}
......@@ -1304,7 +1304,7 @@ fn propagate_through_expr(&self, expr: @expr, succ: LiveNode)
}
expr_mac(*) => {
self.tcx.sess.span_bug(expr.span, ~"unexpanded macro");
self.tcx.sess.span_bug(expr.span, "unexpanded macro");
}
}
}
......@@ -1618,10 +1618,10 @@ fn check_ret(@self, id: node_id, sp: span, _fk: &visit::fn_kind,
} else if ty::type_is_bot(t_ret) {
// for bot return types, not ok. Function should fail.
self.tcx.sess.span_err(
sp, ~"some control paths may return");
sp, "some control paths may return");
} else {
self.tcx.sess.span_err(
sp, ~"not all control paths return a value");
sp, "not all control paths return a value");
}
}
}
......@@ -1712,10 +1712,10 @@ fn check_for_reassignment(@self, ln: LiveNode, var: Variable,
None => {
self.tcx.sess.span_err(
span,
~"re-assignment of immutable variable");
"re-assignment of immutable variable");
self.tcx.sess.span_note(
orig_span,
~"prior assignment occurs here");
"prior assignment occurs here");
}
}
}
......
......@@ -928,7 +928,7 @@ fn cat_pattern(&self,
_ => {
self.tcx.sess.span_bug(
pat.span,
~"enum pattern didn't resolve to enum or struct");
"enum pattern didn't resolve to enum or struct");
}
}
}
......
......@@ -424,7 +424,7 @@ fn use_expr(&self,
MoveInWhole => {
self.tcx.sess.span_bug(
expr.span,
fmt!("Component mode can never be MoveInWhole"));
"Component mode can never be MoveInWhole");
}
}
}
......@@ -647,7 +647,7 @@ fn use_expr(&self,
expr_mac(*) => {
self.tcx.sess.span_bug(
expr.span,
~"macro expression remains after expansion");
"macro expression remains after expansion");
}
}
}
......
......@@ -99,8 +99,8 @@ pub fn check_crate(tcx: ty::ctxt,
parental_privacy == Public)
== Private {
tcx.sess.span_err(span,
~"can only dereference enums \
with a single, public variant");
"can only dereference enums \
with a single, public variant");
}
};
......@@ -121,8 +121,8 @@ pub fn check_crate(tcx: ty::ctxt,
tcx.sess.parse_sess.interner)));
}
None => {
tcx.sess.span_bug(span, ~"method not found in \
AST map?!");
tcx.sess.span_bug(span, "method not found in \
AST map?!");
}
}
};
......@@ -140,8 +140,8 @@ pub fn check_crate(tcx: ty::ctxt,
// Look up the enclosing impl.
if container_id.crate != local_crate {
tcx.sess.span_bug(span,
~"local method isn't in local \
impl?!");
"local method isn't in local \
impl?!");
}
match tcx.items.find(&container_id.node) {
......@@ -155,10 +155,10 @@ pub fn check_crate(tcx: ty::ctxt,
}
}
Some(_) => {
tcx.sess.span_bug(span, ~"impl wasn't an item?!");
tcx.sess.span_bug(span, "impl wasn't an item?!");
}
None => {
tcx.sess.span_bug(span, ~"impl wasn't in AST map?!");
tcx.sess.span_bug(span, "impl wasn't in AST map?!");
}
}
}
......@@ -185,8 +185,8 @@ pub fn check_crate(tcx: ty::ctxt,
tcx.sess.parse_sess.interner)));
}
None => {
tcx.sess.span_bug(span, ~"method not found in \
AST map?!");
tcx.sess.span_bug(span, "method not found in \
AST map?!");
}
}
};
......@@ -219,7 +219,7 @@ pub fn check_crate(tcx: ty::ctxt,
.interner)));
}
None => {
tcx.sess.span_bug(span, ~"item not found in AST map?!");
tcx.sess.span_bug(span, "item not found in AST map?!");
}
}
};
......@@ -333,10 +333,10 @@ pub fn check_crate(tcx: ty::ctxt,
match item.node {
item_trait(_, _, ref methods) => {
if method_num >= (*methods).len() {
tcx.sess.span_bug(span, ~"method \
number \
out of \
range?!");
tcx.sess.span_bug(span, "method \
number \
out of \
range?!");
}
match (*methods)[method_num] {
provided(method)
......@@ -363,20 +363,20 @@ pub fn check_crate(tcx: ty::ctxt,
}
}
_ => {
tcx.sess.span_bug(span, ~"trait wasn't \
actually a \
trait?!");
tcx.sess.span_bug(span, "trait wasn't \
actually a \
trait?!");
}
}
}
Some(_) => {
tcx.sess.span_bug(span, ~"trait wasn't an \
item?!");
tcx.sess.span_bug(span, "trait wasn't an \
item?!");
}
None => {
tcx.sess.span_bug(span, ~"trait item wasn't \
found in the AST \
map?!");
tcx.sess.span_bug(span, "trait item wasn't \
found in the AST \
map?!");
}
}
} else {
......@@ -465,8 +465,8 @@ pub fn check_crate(tcx: ty::ctxt,
match method_map.find(&expr.id) {
None => {
tcx.sess.span_bug(expr.span,
~"method call not in \
method map");
"method call not in \
method map");
}
Some(ref entry) => {
debug!("(privacy checking) checking \
......@@ -512,18 +512,18 @@ struct variant \
}
_ => {
tcx.sess.span_bug(expr.span,
~"resolve didn't \
map enum struct \
constructor to a \
variant def");
"resolve didn't \
map enum struct \
constructor to a \
variant def");
}
}
}
}
_ => {
tcx.sess.span_bug(expr.span, ~"struct expr \
didn't have \
struct type?!");
tcx.sess.span_bug(expr.span, "struct expr \
didn't have \
struct type?!");
}
}
}
......@@ -579,18 +579,18 @@ struct variant \
}
_ => {
tcx.sess.span_bug(pattern.span,
~"resolve didn't \
map enum struct \
pattern to a \
variant def");
"resolve didn't \
map enum struct \
pattern to a \
variant def");
}
}
}
}
_ => {
tcx.sess.span_bug(pattern.span,
~"struct pattern didn't have \
struct type?!");
"struct pattern didn't have \
struct type?!");
}
}
}
......
......@@ -320,7 +320,7 @@ fn ancestors_of(self: &RegionMaps, scope: ast::node_id)
pub fn parent_id(cx: ctxt, span: span) -> ast::node_id {
match cx.parent {
None => {
cx.sess.span_bug(span, ~"crate should not be parent here");
cx.sess.span_bug(span, "crate should not be parent here");
}
Some(parent_id) => {
parent_id
......
......@@ -3261,7 +3261,7 @@ pub fn expr_kind(tcx: ctxt,
ast::expr_mac(*) => {
tcx.sess.span_bug(
expr.span,
~"macro expression remains after expansion");
"macro expression remains after expansion");
}
}
}
......@@ -4242,27 +4242,27 @@ pub fn eval_repeat_count(tcx: ctxt, count_expr: @ast::expr) -> uint {
const_eval::const_uint(count) => return count as uint,
const_eval::const_float(count) => {
tcx.sess.span_err(count_expr.span,
~"expected signed or unsigned integer for \
repeat count but found float");
"expected signed or unsigned integer for \
repeat count but found float");
return count as uint;
}
const_eval::const_str(_) => {
tcx.sess.span_err(count_expr.span,
~"expected signed or unsigned integer for \
repeat count but found string");
"expected signed or unsigned integer for \
repeat count but found string");
return 0;
}
const_eval::const_bool(_) => {
tcx.sess.span_err(count_expr.span,
~"expected signed or unsigned integer for \
repeat count but found boolean");
"expected signed or unsigned integer for \
repeat count but found boolean");
return 0;
}
},
Err(*) => {
tcx.sess.span_err(count_expr.span,
~"expected constant integer for repeat count \
but found variable");
"expected constant integer for repeat count \
but found variable");
return 0;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册