diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 1863c16baa0..cb235c015ff 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -62,12 +62,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; } diff --git a/src/librustc/middle/trans/llrepr.rs b/src/librustc/middle/trans/llrepr.rs index 5aec1cfbf26..28e97e0f658 100644 --- a/src/librustc/middle/trans/llrepr.rs +++ b/src/librustc/middle/trans/llrepr.rs @@ -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 LlvmRepr for [T] { fn llrepr(&self, ccx: &CrateContext) -> String { let reprs: Vec = self.iter().map(|t| t.llrepr(ccx)).collect(); format!("[{}]", reprs.connect(",")) diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index bcd70510edd..e6015bfc074 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -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(tcx: &ctxt, v: &[T]) -> String { vec_map_to_string(v, |t| t.repr(tcx)) } -impl<'a, T:Repr> Repr for &'a [T] { +impl Repr for [T] { fn repr(&self, tcx: &ctxt) -> String { - repr_vec(tcx, *self) + repr_vec(tcx, self) } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index b3086fba834..ec691757077 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -90,14 +90,14 @@ pub mod rt { */ // FIXME: Move this trait to pprust and get rid of *_to_str? - pub trait ToSource { + pub trait ToSource for Sized? { // Takes a thing and generates a string containing rust code for it. fn to_source(&self) -> String; } // FIXME (Issue #16472): This should go away after ToToken impls // are revised to go directly to token-trees. - trait ToSourceWithHygiene : ToSource { + trait ToSourceWithHygiene for Sized? : ToSource { // Takes a thing and generates a string containing rust code // for it, encoding Idents as special byte sequences to // maintain hygiene across serialization and deserialization. @@ -150,15 +150,15 @@ pub mod rt { macro_rules! impl_to_source_slice( ($t:ty, $sep:expr) => ( - impl<'a> ToSource for &'a [$t] { + impl ToSource for [$t] { fn to_source(&self) -> String { - slice_to_source($sep, *self) + slice_to_source($sep, self) } } - impl<'a> ToSourceWithHygiene for &'a [$t] { + impl ToSourceWithHygiene for [$t] { fn to_source_with_hygiene(&self) -> String { - slice_to_source_with_hygiene($sep, *self) + slice_to_source_with_hygiene($sep, self) } } ) @@ -200,14 +200,14 @@ pub mod rt { } } - impl<'a> ToSource for &'a str { + impl ToSource for str { fn to_source(&self) -> String { let lit = dummy_spanned(ast::LitStr( - token::intern_and_get_ident(*self), ast::CookedStr)); + token::intern_and_get_ident(self), ast::CookedStr)); pprust::lit_to_string(&lit) } } - impl<'a> ToSourceWithHygiene for &'a str { + impl ToSourceWithHygiene for str { fn to_source_with_hygiene(&self) -> String { self.to_source() } diff --git a/src/libtest/stats.rs b/src/libtest/stats.rs index daef41666af..5161d1de7ee 100644 --- a/src/libtest/stats.rs +++ b/src/libtest/stats.rs @@ -38,7 +38,7 @@ fn local_sort(v: &mut [T]) { } /// Trait that provides simple descriptive statistics on a univariate set of numeric samples. -pub trait Stats { +pub trait Stats for Sized? { /// Sum of the samples. /// @@ -47,24 +47,24 @@ pub trait Stats { /// ["Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"] /// (http://www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps) /// *Discrete & Computational Geometry 18*, 3 (Oct 1997), 305-363, Shewchuk J.R. - fn sum(self) -> T; + fn sum(&self) -> T; /// Minimum value of the samples. - fn min(self) -> T; + fn min(&self) -> T; /// Maximum value of the samples. - fn max(self) -> T; + fn max(&self) -> T; /// Arithmetic mean (average) of the samples: sum divided by sample-count. /// /// See: https://en.wikipedia.org/wiki/Arithmetic_mean - fn mean(self) -> T; + fn mean(&self) -> T; /// Median of the samples: value separating the lower half of the samples from the higher half. /// Equal to `self.percentile(50.0)`. /// /// See: https://en.wikipedia.org/wiki/Median - fn median(self) -> T; + fn median(&self) -> T; /// Variance of the samples: bias-corrected mean of the squares of the differences of each /// sample from the sample mean. Note that this calculates the _sample variance_ rather than the @@ -73,7 +73,7 @@ pub trait Stats { /// than `n`. /// /// See: https://en.wikipedia.org/wiki/Variance - fn var(self) -> T; + fn var(&self) -> T; /// Standard deviation: the square root of the sample variance. /// @@ -81,13 +81,13 @@ pub trait Stats { /// `median_abs_dev` for unknown distributions. /// /// See: https://en.wikipedia.org/wiki/Standard_deviation - fn std_dev(self) -> T; + fn std_dev(&self) -> T; /// Standard deviation as a percent of the mean value. See `std_dev` and `mean`. /// /// Note: this is not a robust statistic for non-normal distributions. Prefer the /// `median_abs_dev_pct` for unknown distributions. - fn std_dev_pct(self) -> T; + fn std_dev_pct(&self) -> T; /// Scaled median of the absolute deviations of each sample from the sample median. This is a /// robust (distribution-agnostic) estimator of sample variability. Use this in preference to @@ -96,10 +96,10 @@ pub trait Stats { /// deviation. /// /// See: http://en.wikipedia.org/wiki/Median_absolute_deviation - fn median_abs_dev(self) -> T; + fn median_abs_dev(&self) -> T; /// Median absolute deviation as a percent of the median. See `median_abs_dev` and `median`. - fn median_abs_dev_pct(self) -> T; + fn median_abs_dev_pct(&self) -> T; /// Percentile: the value below which `pct` percent of the values in `self` fall. For example, /// percentile(95.0) will return the value `v` such that 95% of the samples `s` in `self` @@ -108,7 +108,7 @@ pub trait Stats { /// Calculated by linear interpolation between closest ranks. /// /// See: http://en.wikipedia.org/wiki/Percentile - fn percentile(self, pct: T) -> T; + fn percentile(&self, pct: T) -> T; /// Quartiles of the sample: three values that divide the sample into four equal groups, each /// with 1/4 of the data. The middle value is the median. See `median` and `percentile`. This @@ -116,13 +116,13 @@ pub trait Stats { /// is otherwise equivalent. /// /// See also: https://en.wikipedia.org/wiki/Quartile - fn quartiles(self) -> (T,T,T); + fn quartiles(&self) -> (T,T,T); /// Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th /// percentile (3rd quartile). See `quartiles`. /// /// See also: https://en.wikipedia.org/wiki/Interquartile_range - fn iqr(self) -> T; + fn iqr(&self) -> T; } /// Extracted collection of all the summary statistics of a sample set. @@ -163,9 +163,9 @@ impl Summary { } } -impl<'a, T: FloatMath + FromPrimitive> Stats for &'a [T] { +impl Stats for [T] { // FIXME #11059 handle NaN, inf and overflow - fn sum(self) -> T { + fn sum(&self) -> T { let mut partials = vec![]; for &mut x in self.iter() { @@ -198,26 +198,26 @@ impl<'a, T: FloatMath + FromPrimitive> Stats for &'a [T] { partials.iter().fold(zero, |p, q| p + *q) } - fn min(self) -> T { + fn min(&self) -> T { assert!(self.len() != 0); self.iter().fold(self[0], |p, q| p.min(*q)) } - fn max(self) -> T { + fn max(&self) -> T { assert!(self.len() != 0); self.iter().fold(self[0], |p, q| p.max(*q)) } - fn mean(self) -> T { + fn mean(&self) -> T { assert!(self.len() != 0); self.sum() / FromPrimitive::from_uint(self.len()).unwrap() } - fn median(self) -> T { + fn median(&self) -> T { self.percentile(FromPrimitive::from_uint(50).unwrap()) } - fn var(self) -> T { + fn var(&self) -> T { if self.len() < 2 { Float::zero() } else { @@ -235,16 +235,16 @@ impl<'a, T: FloatMath + FromPrimitive> Stats for &'a [T] { } } - fn std_dev(self) -> T { + fn std_dev(&self) -> T { self.var().sqrt() } - fn std_dev_pct(self) -> T { + fn std_dev_pct(&self) -> T { let hundred = FromPrimitive::from_uint(100).unwrap(); (self.std_dev() / self.mean()) * hundred } - fn median_abs_dev(self) -> T { + fn median_abs_dev(&self) -> T { let med = self.median(); let abs_devs: Vec = self.iter().map(|&v| (med - v).abs()).collect(); // This constant is derived by smarter statistics brains than me, but it is @@ -253,18 +253,18 @@ impl<'a, T: FloatMath + FromPrimitive> Stats for &'a [T] { abs_devs.as_slice().median() * number } - fn median_abs_dev_pct(self) -> T { + fn median_abs_dev_pct(&self) -> T { let hundred = FromPrimitive::from_uint(100).unwrap(); (self.median_abs_dev() / self.median()) * hundred } - fn percentile(self, pct: T) -> T { + fn percentile(&self, pct: T) -> T { let mut tmp = self.to_vec(); local_sort(tmp.as_mut_slice()); percentile_of_sorted(tmp.as_slice(), pct) } - fn quartiles(self) -> (T,T,T) { + fn quartiles(&self) -> (T,T,T) { let mut tmp = self.to_vec(); local_sort(tmp.as_mut_slice()); let first = FromPrimitive::from_uint(25).unwrap(); @@ -276,7 +276,7 @@ impl<'a, T: FloatMath + FromPrimitive> Stats for &'a [T] { (a,b,c) } - fn iqr(self) -> T { + fn iqr(&self) -> T { let (a,_,c) = self.quartiles(); c - a }