Skip to content

Commit 0b9751b

Browse files
author
Lenny222
committed
Use singlequotes in the typechecker too, to distinguish code and English
1 parent b3eb9a0 commit 0b9751b

15 files changed

+49
-46
lines changed

src/comp/middle/typeck.rs

+32-29
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
367367
alt mode {
368368
m_check_tyvar(fcx) { ret next_ty_var(fcx); }
369369
_ { tcx.sess.span_bug(ast_ty.span,
370-
"found ty_infer in unexpected place"); }
370+
"found 'ty_infer' in unexpected place"); }
371371
}
372372
}
373373
}
@@ -866,11 +866,12 @@ mod demand {
866866
let e_err = resolve_type_vars_if_possible(fcx, expected);
867867
let a_err = resolve_type_vars_if_possible(fcx, actual);
868868
fcx.ccx.tcx.sess.span_err(sp,
869-
"mismatched types: expected " +
869+
"mismatched types: expected '" +
870870
ty_to_str(fcx.ccx.tcx, e_err) +
871-
" but found " +
872-
ty_to_str(fcx.ccx.tcx, a_err) + " ("
873-
+ ty::type_err_to_str(err) + ")");
871+
"' but found '" +
872+
ty_to_str(fcx.ccx.tcx, a_err) +
873+
"' (" + ty::type_err_to_str(err) +
874+
")");
874875
ret mk_result(fcx, expected, ty_param_subst_var_ids);
875876
}
876877
}
@@ -1273,7 +1274,7 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
12731274
// can never tell.
12741275
fcx.ccx.tcx.sess.span_fatal
12751276
(pat.span,
1276-
#fmt["mismatched types: expected %s, found tag",
1277+
#fmt["mismatched types: expected '%s' but found tag",
12771278
ty_to_str(fcx.ccx.tcx, expected)]);
12781279
}
12791280
}
@@ -1285,7 +1286,8 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
12851286
ty::ty_rec(fields) { ex_fields = fields; }
12861287
_ {
12871288
fcx.ccx.tcx.sess.span_fatal
1288-
(pat.span, #fmt["mismatched types: expected %s, found record",
1289+
(pat.span,
1290+
#fmt["mismatched types: expected '%s' but found record",
12891291
ty_to_str(fcx.ccx.tcx, expected)]);
12901292
}
12911293
}
@@ -1307,7 +1309,7 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13071309
none. {
13081310
fcx.ccx.tcx.sess.span_fatal(pat.span,
13091311
#fmt["mismatched types: did not \
1310-
expect a record with a field %s",
1312+
expect a record with a field '%s'",
13111313
f.ident]);
13121314
}
13131315
}
@@ -1320,8 +1322,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13201322
ty::ty_tup(elts) { ex_elts = elts; }
13211323
_ {
13221324
fcx.ccx.tcx.sess.span_fatal
1323-
(pat.span, #fmt["mismatched types: expected %s, found tuple",
1324-
ty_to_str(fcx.ccx.tcx, expected)]);
1325+
(pat.span,
1326+
#fmt["mismatched types: expected '%s', found tuple",
1327+
ty_to_str(fcx.ccx.tcx, expected)]);
13251328
}
13261329
}
13271330
let e_count = vec::len(elts);
@@ -1343,9 +1346,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13431346
}
13441347
_ {
13451348
fcx.ccx.tcx.sess.span_fatal(pat.span,
1346-
"mismatched types: expected " +
1349+
"mismatched types: expected '" +
13471350
ty_to_str(fcx.ccx.tcx, expected) +
1348-
" found box");
1351+
"' found box");
13491352
}
13501353
}
13511354
}
@@ -1357,9 +1360,9 @@ fn check_pat(fcx: @fn_ctxt, map: ast_util::pat_id_map, pat: @ast::pat,
13571360
}
13581361
_ {
13591362
fcx.ccx.tcx.sess.span_fatal(pat.span,
1360-
"mismatched types: expected " +
1363+
"mismatched types: expected '" +
13611364
ty_to_str(fcx.ccx.tcx, expected) +
1362-
" found uniq");
1365+
"' found uniq");
13631366
}
13641367
}
13651368
}
@@ -1761,8 +1764,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
17611764
if !type_is_integral(fcx, oper.span, oper_t) &&
17621765
structure_of(fcx, oper.span, oper_t) != ty::ty_bool {
17631766
tcx.sess.span_err(expr.span,
1764-
#fmt["mismatched types: expected bool \
1765-
or integer but found %s",
1767+
#fmt["mismatched types: expected 'bool' \
1768+
or 'integer' but found '%s'",
17661769
ty_to_str(tcx, oper_t)]);
17671770
}
17681771
}
@@ -1772,8 +1775,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
17721775
ty::type_is_fp(tcx, oper_t)) {
17731776
tcx.sess.span_err(expr.span,
17741777
"applying unary minus to \
1775-
non-numeric type "
1776-
+ ty_to_str(tcx, oper_t));
1778+
non-numeric type '"
1779+
+ ty_to_str(tcx, oper_t) + "'");
17771780
}
17781781
}
17791782
}
@@ -1889,7 +1892,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
18891892
_ {
18901893
tcx.sess.span_fatal(expr.span,
18911894
"mismatched types: expected vector or string "
1892-
+ "but found " + ty_to_str(tcx, ety));
1895+
+ "but found '" + ty_to_str(tcx, ety) + "'");
18931896
}
18941897
}
18951898
bot |= check_for(fcx, decl, elt_ty, body, id);
@@ -2220,8 +2223,8 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
22202223
if !type_is_integral(fcx, idx.span, idx_t) {
22212224
tcx.sess.span_err(idx.span,
22222225
"mismatched types: expected \
2223-
integer but found "
2224-
+ ty_to_str(tcx, idx_t));
2226+
'integer' but found '"
2227+
+ ty_to_str(tcx, idx_t) + "'");
22252228
}
22262229
alt structure_of(fcx, expr.span, base_t) {
22272230
ty::ty_vec(mt) { write::ty_only_fixup(fcx, id, mt.ty); }
@@ -2658,13 +2661,13 @@ fn check_item(ccx: @crate_ctxt, it: @ast::item) {
26582661
some(m) {
26592662
if !ty::same_method(ccx.tcx, m, if_m) {
26602663
ccx.tcx.sess.span_err(
2661-
ty.span, "method " + if_m.ident +
2662-
" has the wrong type");
2664+
ty.span, "method '" + if_m.ident +
2665+
"' has the wrong type");
26632666
}
26642667
}
26652668
none. {
2666-
ccx.tcx.sess.span_err(ty.span, "missing method " +
2667-
if_m.ident);
2669+
ccx.tcx.sess.span_err(ty.span, "missing method '" +
2670+
if_m.ident + "'");
26682671
}
26692672
}
26702673
}
@@ -2708,15 +2711,15 @@ fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
27082711
if !ok {
27092712
let span = ast_map::node_span(tcx.items.get(main_id));
27102713
tcx.sess.span_err(span,
2711-
"wrong type in main function: found " +
2712-
ty_to_str(tcx, main_t));
2714+
"wrong type in main function: found '" +
2715+
ty_to_str(tcx, main_t) + "'");
27132716
}
27142717
}
27152718
_ {
27162719
let span = ast_map::node_span(tcx.items.get(main_id));
27172720
tcx.sess.span_bug(span,
2718-
"main has a non-function type: found" +
2719-
ty_to_str(tcx, main_t));
2721+
"main has a non-function type: found '" +
2722+
ty_to_str(tcx, main_t) + "'");
27202723
}
27212724
}
27222725
}
+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)