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

Fix-up PP Code to reflect new lifetime param syntax

上级 048ed148
......@@ -50,7 +50,7 @@
use middle::ty;
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 core::uint;
......@@ -1026,7 +1026,7 @@ pub fn cmt_to_str(&self, cmt: cmt) -> ~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
}
/// 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) {
return;
}
......
......@@ -21,7 +21,7 @@
use middle::subst::Subst;
use middle::typeck;
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::{Repr, UserString};
use util::common::{indenter};
......@@ -3531,12 +3531,12 @@ fn terr_vstore_kind_to_str(k: terr_vstore_kind) -> ~str {
terr_regions_insufficiently_polymorphic(br, _) => {
fmt!("expected bound lifetime parameter %s, \
but found concrete lifetime",
bound_region_to_str(cx, br))
bound_region_ptr_to_str(cx, br))
}
terr_regions_overly_polymorphic(br, _) => {
fmt!("expected concrete lifetime, \
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) => {
fmt!("%s storage differs: expected %s but found %s",
......
......@@ -107,7 +107,7 @@
use middle::typeck::no_params;
use middle::typeck::{require_same_types, method_map, vtable_map};
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;
......@@ -680,7 +680,7 @@ pub fn search_in_scope_regions(&self,
} else {
result::Err(RegionError {
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)
})
}
......
......@@ -690,13 +690,13 @@ fn constrain_regions_in_type(
let tcx = rcx.fcx.ccx.tcx;
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));
do relate_nested_regions(tcx, Some(minimum_lifetime), ty) |r_sub, r_sup| {
debug!("relate(r_sub=%s, r_sup=%s)",
region_to_str(tcx, r_sub),
region_to_str(tcx, r_sup));
region_to_str(tcx, "", false, r_sub),
region_to_str(tcx, "", false, r_sup));
if r_sup.is_bound() || r_sub.is_bound() {
// a bound region is one which appears inside an fn type.
......
......@@ -149,7 +149,7 @@ fn replace_bound_regions(
tcx.sess.bug(
fmt!("Bound region not found in \
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,
// debug message.
let rvar = self.next_region_var_nb(span);
debug!("Bound region %s maps to %?",
bound_region_to_str(self.tcx, br),
bound_region_to_str(self.tcx, "", false, br),
rvar);
rvar
});
......
......@@ -179,7 +179,7 @@ fn fn_sigs(&self, a: &ty::FnSig, b: &ty::FnSig) -> cres<ty::FnSig> {
None, b) |br| {
let skol = self.infcx.region_vars.new_skolemized(br);
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
}
......
......@@ -112,7 +112,7 @@ pub fn explain_region_and_span(cx: ctxt, region: ty::Region)
idx + 1),
br_fresh(_) => fmt!("an anonymous lifetime 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) {
......@@ -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 {
bound_region_to_str_space(cx, "&", br)
pub fn bound_region_ptr_to_str(cx: ctxt, br: bound_region) -> ~str {
bound_region_to_str(cx, "&", true, br)
}
pub fn bound_region_to_str_space(cx: ctxt,
prefix: &str,
br: bound_region)
-> ~str {
if cx.sess.verbose() { return fmt!("%s%? ", prefix, br); }
pub fn bound_region_to_str(cx: ctxt,
prefix: &str, space: bool,
br: bound_region) -> ~str {
let space_str = if space { " " } else { "" };
if cx.sess.verbose() { return fmt!("%s%?%s", prefix, br, space_str); }
match br {
br_named(id) => fmt!("%s'%s ", prefix, cx.sess.str_of(id)),
br_self => fmt!("%s'self ", prefix),
br_named(id) => fmt!("%s'%s%s", prefix, cx.sess.str_of(id), space_str),
br_self => fmt!("%s'self%s", prefix, space_str),
br_anon(_) => 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 {
// In general, if you are giving a region error message,
// you should use `explain_region()` or, better yet,
// `note_and_explain_region()`
pub fn region_to_str(cx: ctxt, region: Region) -> ~str {
region_to_str_space(cx, "&", region)
pub fn region_ptr_to_str(cx: ctxt, region: Region) -> ~str {
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() {
return fmt!("%s%? ", prefix, region);
return fmt!("%s%?%s", prefix, region, space_str);
}
// 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 {
// `explain_region()` or `note_and_explain_region()`.
match region {
re_scope(_) => prefix.to_str(),
re_bound(br) => bound_region_to_str_space(cx, prefix, br),
re_free(ref fr) => bound_region_to_str_space(cx, prefix, fr.bound_region),
re_bound(br) => bound_region_to_str(cx, prefix, space, br),
re_free(ref fr) => bound_region_to_str(cx, prefix, space, fr.bound_region),
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_static => fmt!("%s'static ", prefix),
re_empty => fmt!("%s'<empty> ", prefix)
re_static => fmt!("%s'static%s", prefix, space_str),
re_empty => fmt!("%s'<empty>%s", prefix, space_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_uniq => ~"~",
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 {
match s {
ty::UniqTraitStore => ~"~",
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
(ast::OwnedSigil, ty::re_static) => {}
(_, 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 {
ty_uniq(ref tm) => ~"~" + mt_to_str(cx, tm),
ty_ptr(ref tm) => ~"*" + mt_to_str(cx, 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_type => ~"type",
......@@ -431,13 +434,15 @@ fn field_to_str(cx: ctxt, f: field) -> ~str {
ty_infer(infer_ty) => infer_ty.to_str(),
ty_err => ~"[type error]",
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() {
fmt!("'%s:%?",
str::from_bytes([('a' as u8) + (id as u8)]),
did)
fmt!("%c:%?", parm, did)
} else {
fmt!("'%s",
str::from_bytes([('a' as u8) + (id as u8)]))
fmt!("%c", parm)
}
}
ty_self(*) => ~"Self",
......@@ -468,18 +473,20 @@ pub fn parameterized(cx: ctxt,
self_r: Option<ty::Region>,
tps: &[ty::t]) -> ~str {
let r_str = match self_r {
None => ~"",
let mut strs = ~[];
match self_r {
None => (),
Some(r) => {
region_to_str(cx, r)
strs.push(region_to_str(cx, "", false, r))
}
};
if tps.len() > 0u {
let strs = vec::map(tps, |t| ty_to_str(cx, *t));
fmt!("%s%s<%s>", r_str, base, strs.connect(","))
strs += vec::map(tps, |t| ty_to_str(cx, *t));
if strs.len() > 0u {
fmt!("%s<%s>", base, strs.connect(","))
} else {
fmt!("%s%s", r_str, base)
fmt!("%s", base)
}
}
......@@ -597,7 +604,7 @@ fn repr(&self, tcx: ctxt) -> ~str {
impl Repr for ty::Region {
fn repr(&self, tcx: ctxt) -> ~str {
region_to_str(tcx, *self)
region_to_str(tcx, "", false, *self)
}
}
......
......@@ -16,11 +16,11 @@
struct a_class<'self> { x:&'self int }
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> {
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>() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册