diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2012-02-02 16:50:17 -0800 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2012-02-05 09:12:44 -0800 |
| commit | 77b06d24cd76bf808138f1f7df4dcff40260ff38 (patch) | |
| tree | 1830c6000f2c4a02be320e088389979cefb1414f /src/comp/util | |
| parent | 5163606d060ccb2c6462d34f590e2a1f30ce4a1f (diff) | |
| download | rust-77b06d24cd76bf808138f1f7df4dcff40260ff38.tar.gz rust-77b06d24cd76bf808138f1f7df4dcff40260ff38.zip | |
infer modes rather than overwriting with expected ty
Diffstat (limited to 'src/comp/util')
| -rw-r--r-- | src/comp/util/ppaux.rs | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/src/comp/util/ppaux.rs b/src/comp/util/ppaux.rs index 4772bbc4fc3..512b02ca734 100644 --- a/src/comp/util/ppaux.rs +++ b/src/comp/util/ppaux.rs @@ -4,32 +4,18 @@ import middle::ty; import middle::ty::*; import metadata::encoder; import syntax::print::pprust; -import syntax::print::pprust::{path_to_str, constr_args_to_str, proto_to_str}; +import syntax::print::pprust::{path_to_str, constr_args_to_str, proto_to_str, + mode_to_str}; import syntax::{ast, ast_util}; import middle::ast_map; -fn mode_str(m: ast::mode) -> str { - alt m { - ast::by_ref { "&&" } - ast::by_val { "++" } - ast::by_mut_ref { "&" } - ast::by_move { "-" } - ast::by_copy { "+" } - _ { "" } - } -} - fn ty_to_str(cx: ctxt, typ: t) -> str { fn fn_input_to_str(cx: ctxt, input: {mode: ast::mode, ty: t}) -> str { - let modestr = alt input.mode { - ast::by_ref { - if ty::type_is_immediate(cx, input.ty) { "&&" } else { "" } - } - ast::by_val { - if ty::type_is_immediate(cx, input.ty) { "" } else { "++" } - } - _ { mode_str(input.mode) } + let arg_mode = ty::arg_mode(cx, input); + let modestr = { + if arg_mode == ty::default_arg_mode_for_ty(cx, input.ty) { "" } + else { mode_to_str(input.mode) } }; modestr + ty_to_str(cx, input.ty) } |
