Skip to content

Commit f2c88c1

Browse files
committed
Merge pull request #1385 from Lenny222/quotes
Use singlequotes in the typechecker error messages too, to distinguish code and English
2 parents 51227c1 + 0b9751b commit f2c88c1

15 files changed

+49
-46
lines changed

src/comp/middle/typeck.rs

+32-29
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
369369
alt mode {
370370
m_check_tyvar(fcx) { ret next_ty_var(fcx); }
371371
_ { tcx.sess.span_bug(ast_ty.span,
372-
"found ty_infer in unexpected place"); }
372+
"found 'ty_infer' in unexpected place"); }
373373
}
374374
}
375375
}
@@ -895,11 +895,12 @@ mod demand {
895895
let e_err = resolve_type_vars_if_possible(fcx, expected);
896896
let a_err = resolve_type_vars_if_possible(fcx, actual);
897897
fcx.ccx.tcx.sess.span_err(sp,
898-
"mismatched types: expected " +
898+
"mismatched types: expected '" +
899899
ty_to_str(fcx.ccx.tcx, e_err) +
900-
" but found " +
901-
ty_to_str(fcx.ccx.tcx, a_err) + " ("
902-
+ ty::type_err_to_str(err) + ")");
900+
"' but found '" +
901+
ty_to_str(fcx.ccx.tcx, a_err) +
902+
"' (" + ty::type_err_to_str(err) +
903+
")");
903904
ret mk_result(fcx, expected, ty_param_subst_var_ids);
904905
}
905906
}
@@ -1302,7 +1303,7 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13021303
// can never tell.
13031304
fcx.ccx.tcx.sess.span_fatal
13041305
(pat.span,
1305-
#fmt["mismatched types: expected %s, found tag",
1306+
#fmt["mismatched types: expected '%s' but found tag",
13061307
ty_to_str(fcx.ccx.tcx, expected)]);
13071308
}
13081309
}
@@ -1314,7 +1315,8 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13141315
ty::ty_rec(fields) { ex_fields = fields; }
13151316
_ {
13161317
fcx.ccx.tcx.sess.span_fatal
1317-
(pat.span, #fmt["mismatched types: expected %s, found record",
1318+
(pat.span,
1319+
#fmt["mismatched types: expected '%s' but found record",
13181320
ty_to_str(fcx.ccx.tcx, expected)]);
13191321
}
13201322
}
@@ -1336,7 +1338,7 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13361338
none. {
13371339
fcx.ccx.tcx.sess.span_fatal(pat.span,
13381340
#fmt["mismatched types: did not \
1339-
expect a record with a field %s",
1341+
expect a record with a field '%s'",
13401342
f.ident]);
13411343
}
13421344
}
@@ -1349,8 +1351,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13491351
ty::ty_tup(elts) { ex_elts = elts; }
13501352
_ {
13511353
fcx.ccx.tcx.sess.span_fatal
1352-
(pat.span, #fmt["mismatched types: expected %s, found tuple",
1353-
ty_to_str(fcx.ccx.tcx, expected)]);
1354+
(pat.span,
1355+
#fmt["mismatched types: expected '%s', found tuple",
1356+
ty_to_str(fcx.ccx.tcx, expected)]);
13541357
}
13551358
}
13561359
let e_count = vec::len(elts);
@@ -1372,9 +1375,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13721375
}
13731376
_ {
13741377
fcx.ccx.tcx.sess.span_fatal(pat.span,
1375-
"mismatched types: expected " +
1378+
"mismatched types: expected '" +
13761379
ty_to_str(fcx.ccx.tcx, expected) +
1377-
" found box");
1380+
"' found box");
13781381
}
13791382
}
13801383
}
@@ -1386,9 +1389,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13861389
}
13871390
_ {
13881391
fcx.ccx.tcx.sess.span_fatal(pat.span,
1389-
"mismatched types: expected " +
1392+
"mismatched types: expected '" +
13901393
ty_to_str(fcx.ccx.tcx, expected) +
1391-
" found uniq");
1394+
"' found uniq");
13921395
}
13931396
}
13941397
}
@@ -1790,8 +1793,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
17901793
if !type_is_integral(fcx, oper.span, oper_t) &&
17911794
structure_of(fcx, oper.span, oper_t) != ty::ty_bool {
17921795
tcx.sess.span_err(expr.span,
1793-
#fmt["mismatched types: expected bool \
1794-
or integer but found %s",
1796+
#fmt["mismatched types: expected 'bool' \
1797+
or 'integer' but found '%s'",
17951798
ty_to_str(tcx, oper_t)]);
17961799
}
17971800
}
@@ -1801,8 +1804,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
18011804
ty::type_is_fp(tcx, oper_t)) {
18021805
tcx.sess.span_err(expr.span,
18031806
"applying unary minus to \
1804-
non-numeric type "
1805-
+ ty_to_str(tcx, oper_t));
1807+
non-numeric type '"
1808+
+ ty_to_str(tcx, oper_t) + "'");
18061809
}
18071810
}
18081811
}
@@ -1918,7 +1921,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
19181921
_ {
19191922
tcx.sess.span_fatal(expr.span,
19201923
"mismatched types: expected vector or string "
1921-
+ "but found " + ty_to_str(tcx, ety));
1924+
+ "but found '" + ty_to_str(tcx, ety) + "'");
19221925
}
19231926
}
19241927
bot |= check_for(fcx, decl, elt_ty, body, id);
@@ -2249,8 +2252,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
22492252
if !type_is_integral(fcx, idx.span, idx_t) {
22502253
tcx.sess.span_err(idx.span,
22512254
"mismatched types: expected \
2252-
integer but found "
2253-
+ ty_to_str(tcx, idx_t));
2255+
'integer' but found '"
2256+
+ ty_to_str(tcx, idx_t) + "'");
22542257
}
22552258
alt structure_of(fcx, expr.span, base_t) {
22562259
ty::ty_vec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
@@ -2687,13 +2690,13 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
26872690
some(m) {
26882691
if !ty::same_method(ccx.tcx, m, if_m) {
26892692
ccx.tcx.sess.span_err(
2690-
ty.span, "method " + if_m.ident +
2691-
" has the wrong type");
2693+
ty.span, "method '" + if_m.ident +
2694+
"' has the wrong type");
26922695
}
26932696
}
26942697
none. {
2695-
ccx.tcx.sess.span_err(ty.span, "missing method " +
2696-
if_m.ident);
2698+
ccx.tcx.sess.span_err(ty.span, "missing method '" +
2699+
if_m.ident + "'");
26972700
}
26982701
}
26992702
}
@@ -2737,15 +2740,15 @@ fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
27372740
if !ok {
27382741
let span = ast_map::node_span(tcx.items.get(main_id));
27392742
tcx.sess.span_err(span,
2740-
"wrong type in main function: found " +
2741-
ty_to_str(tcx, main_t));
2743+
"wrong type in main function: found '" +
2744+
ty_to_str(tcx, main_t) + "'");
27422745
}
27432746
}
27442747
_ {
27452748
let span = ast_map::node_span(tcx.items.get(main_id));
27462749
tcx.sess.span_bug(span,
2747-
"main has a non-function type: found" +
2748-
ty_to_str(tcx, main_t));
2750+
"main has a non-function type: found '" +
2751+
ty_to_str(tcx, main_t) + "'");
27492752
}
27502753
}
27512754
}
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected str but found int
1+
// error-pattern:expected 'str' but found 'int'
22

33
const i: str = 10;
44
fn main() { log(debug, i); }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// error-pattern:did not expect a record with a field q
1+
// error-pattern:did not expect a record with a field 'q'
22

33
fn main() { alt {x: 1, y: 2} { {x: x, q: q} { } } }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// error-pattern:expected str but found [int]
1+
// error-pattern:expected 'str' but found '[int]'
22
fn main() { fail [0]; }

src/test/compile-fail/fn-bare-bind.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// error-pattern:mismatched types: expected fn() but found fn@()
1+
// error-pattern:mismatched types: expected 'fn()' but found 'fn@()'
22

33
fn f() {
44
}
55

66
fn main() {
77
// Can't produce a bare function by binding
88
let g: fn() = bind f();
9-
}
9+
}

src/test/compile-fail/fn-compare-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected fn() but found fn(++int)
1+
// error-pattern:expected 'fn()' but found 'fn(++int)'
22

33
fn main() {
44
fn f() { }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// error-pattern:wrong type in main function: found fn() -> char
1+
// error-pattern:wrong type in main function: found 'fn() -> char'
22
fn main() -> char { }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// error-pattern:wrong type in main function: found fn(
1+
// error-pattern:wrong type in main function: found 'fn(&&{x: int,y: int})'
22
fn main(foo: {x: int, y: int}) { }

src/test/compile-fail/minus-string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
// error-pattern:applying unary minus to non-numeric type str
1+
// error-pattern:applying unary minus to non-numeric type 'str'
22

33
fn main() { -"foo"; }

src/test/compile-fail/native-type-mismatch.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected *Mb but found native
1+
// error-pattern:expected '*Mb' but found 'native'
22
use std;
33

44
fn main() unsafe {

src/test/compile-fail/nonsense-constraints.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Tests that the typechecker checks constraints
2-
// error-pattern:mismatched types: expected uint but found u8
2+
// error-pattern:mismatched types: expected 'uint' but found 'u8'
33
use std;
44
import uint;
55

src/test/compile-fail/rec-extend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected int but found bool
1+
// error-pattern:expected 'int' but found 'bool'
22

33
fn main() {
44

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern: mismatched types: expected lambda(++uint) -> uint
1+
// error-pattern: mismatched types: expected 'lambda(++uint) -> uint'
22

33
fn test(f: lambda(uint) -> uint) -> uint {
44
ret f(22u);
@@ -7,4 +7,4 @@ fn test(f: lambda(uint) -> uint) -> uint {
77
fn main() {
88
let f = sendfn(x: uint) -> uint { ret 4u; };
99
log(debug, test(f));
10-
}
10+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Checking that the compiler reports multiple type errors at once
2-
// error-pattern:mismatched types: expected bool
3-
// error-pattern:mismatched types: expected int
2+
// error-pattern:mismatched types: expected 'bool'
3+
// error-pattern:mismatched types: expected 'int'
44

55
fn main() { let a: bool = 1; let b: int = true; }
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// error-pattern:expected bool but found int
1+
// error-pattern:expected 'bool' but found 'int'
22
// issue #516
33

44
fn main() { let x = true; let y = 1; let z = x + y; }

0 commit comments

Comments
 (0)