提交 761fc16c 编写于 作者: J James Miller 提交者: James Miller

Fix-up PP Code to reflect new lifetime param syntax

上级 048ed148
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
use middle::ty; use middle::ty;
use middle::typeck; use middle::typeck;
use util::ppaux::{ty_to_str, region_to_str, Repr}; use util::ppaux::{ty_to_str, region_ptr_to_str, Repr};
use util::common::indenter; use util::common::indenter;
use core::uint; use core::uint;
...@@ -1026,7 +1026,7 @@ pub fn cmt_to_str(&self, cmt: cmt) -> ~str { ...@@ -1026,7 +1026,7 @@ pub fn cmt_to_str(&self, cmt: cmt) -> ~str {
} }
pub fn region_to_str(&self, r: ty::Region) -> ~str { pub fn region_to_str(&self, r: ty::Region) -> ~str {
region_to_str(self.tcx, r) region_ptr_to_str(self.tcx, r)
} }
} }
......
...@@ -693,7 +693,7 @@ fn set_debug_location(cx: @mut CrateContext, scope: DIScope, line: uint, col: ui ...@@ -693,7 +693,7 @@ fn set_debug_location(cx: @mut CrateContext, scope: DIScope, line: uint, col: ui
} }
/// Set current debug location at the beginning of the span /// Set current debug location at the beginning of the span
pub fn update_source_pos(bcx: @mut Block, span: span) { pub fn update_source_pos(bcx: block, span: span) {
if !bcx.sess().opts.debuginfo || (*span.lo == 0 && *span.hi == 0) { if !bcx.sess().opts.debuginfo || (*span.lo == 0 && *span.hi == 0) {
return; return;
} }
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
use middle::subst::Subst; use middle::subst::Subst;
use middle::typeck; use middle::typeck;
use middle; use middle;
use util::ppaux::{note_and_explain_region, bound_region_to_str}; use util::ppaux::{note_and_explain_region, bound_region_to_str, bound_region_ptr_to_str};
use util::ppaux::{trait_store_to_str, ty_to_str, vstore_to_str}; use util::ppaux::{trait_store_to_str, ty_to_str, vstore_to_str};
use util::ppaux::{Repr, UserString}; use util::ppaux::{Repr, UserString};
use util::common::{indenter}; use util::common::{indenter};
...@@ -3531,12 +3531,12 @@ fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str { ...@@ -3531,12 +3531,12 @@ fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str {
terr_regions_insufficiently_polymorphic(br, _) => { terr_regions_insufficiently_polymorphic(br, _) => {
fmt!("expected bound lifetime parameter %s, \ fmt!("expected bound lifetime parameter %s, \
but found concrete lifetime", but found concrete lifetime",
bound_region_to_str(cx, br)) bound_region_ptr_to_str(cx, br))
} }
terr_regions_overly_polymorphic(br, _) => { terr_regions_overly_polymorphic(br, _) => {
fmt!("expected concrete lifetime, \ fmt!("expected concrete lifetime, \
but found bound lifetime parameter %s", but found bound lifetime parameter %s",
bound_region_to_str(cx, br)) bound_region_ptr_to_str(cx, br))
} }
terr_vstores_differ(k, ref values) => { terr_vstores_differ(k, ref values) => {
fmt!("%s storage differs: expected %s but found %s", fmt!("%s storage differs: expected %s but found %s",
......
...@@ -107,7 +107,7 @@ ...@@ -107,7 +107,7 @@
use middle::typeck::no_params; use middle::typeck::no_params;
use middle::typeck::{require_same_types, method_map, vtable_map}; use middle::typeck::{require_same_types, method_map, vtable_map};
use util::common::{block_query, indenter, loop_query}; use util::common::{block_query, indenter, loop_query};
use util::ppaux::{bound_region_to_str}; use util::ppaux::{bound_region_to_str,bound_region_ptr_to_str};
use util::ppaux; use util::ppaux;
...@@ -680,7 +680,7 @@ pub fn search_in_scope_regions(&self, ...@@ -680,7 +680,7 @@ pub fn search_in_scope_regions(&self,
} else { } else {
result::Err(RegionError { result::Err(RegionError {
msg: fmt!("named region `%s` not in scope here", msg: fmt!("named region `%s` not in scope here",
bound_region_to_str(self.tcx(), br)), bound_region_ptr_to_str(self.tcx(), br)),
replacement: self.infcx().next_region_var_nb(span) replacement: self.infcx().next_region_var_nb(span)
}) })
} }
......
...@@ -690,13 +690,13 @@ fn constrain_regions_in_type( ...@@ -690,13 +690,13 @@ fn constrain_regions_in_type(
let tcx = rcx.fcx.ccx.tcx; let tcx = rcx.fcx.ccx.tcx;
debug!("constrain_regions_in_type(minimum_lifetime=%s, ty=%s)", debug!("constrain_regions_in_type(minimum_lifetime=%s, ty=%s)",
region_to_str(tcx, minimum_lifetime), region_to_str(tcx, "", false, minimum_lifetime),
ty_to_str(tcx, ty)); ty_to_str(tcx, ty));
do relate_nested_regions(tcx, Some(minimum_lifetime), ty) |r_sub, r_sup| { do relate_nested_regions(tcx, Some(minimum_lifetime), ty) |r_sub, r_sup| {
debug!("relate(r_sub=%s, r_sup=%s)", debug!("relate(r_sub=%s, r_sup=%s)",
region_to_str(tcx, r_sub), region_to_str(tcx, "", false, r_sub),
region_to_str(tcx, r_sup)); region_to_str(tcx, "", false, r_sup));
if r_sup.is_bound() || r_sub.is_bound() { if r_sup.is_bound() || r_sub.is_bound() {
// a bound region is one which appears inside an fn type. // a bound region is one which appears inside an fn type.
......
...@@ -149,7 +149,7 @@ fn replace_bound_regions( ...@@ -149,7 +149,7 @@ fn replace_bound_regions(
tcx.sess.bug( tcx.sess.bug(
fmt!("Bound region not found in \ fmt!("Bound region not found in \
in_scope_regions list: %s", in_scope_regions list: %s",
region_to_str(tcx, r))); region_to_str(tcx, "", false, r)));
} }
} }
} }
......
...@@ -821,7 +821,7 @@ pub fn replace_bound_regions_with_fresh_regions(&mut self, ...@@ -821,7 +821,7 @@ pub fn replace_bound_regions_with_fresh_regions(&mut self,
// debug message. // debug message.
let rvar = self.next_region_var_nb(span); let rvar = self.next_region_var_nb(span);
debug!("Bound region %s maps to %?", debug!("Bound region %s maps to %?",
bound_region_to_str(self.tcx, br), bound_region_to_str(self.tcx, "", false, br),
rvar); rvar);
rvar rvar
}); });
......
...@@ -179,7 +179,7 @@ fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> { ...@@ -179,7 +179,7 @@ fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
None, b) |br| { None, b) |br| {
let skol = self.infcx.region_vars.new_skolemized(br); let skol = self.infcx.region_vars.new_skolemized(br);
debug!("Bound region %s skolemized to %?", debug!("Bound region %s skolemized to %?",
bound_region_to_str(self.infcx.tcx, br), bound_region_to_str(self.infcx.tcx, "", false, br),
skol); skol);
skol skol
} }
......
...@@ -112,7 +112,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region) ...@@ -112,7 +112,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
idx + 1), idx + 1),
br_fresh(_) => fmt!("an anonymous lifetime defined on"), br_fresh(_) => fmt!("an anonymous lifetime defined on"),
_ => fmt!("the lifetime %s as defined on", _ => fmt!("the lifetime %s as defined on",
bound_region_to_str(cx, fr.bound_region)) bound_region_ptr_to_str(cx, fr.bound_region))
}; };
match cx.items.find(&fr.scope_id) { match cx.items.find(&fr.scope_id) {
...@@ -147,22 +147,23 @@ fn explain_span(cx: ctxt, heading: &str, span: span) ...@@ -147,22 +147,23 @@ fn explain_span(cx: ctxt, heading: &str, span: span)
} }
} }
pub fn bound_region_to_str(cx: ctxt, br: bound_region) -> ~str { pub fn bound_region_ptr_to_str(cx: ctxt, br: bound_region) -> ~str {
bound_region_to_str_space(cx, "&", br) bound_region_to_str(cx, "&", true, br)
} }
pub fn bound_region_to_str_space(cx: ctxt, pub fn bound_region_to_str(cx: ctxt,
prefix: &str, prefix: &str, space: bool,
br: bound_region) br: bound_region) -> ~str {
-> ~str { let space_str = if space { " " } else { "" };
if cx.sess.verbose() { return fmt!("%s%? ", prefix, br); }
if cx.sess.verbose() { return fmt!("%s%?%s", prefix, br, space_str); }
match br { match br {
br_named(id) => fmt!("%s'%s ", prefix, cx.sess.str_of(id)), br_named(id) => fmt!("%s'%s%s", prefix, cx.sess.str_of(id), space_str),
br_self => fmt!("%s'self ", prefix), br_self => fmt!("%s'self%s", prefix, space_str),
br_anon(_) => prefix.to_str(), br_anon(_) => prefix.to_str(),
br_fresh(_) => prefix.to_str(), br_fresh(_) => prefix.to_str(),
br_cap_avoid(_, br) => bound_region_to_str_space(cx, prefix, *br) br_cap_avoid(_, br) => bound_region_to_str(cx, prefix, space, *br)
} }
} }
...@@ -208,13 +209,15 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str { ...@@ -208,13 +209,15 @@ pub fn re_scope_id_to_str(cx: ctxt, node_id: ast::node_id) -> ~str {
// In general, if you are giving a region error message, // In general, if you are giving a region error message,
// you should use `explain_region()` or, better yet, // you should use `explain_region()` or, better yet,
// `note_and_explain_region()` // `note_and_explain_region()`
pub fn region_to_str(cx: ctxt, region: Region) -> ~str { pub fn region_ptr_to_str(cx: ctxt, region: Region) -> ~str {
region_to_str_space(cx, "&", region) region_to_str(cx, "&", true, region)
} }
pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str { pub fn region_to_str(cx: ctxt, prefix: &str, space: bool, region: Region) -> ~str {
let space_str = if space { " " } else { "" };
if cx.sess.verbose() { if cx.sess.verbose() {
return fmt!("%s%? ", prefix, region); return fmt!("%s%?%s", prefix, region, space_str);
} }
// These printouts are concise. They do not contain all the information // These printouts are concise. They do not contain all the information
...@@ -223,14 +226,14 @@ pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str { ...@@ -223,14 +226,14 @@ pub fn region_to_str_space(cx: ctxt, prefix: &str, region: Region) -> ~str {
// `explain_region()` or `note_and_explain_region()`. // `explain_region()` or `note_and_explain_region()`.
match region { match region {
re_scope(_) => prefix.to_str(), re_scope(_) => prefix.to_str(),
re_bound(br) => bound_region_to_str_space(cx, prefix, br), re_bound(br) => bound_region_to_str(cx, prefix, space, br),
re_free(ref fr) => bound_region_to_str_space(cx, prefix, fr.bound_region), re_free(ref fr) => bound_region_to_str(cx, prefix, space, fr.bound_region),
re_infer(ReSkolemized(_, br)) => { re_infer(ReSkolemized(_, br)) => {
bound_region_to_str_space(cx, prefix, br) bound_region_to_str(cx, prefix, space, br)
} }
re_infer(ReVar(_)) => prefix.to_str(), re_infer(ReVar(_)) => prefix.to_str(),
re_static => fmt!("%s'static ", prefix), re_static => fmt!("%s'static%s", prefix, space_str),
re_empty => fmt!("%s'<empty> ", prefix) re_empty => fmt!("%s'<empty>%s", prefix, space_str)
} }
} }
...@@ -256,7 +259,7 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str { ...@@ -256,7 +259,7 @@ pub fn vstore_to_str(cx: ctxt, vs: ty::vstore) -> ~str {
ty::vstore_fixed(n) => fmt!("%u", n), ty::vstore_fixed(n) => fmt!("%u", n),
ty::vstore_uniq => ~"~", ty::vstore_uniq => ~"~",
ty::vstore_box => ~"@", ty::vstore_box => ~"@",
ty::vstore_slice(r) => region_to_str_space(cx, "&", r) ty::vstore_slice(r) => region_ptr_to_str(cx, r)
} }
} }
...@@ -264,7 +267,7 @@ pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str { ...@@ -264,7 +267,7 @@ pub fn trait_store_to_str(cx: ctxt, s: ty::TraitStore) -> ~str {
match s { match s {
ty::UniqTraitStore => ~"~", ty::UniqTraitStore => ~"~",
ty::BoxTraitStore => ~"@", ty::BoxTraitStore => ~"@",
ty::RegionTraitStore(r) => region_to_str_space(cx, "&", r) ty::RegionTraitStore(r) => region_ptr_to_str(cx, r)
} }
} }
...@@ -340,7 +343,7 @@ fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str ...@@ -340,7 +343,7 @@ fn closure_to_str(cx: ctxt, cty: &ty::ClosureTy) -> ~str
(ast::OwnedSigil, ty::re_static) => {} (ast::OwnedSigil, ty::re_static) => {}
(_, region) => { (_, region) => {
s.push_str(region_to_str_space(cx, "", region)); s.push_str(region_to_str(cx, "", true, region));
} }
} }
...@@ -414,7 +417,7 @@ fn field_to_str(cx: ctxt, f: field) -> ~str { ...@@ -414,7 +417,7 @@ fn field_to_str(cx: ctxt, f: field) -> ~str {
ty_uniq(ref tm) => ~"~" + mt_to_str(cx, tm), ty_uniq(ref tm) => ~"~" + mt_to_str(cx, tm),
ty_ptr(ref tm) => ~"*" + mt_to_str(cx, tm), ty_ptr(ref tm) => ~"*" + mt_to_str(cx, tm),
ty_rptr(r, ref tm) => { ty_rptr(r, ref tm) => {
region_to_str_space(cx, "&", r) + mt_to_str(cx, tm) region_ptr_to_str(cx, r) + mt_to_str(cx, tm)
} }
ty_unboxed_vec(ref tm) => { fmt!("unboxed_vec<%s>", mt_to_str(cx, tm)) } ty_unboxed_vec(ref tm) => { fmt!("unboxed_vec<%s>", mt_to_str(cx, tm)) }
ty_type => ~"type", ty_type => ~"type",
...@@ -431,13 +434,15 @@ fn field_to_str(cx: ctxt, f: field) -> ~str { ...@@ -431,13 +434,15 @@ fn field_to_str(cx: ctxt, f: field) -> ~str {
ty_infer(infer_ty) => infer_ty.to_str(), ty_infer(infer_ty) => infer_ty.to_str(),
ty_err => ~"[type error]", ty_err => ~"[type error]",
ty_param(param_ty {idx: id, def_id: did}) => { ty_param(param_ty {idx: id, def_id: did}) => {
let mut parm = (('T' as uint) + id) as char;
if (parm as uint) > ('Z' as uint) {
parm = (parm as uint - 26) as char;
}
if cx.sess.verbose() { if cx.sess.verbose() {
fmt!("'%s:%?", fmt!("%c:%?", parm, did)
str::from_bytes([('a' as u8) + (id as u8)]),
did)
} else { } else {
fmt!("'%s", fmt!("%c", parm)
str::from_bytes([('a' as u8) + (id as u8)]))
} }
} }
ty_self(*) => ~"Self", ty_self(*) => ~"Self",
...@@ -468,18 +473,20 @@ pub fn parameterized(cx: ctxt, ...@@ -468,18 +473,20 @@ pub fn parameterized(cx: ctxt,
self_r: Option<ty::Region>, self_r: Option<ty::Region>,
tps: &[ty::t]) -> ~str { tps: &[ty::t]) -> ~str {
let r_str = match self_r { let mut strs = ~[];
None => ~"", match self_r {
None => (),
Some(r) => { Some(r) => {
region_to_str(cx, r) strs.push(region_to_str(cx, "", false, r))
} }
}; };
if tps.len() > 0u { strs += vec::map(tps, |t| ty_to_str(cx, *t));
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
fmt!("%s%s<%s>", r_str, base, strs.connect(",")) if strs.len() > 0u {
fmt!("%s<%s>", base, strs.connect(","))
} else { } else {
fmt!("%s%s", r_str, base) fmt!("%s", base)
} }
} }
...@@ -597,7 +604,7 @@ fn repr(&self, tcx: ctxt) -> ~str { ...@@ -597,7 +604,7 @@ fn repr(&self, tcx: ctxt) -> ~str {
impl Repr for ty::Region { impl Repr for ty::Region {
fn repr(&self, tcx: ctxt) -> ~str { fn repr(&self, tcx: ctxt) -> ~str {
region_to_str(tcx, *self) region_to_str(tcx, "", false, *self)
} }
} }
......
...@@ -16,11 +16,11 @@ ...@@ -16,11 +16,11 @@
struct a_class<'self> { x:&'self int } struct a_class<'self> { x:&'self int }
fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> { fn a_fn1<'a,'b>(e: an_enum<'a>) -> an_enum<'b> {
return e; //~ ERROR mismatched types: expected `an_enum/&'b ` but found `an_enum/&'a ` return e; //~ ERROR mismatched types: expected `an_enum<'b>` but found `an_enum<'a>`
} }
fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> { fn a_fn3<'a,'b>(e: a_class<'a>) -> a_class<'b> {
return e; //~ ERROR mismatched types: expected `a_class/&'b ` but found `a_class/&'a ` return e; //~ ERROR mismatched types: expected `a_class<'b>` but found `a_class<'a>`
} }
fn a_fn4<'a,'b>() { fn a_fn4<'a,'b>() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册