librustc: DSTify `ClassList`, `LlvmRepr` and `Repr`

This commit is contained in:
Jorge Aparicio 2014-11-17 15:40:05 -05:00
parent daa949e516
commit d50e80f449
3 changed files with 9 additions and 9 deletions

View File

@ -61,12 +61,12 @@ impl RegClass {
}
}
trait ClassList {
trait ClassList for Sized? {
fn is_pass_byval(&self) -> bool;
fn is_ret_bysret(&self) -> bool;
}
impl<'a> ClassList for &'a [RegClass] {
impl ClassList for [RegClass] {
fn is_pass_byval(&self) -> bool {
if self.len() == 0 { return false; }

View File

@ -12,11 +12,11 @@ use middle::trans::context::CrateContext;
use middle::trans::type_::Type;
use llvm::ValueRef;
pub trait LlvmRepr {
pub trait LlvmRepr for Sized? {
fn llrepr(&self, ccx: &CrateContext) -> String;
}
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
impl<T:LlvmRepr> LlvmRepr for [T] {
fn llrepr(&self, ccx: &CrateContext) -> String {
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
format!("[{}]", reprs.connect(","))

View File

@ -37,7 +37,7 @@ use syntax::{ast, ast_util};
use syntax::owned_slice::OwnedSlice;
/// Produces a string suitable for debugging output.
pub trait Repr {
pub trait Repr for Sized? {
fn repr(&self, tcx: &ctxt) -> String;
}
@ -578,9 +578,9 @@ impl Repr for () {
}
}
impl<'a,T:Repr> Repr for &'a T {
impl<'a, Sized? T:Repr> Repr for &'a T {
fn repr(&self, tcx: &ctxt) -> String {
(&**self).repr(tcx)
Repr::repr(*self, tcx)
}
}
@ -600,9 +600,9 @@ fn repr_vec<T:Repr>(tcx: &ctxt, v: &[T]) -> String {
vec_map_to_string(v, |t| t.repr(tcx))
}
impl<'a, T:Repr> Repr for &'a [T] {
impl<T:Repr> Repr for [T] {
fn repr(&self, tcx: &ctxt) -> String {
repr_vec(tcx, *self)
repr_vec(tcx, self)
}
}