Skip to content

Commit f637f1c

Browse files
committed
auto merge of #19050 : japaric/rust/moar-dst, r=aturon
r? @aturon cc #16918
2 parents 9c96a79 + d50e80f commit f637f1c

File tree

5 files changed

+46
-46
lines changed

5 files changed

+46
-46
lines changed

Diff for: src/librustc/middle/trans/cabi_x86_64.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ impl RegClass {
6262
}
6363
}
6464

65-
trait ClassList {
65+
trait ClassList for Sized? {
6666
fn is_pass_byval(&self) -> bool;
6767
fn is_ret_bysret(&self) -> bool;
6868
}
6969

70-
impl<'a> ClassList for &'a [RegClass] {
70+
impl ClassList for [RegClass] {
7171
fn is_pass_byval(&self) -> bool {
7272
if self.len() == 0 { return false; }
7373

Diff for: src/librustc/middle/trans/llrepr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ use middle::trans::context::CrateContext;
1212
use middle::trans::type_::Type;
1313
use llvm::ValueRef;
1414

15-
pub trait LlvmRepr {
15+
pub trait LlvmRepr for Sized? {
1616
fn llrepr(&self, ccx: &CrateContext) -> String;
1717
}
1818

19-
impl<'a, T:LlvmRepr> LlvmRepr for &'a [T] {
19+
impl<T:LlvmRepr> LlvmRepr for [T] {
2020
fn llrepr(&self, ccx: &CrateContext) -> String {
2121
let reprs: Vec<String> = self.iter().map(|t| t.llrepr(ccx)).collect();
2222
format!("[{}]", reprs.connect(","))

Diff for: src/librustc/util/ppaux.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ use syntax::{ast, ast_util};
3737
use syntax::owned_slice::OwnedSlice;
3838

3939
/// Produces a string suitable for debugging output.
40-
pub trait Repr {
40+
pub trait Repr for Sized? {
4141
fn repr(&self, tcx: &ctxt) -> String;
4242
}
4343

@@ -578,9 +578,9 @@ impl Repr for () {
578578
}
579579
}
580580

581-
impl<'a,T:Repr> Repr for &'a T {
581+
impl<'a, Sized? T:Repr> Repr for &'a T {
582582
fn repr(&self, tcx: &ctxt) -> String {
583-
(&**self).repr(tcx)
583+
Repr::repr(*self, tcx)
584584
}
585585
}
586586

@@ -600,9 +600,9 @@ fn repr_vec<T:Repr>(tcx: &ctxt, v: &[T]) -> String {
600600
vec_map_to_string(v, |t| t.repr(tcx))
601601
}
602602

603-
impl<'a, T:Repr> Repr for &'a [T] {
603+
impl<T:Repr> Repr for [T] {
604604
fn repr(&self, tcx: &ctxt) -> String {
605-
repr_vec(tcx, *self)
605+
repr_vec(tcx, self)
606606
}
607607
}
608608

Diff for: src/libsyntax/ext/quote.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,14 @@ pub mod rt {
9090
*/
9191

9292
// FIXME: Move this trait to pprust and get rid of *_to_str?
93-
pub trait ToSource {
93+
pub trait ToSource for Sized? {
9494
// Takes a thing and generates a string containing rust code for it.
9595
fn to_source(&self) -> String;
9696
}
9797

9898
// FIXME (Issue #16472): This should go away after ToToken impls
9999
// are revised to go directly to token-trees.
100-
trait ToSourceWithHygiene : ToSource {
100+
trait ToSourceWithHygiene for Sized? : ToSource {
101101
// Takes a thing and generates a string containing rust code
102102
// for it, encoding Idents as special byte sequences to
103103
// maintain hygiene across serialization and deserialization.
@@ -150,15 +150,15 @@ pub mod rt {
150150

151151
macro_rules! impl_to_source_slice(
152152
($t:ty, $sep:expr) => (
153-
impl<'a> ToSource for &'a [$t] {
153+
impl ToSource for [$t] {
154154
fn to_source(&self) -> String {
155-
slice_to_source($sep, *self)
155+
slice_to_source($sep, self)
156156
}
157157
}
158158

159-
impl<'a> ToSourceWithHygiene for &'a [$t] {
159+
impl ToSourceWithHygiene for [$t] {
160160
fn to_source_with_hygiene(&self) -> String {
161-
slice_to_source_with_hygiene($sep, *self)
161+
slice_to_source_with_hygiene($sep, self)
162162
}
163163
}
164164
)
@@ -200,14 +200,14 @@ pub mod rt {
200200
}
201201
}
202202

203-
impl<'a> ToSource for &'a str {
203+
impl ToSource for str {
204204
fn to_source(&self) -> String {
205205
let lit = dummy_spanned(ast::LitStr(
206-
token::intern_and_get_ident(*self), ast::CookedStr));
206+
token::intern_and_get_ident(self), ast::CookedStr));
207207
pprust::lit_to_string(&lit)
208208
}
209209
}
210-
impl<'a> ToSourceWithHygiene for &'a str {
210+
impl ToSourceWithHygiene for str {
211211
fn to_source_with_hygiene(&self) -> String {
212212
self.to_source()
213213
}

Diff for: src/libtest/stats.rs

+28-28
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn local_sort<T: Float>(v: &mut [T]) {
3838
}
3939

4040
/// Trait that provides simple descriptive statistics on a univariate set of numeric samples.
41-
pub trait Stats <T: FloatMath + FromPrimitive>{
41+
pub trait Stats <T: FloatMath + FromPrimitive> for Sized? {
4242

4343
/// Sum of the samples.
4444
///
@@ -47,24 +47,24 @@ pub trait Stats <T: FloatMath + FromPrimitive>{
4747
/// ["Adaptive Precision Floating-Point Arithmetic and Fast Robust Geometric Predicates"]
4848
/// (http://www.cs.cmu.edu/~quake-papers/robust-arithmetic.ps)
4949
/// *Discrete & Computational Geometry 18*, 3 (Oct 1997), 305-363, Shewchuk J.R.
50-
fn sum(self) -> T;
50+
fn sum(&self) -> T;
5151

5252
/// Minimum value of the samples.
53-
fn min(self) -> T;
53+
fn min(&self) -> T;
5454

5555
/// Maximum value of the samples.
56-
fn max(self) -> T;
56+
fn max(&self) -> T;
5757

5858
/// Arithmetic mean (average) of the samples: sum divided by sample-count.
5959
///
6060
/// See: https://en.wikipedia.org/wiki/Arithmetic_mean
61-
fn mean(self) -> T;
61+
fn mean(&self) -> T;
6262

6363
/// Median of the samples: value separating the lower half of the samples from the higher half.
6464
/// Equal to `self.percentile(50.0)`.
6565
///
6666
/// See: https://en.wikipedia.org/wiki/Median
67-
fn median(self) -> T;
67+
fn median(&self) -> T;
6868

6969
/// Variance of the samples: bias-corrected mean of the squares of the differences of each
7070
/// sample from the sample mean. Note that this calculates the _sample variance_ rather than the
@@ -73,21 +73,21 @@ pub trait Stats <T: FloatMath + FromPrimitive>{
7373
/// than `n`.
7474
///
7575
/// See: https://en.wikipedia.org/wiki/Variance
76-
fn var(self) -> T;
76+
fn var(&self) -> T;
7777

7878
/// Standard deviation: the square root of the sample variance.
7979
///
8080
/// Note: this is not a robust statistic for non-normal distributions. Prefer the
8181
/// `median_abs_dev` for unknown distributions.
8282
///
8383
/// See: https://en.wikipedia.org/wiki/Standard_deviation
84-
fn std_dev(self) -> T;
84+
fn std_dev(&self) -> T;
8585

8686
/// Standard deviation as a percent of the mean value. See `std_dev` and `mean`.
8787
///
8888
/// Note: this is not a robust statistic for non-normal distributions. Prefer the
8989
/// `median_abs_dev_pct` for unknown distributions.
90-
fn std_dev_pct(self) -> T;
90+
fn std_dev_pct(&self) -> T;
9191

9292
/// Scaled median of the absolute deviations of each sample from the sample median. This is a
9393
/// robust (distribution-agnostic) estimator of sample variability. Use this in preference to
@@ -96,10 +96,10 @@ pub trait Stats <T: FloatMath + FromPrimitive>{
9696
/// deviation.
9797
///
9898
/// See: http://en.wikipedia.org/wiki/Median_absolute_deviation
99-
fn median_abs_dev(self) -> T;
99+
fn median_abs_dev(&self) -> T;
100100

101101
/// Median absolute deviation as a percent of the median. See `median_abs_dev` and `median`.
102-
fn median_abs_dev_pct(self) -> T;
102+
fn median_abs_dev_pct(&self) -> T;
103103

104104
/// Percentile: the value below which `pct` percent of the values in `self` fall. For example,
105105
/// percentile(95.0) will return the value `v` such that 95% of the samples `s` in `self`
@@ -108,21 +108,21 @@ pub trait Stats <T: FloatMath + FromPrimitive>{
108108
/// Calculated by linear interpolation between closest ranks.
109109
///
110110
/// See: http://en.wikipedia.org/wiki/Percentile
111-
fn percentile(self, pct: T) -> T;
111+
fn percentile(&self, pct: T) -> T;
112112

113113
/// Quartiles of the sample: three values that divide the sample into four equal groups, each
114114
/// with 1/4 of the data. The middle value is the median. See `median` and `percentile`. This
115115
/// function may calculate the 3 quartiles more efficiently than 3 calls to `percentile`, but
116116
/// is otherwise equivalent.
117117
///
118118
/// See also: https://en.wikipedia.org/wiki/Quartile
119-
fn quartiles(self) -> (T,T,T);
119+
fn quartiles(&self) -> (T,T,T);
120120

121121
/// Inter-quartile range: the difference between the 25th percentile (1st quartile) and the 75th
122122
/// percentile (3rd quartile). See `quartiles`.
123123
///
124124
/// See also: https://en.wikipedia.org/wiki/Interquartile_range
125-
fn iqr(self) -> T;
125+
fn iqr(&self) -> T;
126126
}
127127

128128
/// Extracted collection of all the summary statistics of a sample set.
@@ -163,9 +163,9 @@ impl<T: FloatMath + FromPrimitive> Summary<T> {
163163
}
164164
}
165165

166-
impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
166+
impl<T: FloatMath + FromPrimitive> Stats<T> for [T] {
167167
// FIXME #11059 handle NaN, inf and overflow
168-
fn sum(self) -> T {
168+
fn sum(&self) -> T {
169169
let mut partials = vec![];
170170

171171
for &mut x in self.iter() {
@@ -198,26 +198,26 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
198198
partials.iter().fold(zero, |p, q| p + *q)
199199
}
200200

201-
fn min(self) -> T {
201+
fn min(&self) -> T {
202202
assert!(self.len() != 0);
203203
self.iter().fold(self[0], |p, q| p.min(*q))
204204
}
205205

206-
fn max(self) -> T {
206+
fn max(&self) -> T {
207207
assert!(self.len() != 0);
208208
self.iter().fold(self[0], |p, q| p.max(*q))
209209
}
210210

211-
fn mean(self) -> T {
211+
fn mean(&self) -> T {
212212
assert!(self.len() != 0);
213213
self.sum() / FromPrimitive::from_uint(self.len()).unwrap()
214214
}
215215

216-
fn median(self) -> T {
216+
fn median(&self) -> T {
217217
self.percentile(FromPrimitive::from_uint(50).unwrap())
218218
}
219219

220-
fn var(self) -> T {
220+
fn var(&self) -> T {
221221
if self.len() < 2 {
222222
Float::zero()
223223
} else {
@@ -235,16 +235,16 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
235235
}
236236
}
237237

238-
fn std_dev(self) -> T {
238+
fn std_dev(&self) -> T {
239239
self.var().sqrt()
240240
}
241241

242-
fn std_dev_pct(self) -> T {
242+
fn std_dev_pct(&self) -> T {
243243
let hundred = FromPrimitive::from_uint(100).unwrap();
244244
(self.std_dev() / self.mean()) * hundred
245245
}
246246

247-
fn median_abs_dev(self) -> T {
247+
fn median_abs_dev(&self) -> T {
248248
let med = self.median();
249249
let abs_devs: Vec<T> = self.iter().map(|&v| (med - v).abs()).collect();
250250
// This constant is derived by smarter statistics brains than me, but it is
@@ -253,18 +253,18 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
253253
abs_devs.as_slice().median() * number
254254
}
255255

256-
fn median_abs_dev_pct(self) -> T {
256+
fn median_abs_dev_pct(&self) -> T {
257257
let hundred = FromPrimitive::from_uint(100).unwrap();
258258
(self.median_abs_dev() / self.median()) * hundred
259259
}
260260

261-
fn percentile(self, pct: T) -> T {
261+
fn percentile(&self, pct: T) -> T {
262262
let mut tmp = self.to_vec();
263263
local_sort(tmp.as_mut_slice());
264264
percentile_of_sorted(tmp.as_slice(), pct)
265265
}
266266

267-
fn quartiles(self) -> (T,T,T) {
267+
fn quartiles(&self) -> (T,T,T) {
268268
let mut tmp = self.to_vec();
269269
local_sort(tmp.as_mut_slice());
270270
let first = FromPrimitive::from_uint(25).unwrap();
@@ -276,7 +276,7 @@ impl<'a, T: FloatMath + FromPrimitive> Stats<T> for &'a [T] {
276276
(a,b,c)
277277
}
278278

279-
fn iqr(self) -> T {
279+
fn iqr(&self) -> T {
280280
let (a,_,c) = self.quartiles();
281281
c - a
282282
}

0 commit comments

Comments
 (0)