Skip to content

Commit 9968ae2

Browse files
committed
Adjust the error messages to match the pattern "expected foo, found bar"
Closes #8492
1 parent 2e5aea6 commit 9968ae2

File tree

118 files changed

+266
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+266
-266
lines changed

src/libfmt_macros/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ impl<'a> Parser<'a> {
200200
self.cur.next();
201201
}
202202
Some((_, other)) => {
203-
self.err(format!("expected `{}` but found `{}`",
203+
self.err(format!("expected `{}`, found `{}`",
204204
c,
205205
other).as_slice());
206206
}

src/librustc/metadata/tydecode.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,12 +575,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
575575

576576
let crate_num = match uint::parse_bytes(crate_part, 10u) {
577577
Some(cn) => cn as ast::CrateNum,
578-
None => fail!("internal error: parse_def_id: crate number expected, but found {:?}",
578+
None => fail!("internal error: parse_def_id: crate number expected, found {:?}",
579579
crate_part)
580580
};
581581
let def_num = match uint::parse_bytes(def_part, 10u) {
582582
Some(dn) => dn as ast::NodeId,
583-
None => fail!("internal error: parse_def_id: id expected, but found {:?}",
583+
None => fail!("internal error: parse_def_id: id expected, found {:?}",
584584
def_part)
585585
};
586586
ast::DefId { krate: crate_num, node: def_num }

src/librustc/middle/effect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl<'a> Visitor<()> for EffectCheckVisitor<'a> {
122122
// we need to create a new context, when we're
123123
// - outside `unsafe` and found a `unsafe` block
124124
// (normal case)
125-
// - inside `unsafe` but found an `unsafe` block
125+
// - inside `unsafe`, found an `unsafe` block
126126
// created internally to the compiler
127127
//
128128
// The second case is necessary to ensure that the

src/librustc/middle/ty.rs

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,17 +3603,17 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
36033603
match *err {
36043604
terr_mismatch => "types differ".to_string(),
36053605
terr_fn_style_mismatch(values) => {
3606-
format!("expected {} fn but found {} fn",
3606+
format!("expected {} fn, found {} fn",
36073607
values.expected.to_string(),
36083608
values.found.to_string())
36093609
}
36103610
terr_abi_mismatch(values) => {
3611-
format!("expected {} fn but found {} fn",
3611+
format!("expected {} fn, found {} fn",
36123612
values.expected.to_string(),
36133613
values.found.to_string())
36143614
}
36153615
terr_onceness_mismatch(values) => {
3616-
format!("expected {} fn but found {} fn",
3616+
format!("expected {} fn, found {} fn",
36173617
values.expected.to_string(),
36183618
values.found.to_string())
36193619
}
@@ -3630,28 +3630,28 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
36303630
terr_ptr_mutability => "pointers differ in mutability".to_string(),
36313631
terr_ref_mutability => "references differ in mutability".to_string(),
36323632
terr_ty_param_size(values) => {
3633-
format!("expected a type with {} type params \
3634-
but found one with {} type params",
3633+
format!("expected a type with {} type params, \
3634+
found one with {} type params",
36353635
values.expected,
36363636
values.found)
36373637
}
36383638
terr_tuple_size(values) => {
3639-
format!("expected a tuple with {} elements \
3640-
but found one with {} elements",
3639+
format!("expected a tuple with {} elements, \
3640+
found one with {} elements",
36413641
values.expected,
36423642
values.found)
36433643
}
36443644
terr_record_size(values) => {
3645-
format!("expected a record with {} fields \
3646-
but found one with {} fields",
3645+
format!("expected a record with {} fields, \
3646+
found one with {} fields",
36473647
values.expected,
36483648
values.found)
36493649
}
36503650
terr_record_mutability => {
36513651
"record elements differ in mutability".to_string()
36523652
}
36533653
terr_record_fields(values) => {
3654-
format!("expected a record with field `{}` but found one \
3654+
format!("expected a record with field `{}`, found one \
36553655
with field `{}`",
36563656
token::get_ident(values.expected),
36573657
token::get_ident(values.found))
@@ -3670,57 +3670,57 @@ pub fn type_err_to_str(cx: &ctxt, err: &type_err) -> String {
36703670
}
36713671
terr_regions_insufficiently_polymorphic(br, _) => {
36723672
format!("expected bound lifetime parameter {}, \
3673-
but found concrete lifetime",
3673+
found concrete lifetime",
36743674
bound_region_ptr_to_string(cx, br))
36753675
}
36763676
terr_regions_overly_polymorphic(br, _) => {
36773677
format!("expected concrete lifetime, \
3678-
but found bound lifetime parameter {}",
3678+
found bound lifetime parameter {}",
36793679
bound_region_ptr_to_string(cx, br))
36803680
}
36813681
terr_trait_stores_differ(_, ref values) => {
3682-
format!("trait storage differs: expected `{}` but found `{}`",
3682+
format!("trait storage differs: expected `{}`, found `{}`",
36833683
trait_store_to_string(cx, (*values).expected),
36843684
trait_store_to_string(cx, (*values).found))
36853685
}
36863686
terr_sorts(values) => {
3687-
format!("expected {} but found {}",
3687+
format!("expected {}, found {}",
36883688
ty_sort_string(cx, values.expected),
36893689
ty_sort_string(cx, values.found))
36903690
}
36913691
terr_traits(values) => {
3692-
format!("expected trait `{}` but found trait `{}`",
3692+
format!("expected trait `{}`, found trait `{}`",
36933693
item_path_str(cx, values.expected),
36943694
item_path_str(cx, values.found))
36953695
}
36963696
terr_builtin_bounds(values) => {
36973697
if values.expected.is_empty() {
3698-
format!("expected no bounds but found `{}`",
3698+
format!("expected no bounds, found `{}`",
36993699
values.found.user_string(cx))
37003700
} else if values.found.is_empty() {
3701-
format!("expected bounds `{}` but found no bounds",
3701+
format!("expected bounds `{}`, found no bounds",
37023702
values.expected.user_string(cx))
37033703
} else {
3704-
format!("expected bounds `{}` but found bounds `{}`",
3704+
format!("expected bounds `{}`, found bounds `{}`",
37053705
values.expected.user_string(cx),
37063706
values.found.user_string(cx))
37073707
}
37083708
}
37093709
terr_integer_as_char => {
3710-
"expected an integral type but found `char`".to_string()
3710+
"expected an integral type, found `char`".to_string()
37113711
}
37123712
terr_int_mismatch(ref values) => {
3713-
format!("expected `{}` but found `{}`",
3713+
format!("expected `{}`, found `{}`",
37143714
values.expected.to_string(),
37153715
values.found.to_string())
37163716
}
37173717
terr_float_mismatch(ref values) => {
3718-
format!("expected `{}` but found `{}`",
3718+
format!("expected `{}`, found `{}`",
37193719
values.expected.to_string(),
37203720
values.found.to_string())
37213721
}
37223722
terr_variadic_mismatch(ref values) => {
3723-
format!("expected {} fn but found {} function",
3723+
format!("expected {} fn, found {} function",
37243724
if values.expected { "variadic" } else { "non-variadic" },
37253725
if values.found { "variadic" } else { "non-variadic" })
37263726
}
@@ -4548,7 +4548,7 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::Expr) ->
45484548
const_eval::const_int(count) => if count < 0 {
45494549
tcx.ty_ctxt().sess.span_err(count_expr.span,
45504550
"expected positive integer for \
4551-
repeat count but found negative integer");
4551+
repeat count, found negative integer");
45524552
return 0;
45534553
} else {
45544554
return count as uint
@@ -4557,38 +4557,38 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::Expr) ->
45574557
const_eval::const_float(count) => {
45584558
tcx.ty_ctxt().sess.span_err(count_expr.span,
45594559
"expected positive integer for \
4560-
repeat count but found float");
4560+
repeat count, found float");
45614561
return count as uint;
45624562
}
45634563
const_eval::const_str(_) => {
45644564
tcx.ty_ctxt().sess.span_err(count_expr.span,
45654565
"expected positive integer for \
4566-
repeat count but found string");
4566+
repeat count, found string");
45674567
return 0;
45684568
}
45694569
const_eval::const_bool(_) => {
45704570
tcx.ty_ctxt().sess.span_err(count_expr.span,
45714571
"expected positive integer for \
4572-
repeat count but found boolean");
4572+
repeat count, found boolean");
45734573
return 0;
45744574
}
45754575
const_eval::const_binary(_) => {
45764576
tcx.ty_ctxt().sess.span_err(count_expr.span,
45774577
"expected positive integer for \
4578-
repeat count but found binary array");
4578+
repeat count, found binary array");
45794579
return 0;
45804580
}
45814581
const_eval::const_nil => {
45824582
tcx.ty_ctxt().sess.span_err(count_expr.span,
45834583
"expected positive integer for \
4584-
repeat count but found ()");
4584+
repeat count, found ()");
45854585
return 0;
45864586
}
45874587
},
45884588
Err(..) => {
45894589
tcx.ty_ctxt().sess.span_err(count_expr.span,
4590-
"expected constant integer for repeat count \
4591-
but found variable");
4590+
"expected constant integer for repeat count, \
4591+
found variable");
45924592
return 0;
45934593
}
45944594
}

src/librustc/middle/typeck/astconv.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
191191

192192
if supplied_num_region_params != 0 || anon_regions.is_err() {
193193
span_err!(tcx.sess, path.span, E0107,
194-
"wrong number of lifetime parameters: expected {} but found {}",
194+
"wrong number of lifetime parameters: expected {}, found {}",
195195
expected_num_region_params, supplied_num_region_params);
196196
}
197197

@@ -216,7 +216,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
216216
"expected"
217217
};
218218
this.tcx().sess.span_fatal(path.span,
219-
format!("wrong number of type arguments: {} {} but found {}",
219+
format!("wrong number of type arguments: {} {}, found {}",
220220
expected,
221221
required_ty_param_count,
222222
supplied_ty_param_count).as_slice());
@@ -227,7 +227,7 @@ fn ast_path_substs<AC:AstConv,RS:RegionScope>(
227227
"expected"
228228
};
229229
this.tcx().sess.span_fatal(path.span,
230-
format!("wrong number of type arguments: {} {} but found {}",
230+
format!("wrong number of type arguments: {} {}, found {}",
231231
expected,
232232
formal_ty_param_count,
233233
supplied_ty_param_count).as_slice());

src/librustc/middle/typeck/check/_match.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
169169
fcx.infcx().type_error_message_str_with_expected(pat.span,
170170
|expected, actual| {
171171
expected.map_or("".to_string(), |e| {
172-
format!("mismatched types: expected `{}` but found {}",
172+
format!("mismatched types: expected `{}`, found {}",
173173
e, actual)
174174
})},
175175
Some(expected),
@@ -223,7 +223,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: &ast::Pat, path: &ast::Path,
223223
|expected, actual| {
224224
expected.map_or("".to_string(),
225225
|e| {
226-
format!("mismatched types: expected `{}` but found {}",
226+
format!("mismatched types: expected `{}`, found {}",
227227
e, actual)
228228
})
229229
},
@@ -395,7 +395,7 @@ pub fn check_struct_like_enum_variant_pat(pcx: &pat_ctxt,
395395
Some(&def::DefTy(..)) => {
396396
let name = pprust::path_to_string(path);
397397
span_err!(tcx.sess, span, E0028,
398-
"mismatched types: expected `{}` but found `{}`",
398+
"mismatched types: expected `{}`, found `{}`",
399399
fcx.infcx().ty_to_string(expected), name);
400400
}
401401
_ => {
@@ -548,7 +548,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
548548
expected.map_or("".to_string(),
549549
|e| {
550550
format!("mismatched types: expected \
551-
`{}` but found {}", e, actual)
551+
`{}`, found {}", e, actual)
552552
})},
553553
Some(expected),
554554
"a structure pattern".to_string(),
@@ -607,8 +607,8 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
607607
|expected,
608608
actual| {
609609
expected.map_or("".to_string(), |e| {
610-
format!("mismatched types: expected `{}` \
611-
but found {}", e, actual)
610+
format!("mismatched types: expected `{}`, \
611+
found {}", e, actual)
612612
}
613613
)},
614614
Some(expected),
@@ -645,7 +645,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) {
645645
|expected, actual| {
646646
expected.map_or("".to_string(),
647647
|e| {
648-
format!("mismatched types: expected `{}` but found {}",
648+
format!("mismatched types: expected `{}`, found {}",
649649
e, actual)
650650
})
651651
},
@@ -763,7 +763,7 @@ fn check_pointer_pat(pcx: &pat_ctxt,
763763
span,
764764
|expected, actual| {
765765
expected.map_or("".to_string(), |e| {
766-
format!("mismatched types: expected `{}` but found {}",
766+
format!("mismatched types: expected `{}`, found {}",
767767
e, actual)
768768
})
769769
},

0 commit comments

Comments
 (0)