Skip to content

Commit b42ea7f

Browse files
committed
auto merge of #6174 : sanxiyn/rust/static-string, r=brson
2 parents efcabc4 + 4294aed commit b42ea7f

12 files changed

+146
-146
lines changed

src/librustc/driver/session.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,16 @@ pub struct Session_ {
175175
pub type Session = @Session_;
176176

177177
pub impl Session_ {
178-
fn span_fatal(@self, sp: span, msg: ~str) -> ! {
178+
fn span_fatal(@self, sp: span, msg: &str) -> ! {
179179
self.span_diagnostic.span_fatal(sp, msg)
180180
}
181-
fn fatal(@self, msg: ~str) -> ! {
181+
fn fatal(@self, msg: &str) -> ! {
182182
self.span_diagnostic.handler().fatal(msg)
183183
}
184-
fn span_err(@self, sp: span, msg: ~str) {
184+
fn span_err(@self, sp: span, msg: &str) {
185185
self.span_diagnostic.span_err(sp, msg)
186186
}
187-
fn err(@self, msg: ~str) {
187+
fn err(@self, msg: &str) {
188188
self.span_diagnostic.handler().err(msg)
189189
}
190190
fn has_errors(@self) -> bool {
@@ -193,31 +193,31 @@ pub impl Session_ {
193193
fn abort_if_errors(@self) {
194194
self.span_diagnostic.handler().abort_if_errors()
195195
}
196-
fn span_warn(@self, sp: span, msg: ~str) {
196+
fn span_warn(@self, sp: span, msg: &str) {
197197
self.span_diagnostic.span_warn(sp, msg)
198198
}
199-
fn warn(@self, msg: ~str) {
199+
fn warn(@self, msg: &str) {
200200
self.span_diagnostic.handler().warn(msg)
201201
}
202-
fn span_note(@self, sp: span, msg: ~str) {
202+
fn span_note(@self, sp: span, msg: &str) {
203203
self.span_diagnostic.span_note(sp, msg)
204204
}
205-
fn note(@self, msg: ~str) {
205+
fn note(@self, msg: &str) {
206206
self.span_diagnostic.handler().note(msg)
207207
}
208-
fn span_bug(@self, sp: span, msg: ~str) -> ! {
208+
fn span_bug(@self, sp: span, msg: &str) -> ! {
209209
self.span_diagnostic.span_bug(sp, msg)
210210
}
211-
fn bug(@self, msg: ~str) -> ! {
211+
fn bug(@self, msg: &str) -> ! {
212212
self.span_diagnostic.handler().bug(msg)
213213
}
214-
fn span_unimpl(@self, sp: span, msg: ~str) -> ! {
214+
fn span_unimpl(@self, sp: span, msg: &str) -> ! {
215215
self.span_diagnostic.span_unimpl(sp, msg)
216216
}
217-
fn unimpl(@self, msg: ~str) -> ! {
217+
fn unimpl(@self, msg: &str) -> ! {
218218
self.span_diagnostic.handler().unimpl(msg)
219219
}
220-
fn span_lint_level(@self, level: lint::level, sp: span, msg: ~str) {
220+
fn span_lint_level(@self, level: lint::level, sp: span, msg: &str) {
221221
match level {
222222
lint::allow => { },
223223
lint::warn => self.span_warn(sp, msg),
@@ -230,7 +230,7 @@ pub impl Session_ {
230230
expr_id: ast::node_id,
231231
item_id: ast::node_id,
232232
span: span,
233-
msg: ~str) {
233+
msg: &str) {
234234
let level = lint::get_lint_settings_level(
235235
self.lint_settings, lint_mode, expr_id, item_id);
236236
self.span_lint_level(level, span, msg);

src/librustc/middle/check_const.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,13 @@ pub fn check_expr(sess: Session,
9292
expr_unary(deref, _) => { }
9393
expr_unary(box(_), _) | expr_unary(uniq(_), _) => {
9494
sess.span_err(e.span,
95-
~"disallowed operator in constant expression");
95+
"disallowed operator in constant expression");
9696
return;
9797
}
9898
expr_lit(@codemap::spanned {node: lit_str(_), _}) => { }
9999
expr_binary(_, _, _) | expr_unary(_, _) => {
100100
if method_map.contains_key(&e.id) {
101-
sess.span_err(e.span, ~"user-defined operators are not \
101+
sess.span_err(e.span, "user-defined operators are not \
102102
allowed in constant expressions");
103103
}
104104
}
@@ -118,8 +118,8 @@ pub fn check_expr(sess: Session,
118118
// a path in trans::callee that only works in block contexts.
119119
if pth.types.len() != 0 {
120120
sess.span_err(
121-
e.span, ~"paths in constants may only refer to \
122-
items without type parameters");
121+
e.span, "paths in constants may only refer to \
122+
items without type parameters");
123123
}
124124
match def_map.find(&e.id) {
125125
Some(&def_const(_)) |
@@ -131,11 +131,11 @@ pub fn check_expr(sess: Session,
131131
debug!("(checking const) found bad def: %?", def);
132132
sess.span_err(
133133
e.span,
134-
fmt!("paths in constants may only refer to \
135-
constants or functions"));
134+
"paths in constants may only refer to \
135+
constants or functions");
136136
}
137137
None => {
138-
sess.span_bug(e.span, ~"unbound path in const?!");
138+
sess.span_bug(e.span, "unbound path in const?!");
139139
}
140140
}
141141
}
@@ -146,8 +146,8 @@ pub fn check_expr(sess: Session,
146146
_ => {
147147
sess.span_err(
148148
e.span,
149-
~"function calls in constants are limited to \
150-
struct and enum constructors");
149+
"function calls in constants are limited to \
150+
struct and enum constructors");
151151
}
152152
}
153153
}
@@ -163,12 +163,12 @@ pub fn check_expr(sess: Session,
163163
expr_addr_of(*) => {
164164
sess.span_err(
165165
e.span,
166-
~"borrowed pointers in constants may only refer to \
167-
immutable values");
166+
"borrowed pointers in constants may only refer to \
167+
immutable values");
168168
}
169169
_ => {
170170
sess.span_err(e.span,
171-
~"constant contains unimplemented expression type");
171+
"constant contains unimplemented expression type");
172172
return;
173173
}
174174
}
@@ -178,14 +178,14 @@ pub fn check_expr(sess: Session,
178178
if t != ty_char {
179179
if (v as u64) > ast_util::int_ty_max(
180180
if t == ty_i { sess.targ_cfg.int_type } else { t }) {
181-
sess.span_err(e.span, ~"literal out of range for its type");
181+
sess.span_err(e.span, "literal out of range for its type");
182182
}
183183
}
184184
}
185185
expr_lit(@codemap::spanned {node: lit_uint(v, t), _}) => {
186186
if v > ast_util::uint_ty_max(
187187
if t == ty_u { sess.targ_cfg.uint_type } else { t }) {
188-
sess.span_err(e.span, ~"literal out of range for its type");
188+
sess.span_err(e.span, "literal out of range for its type");
189189
}
190190
}
191191
_ => ()
@@ -224,7 +224,7 @@ pub fn check_item_recursion(sess: Session,
224224

225225
fn visit_item(it: @item, env: env, v: visit::vt<env>) {
226226
if env.idstack.contains(&(it.id)) {
227-
env.sess.span_fatal(env.root_it.span, ~"recursive constant");
227+
env.sess.span_fatal(env.root_it.span, "recursive constant");
228228
}
229229
env.idstack.push(it.id);
230230
visit::visit_item(it, env, v);

src/librustc/middle/check_loop.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,17 +54,17 @@ pub fn check_crate(tcx: ty::ctxt, crate: @crate) {
5454
}
5555
expr_break(_) => {
5656
if !cx.in_loop {
57-
tcx.sess.span_err(e.span, ~"`break` outside of loop");
57+
tcx.sess.span_err(e.span, "`break` outside of loop");
5858
}
5959
}
6060
expr_again(_) => {
6161
if !cx.in_loop {
62-
tcx.sess.span_err(e.span, ~"`again` outside of loop");
62+
tcx.sess.span_err(e.span, "`again` outside of loop");
6363
}
6464
}
6565
expr_ret(oe) => {
6666
if !cx.can_ret {
67-
tcx.sess.span_err(e.span, ~"`return` in block function");
67+
tcx.sess.span_err(e.span, "`return` in block function");
6868
}
6969
visit::visit_expr_opt(oe, cx, v);
7070
}

src/librustc/middle/check_match.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub fn check_expr(cx: @MatchCheckCtxt, ex: @expr, s: (), v: visit::vt<()>) {
9494
}
9595
let arms = vec::concat(arms.filter_mapped(unguarded_pat));
9696
if arms.is_empty() {
97-
cx.tcx.sess.span_err(ex.span, ~"non-exhaustive patterns");
97+
cx.tcx.sess.span_err(ex.span, "non-exhaustive patterns");
9898
} else {
9999
check_exhaustive(cx, ex.span, arms);
100100
}
@@ -111,7 +111,7 @@ pub fn check_arms(cx: @MatchCheckCtxt, arms: &[arm]) {
111111
let v = ~[*pat];
112112
match is_useful(cx, &seen, v) {
113113
not_useful => {
114-
cx.tcx.sess.span_err(pat.span, ~"unreachable pattern");
114+
cx.tcx.sess.span_err(pat.span, "unreachable pattern");
115115
}
116116
_ => ()
117117
}
@@ -685,7 +685,7 @@ pub fn check_local(cx: @MatchCheckCtxt,
685685
visit::visit_local(loc, s, v);
686686
if is_refutable(cx, loc.node.pat) {
687687
cx.tcx.sess.span_err(loc.node.pat.span,
688-
~"refutable pattern in local binding");
688+
"refutable pattern in local binding");
689689
}
690690
691691
// Check legality of move bindings.
@@ -708,7 +708,7 @@ pub fn check_fn(cx: @MatchCheckCtxt,
708708
for decl.inputs.each |input| {
709709
if is_refutable(cx, input.pat) {
710710
cx.tcx.sess.span_err(input.pat.span,
711-
~"refutable pattern in function argument");
711+
"refutable pattern in function argument");
712712
}
713713
}
714714
}
@@ -780,24 +780,24 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
780780
if sub.is_some() {
781781
tcx.sess.span_err(
782782
p.span,
783-
~"cannot bind by-move with sub-bindings");
783+
"cannot bind by-move with sub-bindings");
784784
} else if has_guard {
785785
tcx.sess.span_err(
786786
p.span,
787-
~"cannot bind by-move into a pattern guard");
787+
"cannot bind by-move into a pattern guard");
788788
} else if by_ref_span.is_some() {
789789
tcx.sess.span_err(
790790
p.span,
791-
~"cannot bind by-move and by-ref \
792-
in the same pattern");
791+
"cannot bind by-move and by-ref \
792+
in the same pattern");
793793
tcx.sess.span_note(
794794
by_ref_span.get(),
795-
~"by-ref binding occurs here");
795+
"by-ref binding occurs here");
796796
} else if is_lvalue {
797797
tcx.sess.span_err(
798798
p.span,
799-
~"cannot bind by-move when \
800-
matching an lvalue");
799+
"cannot bind by-move when \
800+
matching an lvalue");
801801
}
802802
};
803803
@@ -837,9 +837,9 @@ pub fn check_legality_of_move_bindings(cx: @MatchCheckCtxt,
837837
{
838838
cx.tcx.sess.span_err(
839839
pat.span,
840-
~"by-move pattern \
841-
bindings may not occur \
842-
behind @ or & bindings");
840+
"by-move pattern \
841+
bindings may not occur \
842+
behind @ or & bindings");
843843
}
844844

845845
match sub {

src/librustc/middle/kind.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,21 @@ fn check_struct_safe_for_destructor(cx: Context,
9797
});
9898
if !ty::type_is_owned(cx.tcx, struct_ty) {
9999
cx.tcx.sess.span_err(span,
100-
~"cannot implement a destructor on a struct \
101-
that is not Owned");
100+
"cannot implement a destructor on a struct \
101+
that is not Owned");
102102
cx.tcx.sess.span_note(span,
103-
~"use \"#[unsafe_destructor]\" on the \
104-
implementation to force the compiler to \
105-
allow this");
103+
"use \"#[unsafe_destructor]\" on the \
104+
implementation to force the compiler to \
105+
allow this");
106106
}
107107
} else {
108108
cx.tcx.sess.span_err(span,
109-
~"cannot implement a destructor on a struct \
110-
with type parameters");
109+
"cannot implement a destructor on a struct \
110+
with type parameters");
111111
cx.tcx.sess.span_note(span,
112-
~"use \"#[unsafe_destructor]\" on the \
113-
implementation to force the compiler to \
114-
allow this");
112+
"use \"#[unsafe_destructor]\" on the \
113+
implementation to force the compiler to \
114+
allow this");
115115
}
116116
}
117117

@@ -143,10 +143,10 @@ fn check_item(item: @item, cx: Context, visitor: visit::vt<Context>) {
143143
}
144144
_ => {
145145
cx.tcx.sess.span_bug(self_type.span,
146-
~"the self type for \
147-
the Drop trait \
148-
impl is not a \
149-
path");
146+
"the self type for \
147+
the Drop trait \
148+
impl is not a \
149+
path");
150150
}
151151
}
152152
}
@@ -193,7 +193,7 @@ fn with_appropriate_checker(cx: Context, id: node_id, b: &fn(check_fn)) {
193193
fn check_for_bare(cx: Context, fv: @freevar_entry) {
194194
cx.tcx.sess.span_err(
195195
fv.span,
196-
~"attempted dynamic environment capture");
196+
"attempted dynamic environment capture");
197197
}
198198

199199
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) {
409409
if is_mutbl {
410410
cx.tcx.sess.span_err(
411411
sp,
412-
~"mutable variables cannot be implicitly captured");
412+
"mutable variables cannot be implicitly captured");
413413
}
414414
}
415415
def_arg(*) => { /* ok */ }
@@ -451,12 +451,12 @@ pub fn check_durable(tcx: ty::ctxt, ty: ty::t, sp: span) -> bool {
451451
if !ty::type_is_durable(tcx, ty) {
452452
match ty::get(ty).sty {
453453
ty::ty_param(*) => {
454-
tcx.sess.span_err(sp, ~"value may contain borrowed \
455-
pointers; use `'static` bound");
454+
tcx.sess.span_err(sp, "value may contain borrowed \
455+
pointers; use `'static` bound");
456456
}
457457
_ => {
458-
tcx.sess.span_err(sp, ~"value may contain borrowed \
459-
pointers");
458+
tcx.sess.span_err(sp, "value may contain borrowed \
459+
pointers");
460460
}
461461
}
462462
false
@@ -581,7 +581,7 @@ pub fn check_kind_bounds_of_cast(cx: Context, source: @expr, target: @expr) {
581581
if !ty::type_is_owned(cx.tcx, source_ty) {
582582
cx.tcx.sess.span_err(
583583
target.span,
584-
~"uniquely-owned trait objects must be sendable");
584+
"uniquely-owned trait objects must be sendable");
585585
}
586586
}
587587
_ => {} // Nothing to do.

0 commit comments

Comments
 (0)