提交 35b91e2f 编写于 作者: J Jeong YunWon

Use static strings

上级 d1f72202
......@@ -115,7 +115,7 @@ fn loan(&mut self,
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 {
......@@ -123,7 +123,7 @@ fn loan(&mut self,
// 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)
......@@ -188,7 +188,7 @@ fn loan(&mut self,
// 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");
}
}
}
......
......@@ -525,11 +525,11 @@ fn report(&self, err: bckerr) {
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);
}
......
......@@ -124,7 +124,7 @@ fn preserve(&self, cmt: cmt) -> bckres<PreserveCondition> {
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)
......
......@@ -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");
}
}
......
......@@ -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!");
}
};
......
......@@ -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")
}
}
},
......
......@@ -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");
}
}
}
......@@ -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),
......@@ -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) => {
......@@ -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) =>
......@@ -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;
......@@ -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])
}
......@@ -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");
}
}
});
......@@ -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) => {
......@@ -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) => {
......@@ -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")
}
}
}
......@@ -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")
};
}
}
......
......@@ -761,8 +761,8 @@ fn deref(&self, bcx: block,
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");
}
}
}
......
......@@ -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);
......@@ -782,7 +782,7 @@ 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 };
......@@ -790,10 +790,10 @@ fn create_ty(cx: @CrateContext, t: ty::t, span: span)
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);
......@@ -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")
}
}
};
......@@ -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, _, _) => {
......@@ -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);
......
......@@ -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");
}
}
}
......@@ -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));
}
}
......@@ -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")
}
}
};
......@@ -1478,7 +1477,7 @@ 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;
......@@ -1486,7 +1485,7 @@ fn trans_eager_binop(bcx: block,
}
}
_ => {
bcx.tcx().sess.span_bug(binop_expr.span, ~"unexpected binop");
bcx.tcx().sess.span_bug(binop_expr.span, "unexpected binop");
}
};
......
......@@ -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);
......
......@@ -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);
......
......@@ -170,11 +170,13 @@ fn traverse_expr<'a, 'b>(e: @expr, cx: &'b ctx<'a>,
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(_, _, _) => {
......
......@@ -469,7 +469,7 @@ pub fn write_content(bcx: block,
}
_ => {
bcx.tcx().sess.span_bug(content_expr.span,
~"Unexpected evec content");
"Unexpected evec content");
}
}
}
......@@ -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")
}
}
......
......@@ -291,10 +291,8 @@ fn mk_pointer<AC:AstConv,RS:region_scope + Copy + Durable>(
ty::vstore_fixed(*) => {
tcx.sess.span_err(
path.span,
~"@trait, ~trait or &trait \
are the only supported \
forms of casting-to-\
trait");
"@trait, ~trait or &trait are the only supported \
forms of casting-to-trait");
ty::BoxTraitStore
}
};
......@@ -321,7 +319,7 @@ fn check_path_args(tcx: ty::ctxt,
if path.types.len() > 0u {
tcx.sess.span_err(
path.span,
~"type parameters are not allowed on this type");
"type parameters are not allowed on this type");
}
}
......@@ -329,7 +327,7 @@ fn check_path_args(tcx: ty::ctxt,
if path.rp.is_some() {
tcx.sess.span_err(
path.span,
~"region parameters are not allowed on this type");
"region parameters are not allowed on this type");
}
}
}
......@@ -339,9 +337,8 @@ fn check_path_args(tcx: ty::ctxt,
match tcx.ast_ty_to_ty_cache.find(&ast_ty.id) {
Some(&ty::atttce_resolved(ty)) => return ty,
Some(&ty::atttce_unresolved) => {
tcx.sess.span_fatal(ast_ty.span, ~"illegal recursive type; \
insert an enum in the cycle, \
if this is desired");
tcx.sess.span_fatal(ast_ty.span, "illegal recursive type; \
insert an enum in the cycle, if this is desired");
}
None => { /* go on */ }
}
......@@ -359,11 +356,9 @@ fn check_path_args(tcx: ty::ctxt,
|tmt| ty::mk_uniq(tcx, tmt))
}
ast::ty_vec(ref mt) => {
tcx.sess.span_err(ast_ty.span,
~"bare `[]` is not a type");
tcx.sess.span_err(ast_ty.span, "bare `[]` is not a type");
// return /something/ so they can at least get more errors
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt),
ty::vstore_uniq)
ty::mk_evec(tcx, ast_mt_to_mt(self, rscope, mt), ty::vstore_uniq)
}
ast::ty_ptr(ref mt) => {
ty::mk_ptr(tcx, ast_mt_to_mt(self, rscope, mt))
......@@ -434,7 +429,7 @@ fn check_path_args(tcx: ty::ctxt,
}
ast::ty_str => {
tcx.sess.span_err(ast_ty.span,
~"bare `str` is not a type");
"bare `str` is not a type");
// return /something/ so they can at least get more errors
ty::mk_estr(tcx, ty::vstore_uniq)
}
......@@ -454,7 +449,7 @@ fn check_path_args(tcx: ty::ctxt,
}
_ => {
tcx.sess.span_fatal(ast_ty.span,
~"found type name used as a variable");
"found type name used as a variable");
}
}
}
......@@ -470,7 +465,7 @@ fn check_path_args(tcx: ty::ctxt,
ty::vstore_fixed(i as uint)),
_ => {
tcx.sess.span_fatal(
ast_ty.span, ~"expected constant expr for vector length");
ast_ty.span, "expected constant expr for vector length");
}
}
}
......@@ -489,11 +484,11 @@ fn check_path_args(tcx: ty::ctxt,
// routine.
self.tcx().sess.span_bug(
ast_ty.span,
~"found `ty_infer` in unexpected place");
"found `ty_infer` in unexpected place");
}
ast::ty_mac(_) => {
tcx.sess.span_bug(ast_ty.span,
~"found `ty_mac` in unexpected place");
"found `ty_mac` in unexpected place");
}
};
......
......@@ -204,8 +204,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
if arg_len > 0 {
// N-ary variant.
if arg_len != subpats_len {
let s = fmt!("this pattern has %u field%s, but the corresponding \
%s has %u field%s",
let s = fmt!("this pattern has %u field%s, but the corresponding %s has %u field%s",
subpats_len,
if subpats_len == 1u { ~"" } else { ~"s" },
kind_name,
......@@ -223,13 +222,12 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: @ast::Path,
}
}
} else if subpats_len > 0 {
tcx.sess.span_err
(pat.span, fmt!("this pattern has %u field%s, but the \
corresponding %s has no fields",
subpats_len,
if subpats_len == 1u { ~"" }
else { ~"s" },
kind_name));
tcx.sess.span_err(pat.span,
fmt!("this pattern has %u field%s, but the corresponding %s has no \
fields",
subpats_len,
if subpats_len == 1u { "" } else { "s" },
kind_name));
error_happened = true;
}
......@@ -319,20 +317,19 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::node_id, span: span,
Some(&ast::def_struct(*)) | Some(&ast::def_variant(*)) => {
let name = pprust::path_to_str(path, tcx.sess.intr());
tcx.sess.span_err(span,
fmt!("mismatched types: expected `%s` but \
found `%s`",
fmt!("mismatched types: expected `%s` but found `%s`",
fcx.infcx().ty_to_str(expected),
name));
}
_ => {
tcx.sess.span_bug(span, ~"resolve didn't write in class");
tcx.sess.span_bug(span, "resolve didn't write in class");
}
}
// Forbid pattern-matching structs with destructors.
if ty::has_dtor(tcx, class_id) {
tcx.sess.span_err(span, ~"deconstructing struct not allowed in \
pattern (it has a destructor)");
tcx.sess.span_err(span, "deconstructing struct not allowed in pattern \
(it has a destructor)");
}
check_struct_pat_fields(pcx, span, path, fields, class_fields, class_id,
......@@ -370,7 +367,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
name));
}
_ => {
tcx.sess.span_bug(span, ~"resolve didn't write in variant");
tcx.sess.span_bug(span, "resolve didn't write in variant");
}
}
}
......@@ -404,10 +401,9 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
{
// no-op
} else if !ty::type_is_numeric(b_ty) {
tcx.sess.span_err(pat.span, ~"non-numeric type used in range");
tcx.sess.span_err(pat.span, "non-numeric type used in range");
} else if !valid_range_bounds(fcx.ccx, begin, end) {
tcx.sess.span_err(begin.span, ~"lower range bound must be less \
than upper");
tcx.sess.span_err(begin.span, "lower range bound must be less than upper");
}
fcx.write_ty(pat.id, b_ty);
}
......@@ -476,9 +472,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
}
_ => {
tcx.sess.span_err(pat.span,
fmt!("mismatched types: expected `%s` \
but found struct",
fcx.infcx().ty_to_str(expected)));
fmt!("mismatched types: expected `%s` but found struct",
fcx.infcx().ty_to_str(expected)));
error_happened = true;
}
}
......
......@@ -872,7 +872,7 @@ fn consider_candidates(&self,
if relevant_candidates.len() > 1 {
self.tcx().sess.span_err(
self.expr.span,
~"multiple applicable methods in scope");
"multiple applicable methods in scope");
for uint::range(0, relevant_candidates.len()) |idx| {
self.report_candidate(idx, &relevant_candidates[idx].origin);
}
......@@ -983,12 +983,12 @@ fn confirm_candidate(&self,
} else if num_method_tps == 0u {
tcx.sess.span_err(
self.expr.span,
~"this method does not take type parameters");
"this method does not take type parameters");
self.fcx.infcx().next_ty_vars(num_method_tps)
} else if num_supplied_tps != num_method_tps {
tcx.sess.span_err(
self.expr.span,
~"incorrect number of type \
"incorrect number of type \
parameters given for this method");
self.fcx.infcx().next_ty_vars(num_method_tps)
} else {
......@@ -1082,14 +1082,14 @@ fn enforce_trait_instance_limitations(&self,
if ty::type_has_self(method_fty) {
self.tcx().sess.span_err(
self.expr.span,
~"cannot call a method whose type contains a \
self-type through a boxed trait");
"cannot call a method whose type contains a \
self-type through a boxed trait");
}
if candidate.method_ty.generics.has_type_params() {
self.tcx().sess.span_err(
self.expr.span,
~"cannot call a generic method through a boxed trait");
"cannot call a generic method through a boxed trait");
}
}
......@@ -1109,7 +1109,7 @@ fn enforce_drop_trait_limitations(&self, candidate: &Candidate) {
if bad {
self.tcx().sess.span_err(self.expr.span,
~"explicit call to destructor");
"explicit call to destructor");
}
}
......
......@@ -542,17 +542,15 @@ pub fn check_no_duplicate_fields(tcx: ty::ctxt,
let (id, sp) = *p;
let orig_sp = field_names.find(&id).map_consume(|x| *x);
match orig_sp {
Some(orig_sp) => {
tcx.sess.span_err(sp, fmt!("Duplicate field \
name %s in record type declaration",
*tcx.sess.str_of(id)));
tcx.sess.span_note(orig_sp, ~"First declaration of \
this field occurred here");
break;
}
None => {
field_names.insert(id, sp);
}
Some(orig_sp) => {
tcx.sess.span_err(sp, fmt!("Duplicate field name %s in record type declaration",
*tcx.sess.str_of(id)));
tcx.sess.span_note(orig_sp, "First declaration of this field occurred here");
break;
}
None => {
field_names.insert(id, sp);
}
}
}
}
......@@ -1252,8 +1250,7 @@ fn check_argument_types(
ty::ty_rptr(_, mt) => formal_ty = mt.ty,
ty::ty_err => (),
_ => {
fcx.ccx.tcx.sess.span_bug(arg.span,
~"no ref");
fcx.ccx.tcx.sess.span_bug(arg.span, "no ref");
}
}
}
......@@ -1559,8 +1556,7 @@ fn check_user_binop(fcx: @mut FnCtxt,
match ty::get(lhs_resolved_t).sty {
ty::ty_bare_fn(_) | ty::ty_closure(_) => {
tcx.sess.span_note(
ex.span, ~"did you forget the `do` keyword \
for the call?");
ex.span, "did you forget the `do` keyword for the call?");
}
_ => ()
}
......@@ -1851,9 +1847,9 @@ fn check_struct_or_variant_fields(fcx: @mut FnCtxt,
tcx.sess.span_err(span,
fmt!("missing field%s: %s",
if missing_fields.len() == 1 {
~""
""
} else {
~"s"
"s"
},
str::connect(missing_fields, ~", ")));
}
......@@ -1901,7 +1897,7 @@ fn check_struct_constructor(fcx: @mut FnCtxt,
}
_ => {
tcx.sess.span_bug(span,
~"resolve didn't map this to a class");
"resolve didn't map this to a class");
}
}
} else {
......@@ -1989,7 +1985,7 @@ fn check_struct_enum_variant(fcx: @mut FnCtxt,
}
_ => {
tcx.sess.span_bug(span,
~"resolve didn't map this to an enum");
"resolve didn't map this to an enum");
}
}
} else {
......@@ -2201,7 +2197,7 @@ fn check_loop_body(fcx: @mut FnCtxt,
}
}
_ =>
tcx.sess.span_bug(expr.span, ~"vstore modifier on non-sequence")
tcx.sess.span_bug(expr.span, "vstore modifier on non-sequence")
};
fcx.write_ty(ev.id, typ);
fcx.write_ty(id, typ);
......@@ -2284,21 +2280,18 @@ fn check_loop_body(fcx: @mut FnCtxt,
ty::ty_enum(*) => {
tcx.sess.span_err(
expr.span,
~"can only dereference enums \
with a single variant which has a \
single argument");
"can only dereference enums with a single variant which \
has a single argument");
}
ty::ty_struct(*) => {
tcx.sess.span_err(
expr.span,
~"can only dereference structs with \
one anonymous field");
"can only dereference structs with one anonymous field");
}
_ => {
fcx.type_error_message(expr.span,
|actual| {
fmt!("type %s cannot be \
dereferenced", actual)
fmt!("type %s cannot be dereferenced", actual)
}, oprnd_t, None);
}
}
......@@ -2394,7 +2387,7 @@ fn check_loop_body(fcx: @mut FnCtxt,
result::Err(_) => {
tcx.sess.span_err(
expr.span,
~"`return;` in function returning non-nil");
"`return;` in function returning non-nil");
}
},
Some(e) => {
......@@ -2758,8 +2751,8 @@ fn types_compatible(fcx: @mut FnCtxt, sp: span,
variant_id, *fields);
}
_ => {
tcx.sess.span_bug(path.span, ~"structure constructor does \
not name a structure type");
tcx.sess.span_bug(path.span,
"structure constructor does not name a structure type");
}
}
}
......@@ -2961,7 +2954,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
}
_ => false
} {
fcx.ccx.tcx.sess.span_warn(s.span, ~"unreachable statement");
fcx.ccx.tcx.sess.span_warn(s.span, "unreachable statement");
warned = true;
}
if ty::type_is_bot(s_ty) {
......@@ -2982,7 +2975,7 @@ pub fn check_block_with_expected(fcx: @mut FnCtxt,
},
Some(e) => {
if any_bot && !warned {
fcx.ccx.tcx.sess.span_warn(e.span, ~"unreachable expression");
fcx.ccx.tcx.sess.span_warn(e.span, "unreachable expression");
}
check_expr_with_opt_hint(fcx, e, expected);
let ety = fcx.expr_ty(e);
......@@ -3073,8 +3066,8 @@ fn do_check(ccx: @mut CrateCtxt,
*disr_val = val as int;
}
Ok(_) => {
ccx.tcx.sess.span_err(e.span, ~"expected signed integer \
constant");
ccx.tcx.sess.span_err(e.span, "expected signed integer \
constant");
}
Err(ref err) => {
ccx.tcx.sess.span_err(e.span,
......@@ -3085,7 +3078,7 @@ fn do_check(ccx: @mut CrateCtxt,
}
if vec::contains(*disr_vals, &*disr_val) {
ccx.tcx.sess.span_err(v.span,
~"discriminator value already exists");
"discriminator value already exists");
}
disr_vals.push(*disr_val);
let ctor_ty = ty::node_id_to_type(ccx.tcx, v.node.id);
......@@ -3142,9 +3135,9 @@ fn do_check(ccx: @mut CrateCtxt,
_ => false
}
}) {
ccx.tcx.sess.span_err(sp, ~"illegal recursive enum type; \
wrap the inner value in a box to \
make it representable");
ccx.tcx.sess.span_err(sp,
"illegal recursive enum type; \
wrap the inner value in a box to make it representable");
}
// Check that it is possible to instantiate this enum:
......@@ -3205,26 +3198,25 @@ pub fn ty_param_bounds_and_ty_for_def(fcx: @mut FnCtxt,
ast::def_ty(_) |
ast::def_prim_ty(_) |
ast::def_ty_param(*)=> {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type");
}
ast::def_mod(*) | ast::def_foreign_mod(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found module");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found module");
}
ast::def_use(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found use");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found use");
}
ast::def_region(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found region");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found region");
}
ast::def_typaram_binder(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found type \
parameter");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found type parameter");
}
ast::def_label(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found label");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found label");
}
ast::def_self_ty(*) => {
fcx.ccx.tcx.sess.span_bug(sp, ~"expected value but found self ty");
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found self ty");
}
}
}
......@@ -3253,7 +3245,7 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
match tpt.generics.region_param {
None => { // ...but the type is not lifetime parameterized!
fcx.ccx.tcx.sess.span_err
(span, ~"this item is not region-parameterized");
(span, "this item is not region-parameterized");
None
}
Some(_) => { // ...and the type is lifetime parameterized, ok.
......@@ -3273,15 +3265,15 @@ pub fn instantiate_path(fcx: @mut FnCtxt,
fcx.infcx().next_ty_vars(ty_param_count)
} else if ty_param_count == 0 {
fcx.ccx.tcx.sess.span_err
(span, ~"this item does not take type parameters");
(span, "this item does not take type parameters");
fcx.infcx().next_ty_vars(ty_param_count)
} else if ty_substs_len > ty_param_count {
fcx.ccx.tcx.sess.span_err
(span, ~"too many type parameters provided for this item");
(span, "too many type parameters provided for this item");
fcx.infcx().next_ty_vars(ty_param_count)
} else if ty_substs_len < ty_param_count {
fcx.ccx.tcx.sess.span_err
(span, ~"not enough type parameters provided for this item");
(span, "not enough type parameters provided for this item");
fcx.infcx().next_ty_vars(ty_param_count)
} else {
pth.types.map(|aty| fcx.to_ty(*aty))
......
......@@ -490,13 +490,13 @@ fn constrain_auto_ref(rcx: @mut Rcx, expr: @ast::expr) {
// reporting an error would be the correct path.
tcx.sess.span_err(
expr.span,
~"lifetime of borrowed pointer does not include \
the expression being borrowed");
"lifetime of borrowed pointer does not include \
the expression being borrowed");
note_and_explain_region(
tcx,
~"lifetime of the borrowed pointer is",
"lifetime of the borrowed pointer is",
region,
~"");
"");
rcx.errors_reported += 1;
}
}
......@@ -522,17 +522,17 @@ fn constrain_free_variables(
result::Err(_) => {
tcx.sess.span_err(
freevar.span,
~"captured variable does not outlive the enclosing closure");
"captured variable does not outlive the enclosing closure");
note_and_explain_region(
tcx,
~"captured variable is valid for ",
"captured variable is valid for ",
en_region,
~"");
"");
note_and_explain_region(
tcx,
~"closure is valid for ",
"closure is valid for ",
region,
~"");
"");
}
}
}
......
......@@ -414,7 +414,7 @@ fn lookup_vtable(vcx: &VtableContext,
if !is_early {
vcx.tcx().sess.span_err(
location_info.span,
~"multiple applicable methods in scope");
"multiple applicable methods in scope");
}
return Some(/*bad*/copy found[0]);
}
......
......@@ -76,10 +76,8 @@ pub fn get_base_type(inference_context: @mut InferCtxt,
}
_ => {
inference_context.tcx.sess.span_fatal(span,
~"the type of this value \
must be known in order \
to determine the base \
type");
"the type of this value must be known in order \
to determine the base type");
}
}
......@@ -257,9 +255,8 @@ fn check_implementation(&self,
None => {
let session = self.crate_context.tcx.sess;
session.span_err(item.span,
~"no base type found for inherent \
implementation; implement a \
trait or new type instead");
"no base type found for inherent implementation; \
implement a trait or new type instead");
}
Some(_) => {
// Nothing to do.
......@@ -483,11 +480,9 @@ fn check_implementation_coherence_of(&self, trait_def_id: def_id) {
if self.polytypes_unify(polytype_a, polytype_b) {
let session = self.crate_context.tcx.sess;
session.span_err(self.span_of_impl(implementation_b),
~"conflicting implementations for a \
trait");
"conflicting implementations for a trait");
session.span_note(self.span_of_impl(implementation_a),
~"note conflicting implementation \
here");
"note conflicting implementation here");
}
}
}
......@@ -667,11 +662,9 @@ fn check_privileged_scopes(self, crate: @crate) {
// This is an error.
let session = self.crate_context.tcx.sess;
session.span_err(item.span,
~"cannot associate methods with \
a type outside the crate the \
type is defined in; define \
and implement a trait or new \
type instead");
"cannot associate methods with a type outside the \
crate the type is defined in; define and implement \
a trait or new type instead");
}
}
item_impl(_, Some(trait_ref), _, _) => {
......@@ -690,10 +683,8 @@ fn check_privileged_scopes(self, crate: @crate) {
if trait_def_id.crate != local_crate {
let session = self.crate_context.tcx.sess;
session.span_err(item.span,
~"cannot provide an \
extension implementation \
for a trait not defined \
in this crate");
"cannot provide an extension implementation \
for a trait not defined in this crate");
}
}
......@@ -765,7 +756,7 @@ pub fn ast_type_is_defined_in_local_crate(&self, original_type: @ast::Ty)
None => {
self.crate_context.tcx.sess.span_bug(
original_type.span,
~"resolve didn't resolve this type?!");
"resolve didn't resolve this type?!");
}
Some(&node_item(item, _)) => {
match item.node {
......@@ -849,8 +840,7 @@ fn add_provided_methods(all_methods: &mut ~[@MethodInfo],
}
_ => {
self.crate_context.tcx.sess.span_bug(item.span,
~"can't convert a \
non-impl to an impl");
"can't convert a non-impl to an impl");
}
}
}
......@@ -862,9 +852,8 @@ fn span_of_impl(&self, implementation: @Impl) -> span {
return item.span;
}
_ => {
self.crate_context.tcx.sess.bug(~"span_of_impl() called on \
something that wasn't an \
impl!");
self.crate_context.tcx.sess.bug("span_of_impl() called on something that \
wasn't an impl!");
}
}
}
......@@ -1045,17 +1034,16 @@ fn populate_destructor_table(&self) {
match tcx.items.find(&impl_info.did.node) {
Some(&ast_map::node_item(@ref item, _)) => {
tcx.sess.span_err((*item).span,
~"the Drop trait may only \
be implemented on \
structures");
"the Drop trait may only be implemented on \
structures");
}
_ => {
tcx.sess.bug(~"didn't find impl in ast map");
tcx.sess.bug("didn't find impl in ast map");
}
}
} else {
tcx.sess.bug(~"found external impl of Drop trait on \
something other than a struct");
tcx.sess.bug("found external impl of Drop trait on \
something other than a struct");
}
}
}
......
......@@ -151,7 +151,7 @@ fn get_trait_def(&self, id: ast::def_id) -> @ty::TraitDef {
fn ty_infer(&self, span: span) -> ty::t {
self.tcx.sess.span_bug(span,
~"found `ty_infer` in unexpected place");
"found `ty_infer` in unexpected place");
}
}
......@@ -416,8 +416,7 @@ pub fn ensure_supertraits(ccx: &CrateCtxt,
if ty_trait_refs.any(|other_trait| other_trait.def_id == trait_ref.def_id) {
// This means a trait inherited from the same supertrait more
// than once.
tcx.sess.span_err(sp, ~"Duplicate supertrait in trait \
declaration");
tcx.sess.span_err(sp, "Duplicate supertrait in trait declaration");
break;
} else {
ty_trait_refs.push(trait_ref);
......
......@@ -1587,9 +1587,9 @@ fn report_error_for_expanding_node(&mut self,
note_and_explain_region(
self.tcx,
~"first, the lifetime cannot outlive ",
"first, the lifetime cannot outlive ",
upper_bound.region,
~"...");
"...");
self.tcx.sess.span_note(
upper_bound.span,
......@@ -1597,9 +1597,9 @@ fn report_error_for_expanding_node(&mut self,
note_and_explain_region(
self.tcx,
~"but, the lifetime must be valid for ",
"but, the lifetime must be valid for ",
lower_bound.region,
~"...");
"...");
self.tcx.sess.span_note(
lower_bound.span,
......
......@@ -214,7 +214,7 @@ pub fn lookup_def_tcx(tcx: ty::ctxt, sp: span, id: ast::node_id) -> ast::def {
match tcx.def_map.find(&id) {
Some(&x) => x,
_ => {
tcx.sess.span_fatal(sp, ~"internal error looking up a definition")
tcx.sess.span_fatal(sp, "internal error looking up a definition")
}
}
}
......@@ -301,8 +301,7 @@ fn check_main_fn_ty(ccx: @mut CrateCtxt,
if ps.is_parameterized() => {
tcx.sess.span_err(
main_span,
~"main function is not allowed \
to have type parameters");
"main function is not allowed to have type parameters");
return;
}
_ => ()
......@@ -343,8 +342,7 @@ fn check_start_fn_ty(ccx: @mut CrateCtxt,
if ps.is_parameterized() => {
tcx.sess.span_err(
start_span,
~"start function is not allowed to have type \
parameters");
"start function is not allowed to have type parameters");
return;
}
_ => ()
......
......@@ -342,7 +342,7 @@ pub fn expr_to_str(cx: @ext_ctxt, expr: @ast::expr, err_msg: ~str) -> ~str {
pub fn expr_to_ident(cx: @ext_ctxt,
expr: @ast::expr,
err_msg: ~str) -> ast::ident {
err_msg: &str) -> ast::ident {
match expr.node {
ast::expr_path(p) => {
if vec::len(p.types) > 0u || vec::len(p.idents) != 1u {
......
......@@ -308,22 +308,22 @@ fn look_ahead(&self, distance: uint) -> token::Token {
}
return copy self.buffer[(*self.buffer_start + dist - 1) & 3].tok;
}
fn fatal(&self, m: ~str) -> ! {
fn fatal(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(*copy self.span, m)
}
fn span_fatal(&self, sp: span, m: ~str) -> ! {
fn span_fatal(&self, sp: span, m: &str) -> ! {
self.sess.span_diagnostic.span_fatal(sp, m)
}
fn span_note(&self, sp: span, m: ~str) {
fn span_note(&self, sp: span, m: &str) {
self.sess.span_diagnostic.span_note(sp, m)
}
fn bug(&self, m: ~str) -> ! {
fn bug(&self, m: &str) -> ! {
self.sess.span_diagnostic.span_bug(*copy self.span, m)
}
fn warn(&self, m: ~str) {
fn warn(&self, m: &str) {
self.sess.span_diagnostic.span_warn(*copy self.span, m)
}
fn span_err(&self, sp: span, m: ~str) {
fn span_err(&self, sp: span, m: &str) {
self.sess.span_diagnostic.span_err(sp, m)
}
fn abort_if_errors(&self) {
......@@ -2029,8 +2029,7 @@ fn parse_loop_expr(&self, opt_ident: Option<ast::ident>) -> @expr {
// This is a 'continue' expression
if opt_ident.is_some() {
self.span_err(*self.last_span,
~"a label may not be used with a `loop` \
expression");
"a label may not be used with a `loop` expression");
}
let lo = self.span.lo;
......@@ -2167,7 +2166,7 @@ fn parse_pat_vec_elements(
@ast::pat { node: pat_wild, _ } => (),
@ast::pat { node: pat_ident(_, _, _), _ } => (),
@ast::pat { span, _ } => self.span_fatal(
span, ~"expected an identifier or `_`"
span, "expected an identifier or `_`"
)
}
slice = Some(subpat);
......@@ -2459,7 +2458,7 @@ fn parse_pat_ident(&self,
-> ast::pat_ {
if !is_plain_ident(&*self.token) {
self.span_fatal(*self.last_span,
~"expected identifier, found path");
"expected identifier, found path");
}
// why a path here, and not just an identifier?
let name = self.parse_path_without_tps();
......@@ -2478,7 +2477,7 @@ fn parse_pat_ident(&self,
if *self.token == token::LPAREN {
self.span_fatal(
*self.last_span,
~"expected identifier, found enum pattern");
"expected identifier, found enum pattern");
}
pat_ident(binding_mode, name, sub)
......@@ -2609,19 +2608,19 @@ fn check_expected_item(p: &Parser, current_attrs: &[attribute]) {
match self.parse_item_or_view_item(/*bad*/ copy item_attrs,
false) {
iovi_item(i) => {
let hi = i.span.hi;
let decl = @spanned(lo, hi, decl_item(i));
return @spanned(lo, hi, stmt_decl(decl, self.get_id()));
}
iovi_view_item(vi) => {
self.span_fatal(vi.span, ~"view items must be declared at \
the top of the block");
}
iovi_foreign_item(_) => {
self.fatal(~"foreign items are not allowed here");
}
iovi_none() => { /* fallthrough */ }
iovi_item(i) => {
let hi = i.span.hi;
let decl = @spanned(lo, hi, decl_item(i));
return @spanned(lo, hi, stmt_decl(decl, self.get_id()));
}
iovi_view_item(vi) => {
self.span_fatal(vi.span,
"view items must be declared at the top of the block");
}
iovi_foreign_item(_) => {
self.fatal(~"foreign items are not allowed here");
}
iovi_none() => { /* fallthrough */ }
}
check_expected_item(self, item_attrs);
......@@ -2822,8 +2821,7 @@ fn parse_optional_ty_param_bounds(&self) -> @OptVec<TyParamBound> {
result.push(RegionTyParamBound);
} else {
self.span_err(*self.span,
~"`'static` is the only permissible \
region bound here");
"`'static` is the only permissible region bound here");
}
self.bump();
}
......@@ -3238,7 +3236,7 @@ fn parse_item_impl(&self, visibility: ast::visibility) -> item_info {
})
}
_ => {
self.span_err(*self.span, ~"not a trait");
self.span_err(*self.span, "not a trait");
None
}
};
......@@ -3467,9 +3465,8 @@ fn parse_mod_items(&self, term: token::Token,
) {
iovi_item(item) => items.push(item),
iovi_view_item(view_item) => {
self.span_fatal(view_item.span, ~"view items must be \
declared at the top of the \
module");
self.span_fatal(view_item.span, "view items must be declared at the top of the \
module");
}
_ => {
self.fatal(
......@@ -3762,7 +3759,7 @@ fn parse_item_foreign_mod(&self,
}
if opt_abis.is_some() {
self.span_err(*self.span, ~"an ABI may not be specified here");
self.span_err(*self.span, "an ABI may not be specified here");
}
// extern mod foo;
......@@ -4397,9 +4394,7 @@ fn parse_items_and_view_items(&self,
view_item_extern_mod(*)
if !extern_mod_allowed => {
self.span_err(view_item.span,
~"\"extern mod\" \
declarations are not \
allowed here");
"\"extern mod\" declarations are not allowed here");
}
view_item_extern_mod(*) => {}
}
......@@ -4425,8 +4420,7 @@ fn parse_items_and_view_items(&self,
iovi_none => break,
iovi_view_item(view_item) => {
self.span_err(view_item.span,
~"`use` and `extern mod` declarations \
must precede items");
"`use` and `extern mod` declarations must precede items");
}
iovi_item(item) => {
items.push(item)
......@@ -4461,8 +4455,7 @@ fn parse_foreign_items(&self, first_item_attrs: ~[attribute],
iovi_view_item(view_item) => {
// I think this can't occur:
self.span_err(view_item.span,
~"`use` and `extern mod` declarations \
must precede items");
"`use` and `extern mod` declarations must precede items");
}
iovi_item(_) => {
// FIXME #5668: this will occur for a macro invocation:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册