Skip to content

Adjust the error messages to match the pattern "expected foo, found bar" #8314

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 64 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
113cc0e
adjust error message to coding style
Aug 5, 2013
10c1853
rebase
Aug 6, 2013
8129655
rebase
Aug 6, 2013
5c8803b
std: Speed up str::is_utf8
Aug 2, 2013
c1c405b
Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddr
stepancheg Aug 2, 2013
48e1af8
Suppress a libuv leak on mac
brson Aug 3, 2013
db6ff76
etc: add the `in` keyword to the emacs mode.
huonw Aug 3, 2013
b142077
Fix building problems in extra::unicode.
omasanori Aug 2, 2013
4a09595
trans_arg_expr: Omit extra copies for rvalues
dotdash Aug 3, 2013
0ab4965
Work around #8256, do not fail the task, just return None
emberian Aug 4, 2013
4b4960c
librustc: Implement `#[no_main]`, which omits the entry point entirely.
pcwalton Aug 4, 2013
35318b7
std: Remove gc and stackwalk
brson Aug 2, 2013
0dcaf07
Additional check in treemap iterator test.
dim-an Jul 31, 2013
1b54e40
Remove redundant print.
dim-an Aug 1, 2013
d946c8c
Implemented TreeMap::{lower_bound_iter,upper_bound_iter}
dim-an Aug 1, 2013
f338e04
Try to fix a periodic windows build failure due to broken rwildcard m…
brson May 21, 2013
017740d
Update LLVM
alexcrichton May 24, 2013
afd12bf
Fix build issues once LLVM has been upgraded
alexcrichton May 25, 2013
59e8672
Fix setting the fixed stack segment attribute on LLVM functions
alexcrichton May 26, 2013
0ebf15c
Add a workaround for 8199 for now
alexcrichton Aug 1, 2013
1e39db8
Integrate new arm patch and fix an LLVM bug
alexcrichton Aug 2, 2013
e6dd0ea
Fixed str::raw::push_byte
sfackler Aug 4, 2013
9eaeacd
std::rt: Improve the error message when the thread-local ptr is null
brson Aug 4, 2013
c589924
std::rt: Run the tests for Local in a bare thread
brson Aug 4, 2013
d5c4733
std::rt: 3MB stacks!
brson Aug 4, 2013
e4080f6
std::rt: Don't allow schedulers to exit before handling all messages
brson Aug 4, 2013
5d020d1
std::rt: Remove the test for context()
brson Aug 4, 2013
59a5816
Remove old tests and code for `select`
brson Aug 4, 2013
b14b77a
fix warning still mentioning the `again` keyword
thestinger Aug 4, 2013
eabb4fa
Implemented iterator for TrieMap
dim-an Aug 4, 2013
a220768
Remove debug printing.
dim-an Aug 4, 2013
0a686b3
Add support for vanilla linux on arm.
luqmana Aug 1, 2013
f10e934
extra: Don't recurse in DList drop glue. #8295
brson Aug 5, 2013
9624c20
Open files in binary mode. Closes #3948
darkf Aug 5, 2013
92aa473
std: Fix newsched logging truncation
brson Aug 5, 2013
8ce8dfe
std::rt: Schedule more scheduler callbacks to avoid dropping messages
brson Aug 5, 2013
8949610
std::rt: Use magic to make TLS work from annihilated boxes. #8302
brson Aug 5, 2013
b74e3e7
Add extra::arena::Arena::new{, _with_size}.
omasanori Aug 5, 2013
987ad25
std: Use correct lifetime parameter on str::raw::slice_bytes
Aug 5, 2013
d28f85a
Make node_id_to_str print more useful info in some cases. Closes #2410.
msullivan Jul 29, 2013
4114353
Fix an unused variable warning and clean up some dead code/names.
msullivan Jul 29, 2013
8a421ec
Warn when using -o option on libraries. Closes #6554.
msullivan Jul 30, 2013
6446c82
Get rid of some NOTEs.
msullivan Jul 30, 2013
0ba3f91
Improve debug spew in _match.
msullivan Aug 2, 2013
b204783
adjust error message to coding style
Aug 5, 2013
2c581e1
Use TreeMap's ord implementation for Json
alexcrichton Aug 5, 2013
abd2ffb
Updated std::Option, std::Either and std::Result
Kimundi Aug 3, 2013
1662f69
(cleanup) Uncomment an assertion that now holds.
bblum Aug 2, 2013
ed81439
Lazily initialize 'leaf node' taskgroups for unlinked spawns, for an …
bblum Aug 5, 2013
94f8232
std: Add .consume_iter() for Option, to make it reusable
Aug 3, 2013
55657e6
std: Convert Result to use external iterators
Aug 3, 2013
ecee285
std: Remove unused trait bound in Result::map
Aug 3, 2013
2c21b99
std: Implement RandomAccessIterator for Invert
Aug 3, 2013
1c01b1d
std: Improve vec::ChunkIter
Aug 3, 2013
c2d4812
std: Add iterator::Repeat to repeat an element endlessly
Aug 3, 2013
a2f116c
std: Rewrite the HashSet set operation iterators
Aug 3, 2013
e843b88
std: Use method name Option::consume
Aug 3, 2013
cbbca97
std: Improve the documentation for iterator::Invert
Aug 3, 2013
f0e345b
extra: Simplify the bitv iterators using Repeat
Aug 4, 2013
eccf370
std: Remove uint::iterate, replaced by `range`
Aug 4, 2013
282fb72
std: Fix bug in ChunkIter::idx
Aug 4, 2013
26d74df
Move EnumSet into libextra
sammykim Jul 26, 2013
ab93bc4
rebase
Aug 6, 2013
ea07e33
Merge branch 'but_found' of github.com:kud1ing/rust into but_found
Aug 6, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libextra/ebml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ pub mod reader {
self.pos = r_doc.end;
let str = r_doc.as_str_slice();
if lbl != str {
fail!("Expected label %s but found %s", lbl, str);
fail!("Expected label %s, found %s", lbl, str);
}
}
}
Expand All @@ -326,7 +326,7 @@ pub mod reader {
r_doc.start,
r_doc.end);
if r_tag != (exp_tag as uint) {
fail!("expected EBML doc with tag %? but found tag %?", exp_tag, r_tag);
fail!("expected EBML doc with tag %?, found tag %?", exp_tag, r_tag);
}
if r_doc.end > self.parent.end {
fail!("invalid EBML, child extends to 0x%x, parent to 0x%x",
Expand Down
8 changes: 4 additions & 4 deletions src/libextra/terminfo/parser/compiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
// Check magic number
let magic = file.read_le_u16();
if (magic != 0x011A) {
return Err(fmt!("invalid magic number: expected %x but found %x", 0x011A, magic as uint));
return Err(fmt!("invalid magic number: expected %x, found %x", 0x011A, magic as uint));
}

let names_bytes = file.read_le_i16() as int;
Expand All @@ -196,19 +196,19 @@ pub fn parse(file: @Reader, longnames: bool) -> Result<~TermInfo, ~str> {
debug!("string_table_bytes = %?", string_table_bytes);

if (bools_bytes as uint) > boolnames.len() {
error!("expected bools_bytes to be less than %? but found %?", boolnames.len(),
error!("expected bools_bytes to be less than %?, found %?", boolnames.len(),
bools_bytes);
return Err(~"incompatible file: more booleans than expected");
}

if (numbers_count as uint) > numnames.len() {
error!("expected numbers_count to be less than %? but found %?", numnames.len(),
error!("expected numbers_count to be less than %?, found %?", numnames.len(),
numbers_count);
return Err(~"incompatible file: more numbers than expected");
}

if (string_offsets_count as uint) > stringnames.len() {
error!("expected string_offsets_count to be less than %? but found %?", stringnames.len(),
error!("expected string_offsets_count to be less than %?, found %?", stringnames.len(),
string_offsets_count);
return Err(~"incompatible file: more string offsets than expected");
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/metadata/tydecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,12 @@ pub fn parse_def_id(buf: &[u8]) -> ast::def_id {

let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as int,
None => fail!("internal error: parse_def_id: crate number expected, but found %?",
None => fail!("internal error: parse_def_id: crate number expected, found %?",
crate_part)
};
let def_num = match uint::parse_bytes(def_part, 10u) {
Some(dn) => dn as int,
None => fail!("internal error: parse_def_id: id expected, but found %?",
None => fail!("internal error: parse_def_id: id expected, found %?",
def_part)
};
ast::def_id { crate: crate_num, node: def_num }
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/trans/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ pub fn assert_is_binding_or_wild(bcx: @mut Block, p: @ast::pat) {
if !pat_is_binding_or_wild(bcx.tcx().def_map, p) {
bcx.sess().span_bug(
p.span,
fmt!("Expected an identifier pattern but found p: %s",
fmt!("Expected an identifier pattern, but found p: %s",
p.repr(bcx.tcx())));
}
}
Expand Down
56 changes: 28 additions & 28 deletions src/librustc/middle/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3397,15 +3397,15 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
match *err {
terr_mismatch => ~"types differ",
terr_purity_mismatch(values) => {
fmt!("expected %s fn but found %s fn",
fmt!("expected %s fn, found %s fn",
values.expected.to_str(), values.found.to_str())
}
terr_abi_mismatch(values) => {
fmt!("expected %s fn but found %s fn",
fmt!("expected %s fn, found %s fn",
values.expected.to_str(), values.found.to_str())
}
terr_onceness_mismatch(values) => {
fmt!("expected %s fn but found %s fn",
fmt!("expected %s fn, found %s fn",
values.expected.to_str(), values.found.to_str())
}
terr_sigil_mismatch(values) => {
Expand All @@ -3419,25 +3419,25 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
terr_ptr_mutability => ~"pointers differ in mutability",
terr_ref_mutability => ~"references differ in mutability",
terr_ty_param_size(values) => {
fmt!("expected a type with %? type params \
but found one with %? type params",
fmt!("expected a type with %? type params, \
found one with %? type params",
values.expected, values.found)
}
terr_tuple_size(values) => {
fmt!("expected a tuple with %? elements \
but found one with %? elements",
fmt!("expected a tuple with %? elements, \
found one with %? elements",
values.expected, values.found)
}
terr_record_size(values) => {
fmt!("expected a record with %? fields \
but found one with %? fields",
fmt!("expected a record with %? fields, \
found one with %? fields",
values.expected, values.found)
}
terr_record_mutability => {
~"record elements differ in mutability"
}
terr_record_fields(values) => {
fmt!("expected a record with field `%s` but found one with field \
fmt!("expected a record with field `%s`, found one with field \
`%s`",
cx.sess.str_of(values.expected),
cx.sess.str_of(values.found))
Expand All @@ -3454,22 +3454,22 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
}
terr_regions_insufficiently_polymorphic(br, _) => {
fmt!("expected bound lifetime parameter %s, \
but found concrete lifetime",
found concrete lifetime",
bound_region_ptr_to_str(cx, br))
}
terr_regions_overly_polymorphic(br, _) => {
fmt!("expected concrete lifetime, \
but found bound lifetime parameter %s",
found bound lifetime parameter %s",
bound_region_ptr_to_str(cx, br))
}
terr_vstores_differ(k, ref values) => {
fmt!("%s storage differs: expected %s but found %s",
fmt!("%s storage differs: expected %s, found %s",
terr_vstore_kind_to_str(k),
vstore_to_str(cx, (*values).expected),
vstore_to_str(cx, (*values).found))
}
terr_trait_stores_differ(_, ref values) => {
fmt!("trait storage differs: expected %s but found %s",
fmt!("trait storage differs: expected %s, found %s",
trait_store_to_str(cx, (*values).expected),
trait_store_to_str(cx, (*values).found))
}
Expand All @@ -3478,38 +3478,38 @@ pub fn type_err_to_str(cx: ctxt, err: &type_err) -> ~str {
type_err_to_str(cx, err))
}
terr_sorts(values) => {
fmt!("expected %s but found %s",
fmt!("expected %s, found %s",
ty_sort_str(cx, values.expected),
ty_sort_str(cx, values.found))
}
terr_traits(values) => {
fmt!("expected trait %s but found trait %s",
fmt!("expected trait %s, found trait %s",
item_path_str(cx, values.expected),
item_path_str(cx, values.found))
}
terr_builtin_bounds(values) => {
if values.expected.is_empty() {
fmt!("expected no bounds but found `%s`",
fmt!("expected no bounds, found `%s`",
values.found.user_string(cx))
} else if values.found.is_empty() {
fmt!("expected bounds `%s` but found no bounds",
fmt!("expected bounds `%s`, found no bounds",
values.expected.user_string(cx))
} else {
fmt!("expected bounds `%s` but found bounds `%s`",
fmt!("expected bounds `%s`, found bounds `%s`",
values.expected.user_string(cx),
values.found.user_string(cx))
}
}
terr_integer_as_char => {
fmt!("expected an integral type but found char")
fmt!("expected an integral type, found char")
}
terr_int_mismatch(ref values) => {
fmt!("expected %s but found %s",
fmt!("expected %s, found %s",
values.expected.to_str(),
values.found.to_str())
}
terr_float_mismatch(ref values) => {
fmt!("expected %s but found %s",
fmt!("expected %s, found %s",
values.expected.to_str(),
values.found.to_str())
}
Expand Down Expand Up @@ -4335,7 +4335,7 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::expr) ->
const_eval::const_int(count) => if count < 0 {
tcx.ty_ctxt().sess.span_err(count_expr.span,
"expected positive integer for \
repeat count but found negative integer");
repeat count, found negative integer");
return 0;
} else {
return count as uint
Expand All @@ -4344,26 +4344,26 @@ pub fn eval_repeat_count<T: ExprTyProvider>(tcx: &T, count_expr: &ast::expr) ->
const_eval::const_float(count) => {
tcx.ty_ctxt().sess.span_err(count_expr.span,
"expected positive integer for \
repeat count but found float");
repeat count, found float");
return count as uint;
}
const_eval::const_str(_) => {
tcx.ty_ctxt().sess.span_err(count_expr.span,
"expected positive integer for \
repeat count but found string");
repeat count, found string");
return 0;
}
const_eval::const_bool(_) => {
tcx.ty_ctxt().sess.span_err(count_expr.span,
"expected positive integer for \
repeat count but found boolean");
repeat count, found boolean");
return 0;
}
},
Err(*) => {
tcx.ty_ctxt().sess.span_err(count_expr.span,
"expected constant integer for repeat count \
but found variable");
"expected constant integer for \
repeat count, found variable");
return 0;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ fn ast_path_substs<AC:AstConv,RS:region_scope + Clone + 'static>(
if !vec::same_length(*decl_generics.type_param_defs, path.types) {
this.tcx().sess.span_fatal(
path.span,
fmt!("wrong number of type arguments: expected %u but found %u",
fmt!("wrong number of type arguments: expected %u, found %u",
decl_generics.type_param_defs.len(), path.types.len()));
}
let tps = path.types.map(|a_t| ast_ty_to_ty(this, rscope, a_t));
Expand Down
14 changes: 7 additions & 7 deletions src/librustc/middle/typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path,
fcx.infcx().type_error_message_str_with_expected(pat.span,
|expected, actual| {
expected.map_default(~"", |e| {
fmt!("mismatched types: expected `%s` but found %s",
fmt!("mismatched types: expected `%s`, found %s",
*e, actual)})},
Some(expected), ~"a structure pattern",
None);
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn check_pat_variant(pcx: &pat_ctxt, pat: @ast::pat, path: &ast::Path,
fcx.infcx().type_error_message_str_with_expected(pat.span,
|expected, actual| {
expected.map_default(~"", |e| {
fmt!("mismatched types: expected `%s` but found %s",
fmt!("mismatched types: expected `%s`, found %s",
*e, actual)})},
Some(expected), ~"an enum or structure pattern",
None);
Expand Down Expand Up @@ -341,7 +341,7 @@ pub fn check_struct_pat(pcx: &pat_ctxt, pat_id: ast::NodeId, 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`, found `%s`",
fcx.infcx().ty_to_str(expected),
name));
}
Expand Down Expand Up @@ -500,7 +500,7 @@ 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",
fmt!("mismatched types: expected `%s`, found struct",
fcx.infcx().ty_to_str(expected)));
error_happened = true;
}
Expand Down Expand Up @@ -536,7 +536,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
};
fcx.infcx().type_error_message_str_with_expected(pat.span, |expected, actual| {
expected.map_default(~"", |e| {
fmt!("mismatched types: expected `%s` but found %s",
fmt!("mismatched types: expected `%s`, found %s",
*e, actual)})}, Some(expected), ~"tuple", Some(&type_error));
fcx.write_error(pat.id);
}
Expand Down Expand Up @@ -585,7 +585,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: @ast::pat, expected: ty::t) {
pat.span,
|expected, actual| {
expected.map_default(~"", |e| {
fmt!("mismatched types: expected `%s` but found %s",
fmt!("mismatched types: expected `%s`, found %s",
*e, actual)})},
Some(expected),
~"a vector pattern",
Expand Down Expand Up @@ -643,7 +643,7 @@ pub fn check_pointer_pat(pcx: &pat_ctxt,
span,
|expected, actual| {
expected.map_default(~"", |e| {
fmt!("mismatched types: expected `%s` but found %s",
fmt!("mismatched types: expected `%s`, found %s",
*e, actual)})},
Some(expected),
fmt!("%s pattern", match pointer_kind {
Expand Down
23 changes: 11 additions & 12 deletions src/librustc/middle/typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
ty::ty_bool => {}
_ => fcx.type_error_message(call_expr.span, |actual| {
fmt!("expected `for` closure to return `bool`, \
but found `%s`", actual) },
, found `%s`", actual) },
output, None)
}
ty::mk_nil()
Expand Down Expand Up @@ -1358,8 +1358,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
ty::ty_closure(ty::ClosureTy {sig: ref sig, _}) => sig,
_ => {
fcx.type_error_message(call_expr.span, |actual| {
fmt!("expected function but \
found `%s`", actual) }, fn_ty, None);
fmt!("expected function, found `%s`", actual) }, fn_ty, None);
&error_fn_sig
}
};
Expand Down Expand Up @@ -2751,7 +2750,7 @@ pub fn check_expr_with_unifier(fcx: @mut FnCtxt,
pub fn require_integral(fcx: @mut FnCtxt, sp: span, t: ty::t) {
if !type_is_integral(fcx, sp, t) {
fcx.type_error_message(sp, |actual| {
fmt!("mismatched types: expected integral type but found `%s`",
fmt!("mismatched types: expected integral type, found `%s`",
actual)
}, t, None);
}
Expand Down Expand Up @@ -3131,28 +3130,28 @@ 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, 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, 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, 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, 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, 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, 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, found self ty");
}
ast::def_method(*) => {
fcx.ccx.tcx.sess.span_bug(sp, "expected value but found method");
fcx.ccx.tcx.sess.span_bug(sp, "expected value, found method");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/check/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fn relate_trait_refs(vcx: &VtableContext,
let tcx = vcx.tcx();
tcx.sess.span_err(
location_info.span,
fmt!("expected %s, but found %s (%s)",
fmt!("expected %s, found %s (%s)",
ppaux::trait_ref_to_str(tcx, &r_exp_trait_ref),
ppaux::trait_ref_to_str(tcx, &r_act_trait_ref),
ty::type_err_to_str(tcx, err)));
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/middle/typeck/infer/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,4 @@ We make use of a trait-like impementation strategy to consolidate
duplicated code between subtypes, GLB, and LUB computations. See the
section on "Type Combining" below for details.

*/
*/
Loading