When pretty-printing fn types, leave off arg modes when they are the default
This reduces ++/&& spam in the output to a bare minimum. Issue #1507
This commit is contained in:
parent
e1c50c4410
commit
c2fe7b6398
@ -22,8 +22,16 @@ fn mode_str(m: ty::mode) -> str {
|
||||
fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||
fn fn_input_to_str(cx: ctxt, input: {mode: middle::ty::mode, ty: t}) ->
|
||||
str {
|
||||
let s = mode_str(input.mode);
|
||||
ret s + ty_to_str(cx, input.ty);
|
||||
let modestr = alt input.mode {
|
||||
ast::by_ref. {
|
||||
ty::type_is_immediate(cx, input.ty) ? "&&" : ""
|
||||
}
|
||||
ast::by_val. {
|
||||
ty::type_is_immediate(cx, input.ty) ? "" : "++"
|
||||
}
|
||||
_ { mode_str(input.mode) }
|
||||
};
|
||||
modestr + ty_to_str(cx, input.ty)
|
||||
}
|
||||
fn fn_to_str(cx: ctxt, proto: ast::proto, ident: option::t<ast::ident>,
|
||||
inputs: [arg], output: t, cf: ast::ret_style,
|
||||
|
@ -2,5 +2,5 @@ fn main() {
|
||||
fn f() { }
|
||||
fn g(i: int) { }
|
||||
let x = f == g;
|
||||
//!^ ERROR expected `native fn()` but found `native fn(++int)`
|
||||
//!^ ERROR expected `native fn()` but found `native fn(int)`
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
fn main(foo: {x: int, y: int}) {
|
||||
//!^ ERROR wrong type in main function: found `native fn(&&{x: int,y: int})`
|
||||
//!^ ERROR wrong type in main function: found `native fn({x: int,y: int})`
|
||||
}
|
||||
|
@ -4,5 +4,5 @@ fn test(f: fn@(uint) -> uint) -> uint {
|
||||
|
||||
fn main() {
|
||||
let f = fn~(x: uint) -> uint { ret 4u; };
|
||||
log(debug, test(f)); //! ERROR expected `fn@(++uint) -> uint`
|
||||
log(debug, test(f)); //! ERROR expected `fn@(uint) -> uint`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user