Clean up Repr impls a bit so we can add generic impls for @ and ~.

This commit is contained in:
Michael Sullivan
2013-07-08 16:54:28 -07:00
parent 38dc832154
commit 82ae2fa93a
3 changed files with 8 additions and 18 deletions
+1 -1
View File
@@ -1185,7 +1185,7 @@ pub fn freely_aliasable(&self) -> Option<AliasableReason> {
}
}
impl Repr for cmt {
impl Repr for cmt_ {
fn repr(&self, tcx: ty::ctxt) -> ~str {
fmt!("{%s id:%d m:%? ty:%s}",
self.cat.repr(tcx),
-6
View File
@@ -154,12 +154,6 @@ fn repr(&self, tcx: ty::ctxt) -> ~str {
}
}
impl Repr for @param_substs {
fn repr(&self, tcx: ty::ctxt) -> ~str {
param_substs_to_str(*self, tcx)
}
}
// Function context. Every LLVM function we create will have one of
// these.
pub struct fn_ctxt_ {
+7 -11
View File
@@ -512,9 +512,6 @@ fn repr(&self, tcx: ctxt) -> ~str {
}
}
/*
Annoyingly, these conflict with @ast::expr.
impl<T:Repr> Repr for @T {
fn repr(&self, tcx: ctxt) -> ~str {
(&**self).repr(tcx)
@@ -526,7 +523,6 @@ fn repr(&self, tcx: ctxt) -> ~str {
(&**self).repr(tcx)
}
}
*/
fn repr_vec<T:Repr>(tcx: ctxt, v: &[T]) -> ~str {
fmt!("[%s]", v.map(|t| t.repr(tcx)).connect(","))
@@ -538,11 +534,11 @@ fn repr(&self, tcx: ctxt) -> ~str {
}
}
// This is necessary to handle types like Option<@~[T]>, for which
// This is necessary to handle types like Option<~[T]>, for which
// autoderef cannot convert the &[T] handler
impl<T:Repr> Repr for @~[T] {
impl<T:Repr> Repr for ~[T] {
fn repr(&self, tcx: ctxt) -> ~str {
repr_vec(tcx, **self)
repr_vec(tcx, *self)
}
}
@@ -593,19 +589,19 @@ fn repr(&self, tcx: ctxt) -> ~str {
}
}
impl Repr for @ast::expr {
impl Repr for ast::expr {
fn repr(&self, tcx: ctxt) -> ~str {
fmt!("expr(%d: %s)",
self.id,
pprust::expr_to_str(*self, tcx.sess.intr()))
pprust::expr_to_str(self, tcx.sess.intr()))
}
}
impl Repr for @ast::pat {
impl Repr for ast::pat {
fn repr(&self, tcx: ctxt) -> ~str {
fmt!("pat(%d: %s)",
self.id,
pprust::pat_to_str(*self, tcx.sess.intr()))
pprust::pat_to_str(self, tcx.sess.intr()))
}
}