Fallout where types must be specified.
This is due to a [breaking-change] to operators. The primary affected code is uses of the `Rng` trait where we used to (incorrectly) infer the right-hand-side type from the left-hand-side, in the case that the LHS type was a scalar like `i32`. The fix is to add a type annotation like `x + rng.gen::<i32>()`.
This commit is contained in:
parent
d6466ff13a
commit
c92bdcb232
@ -22,13 +22,13 @@ macro_rules! map_insert_rand_bench {
|
||||
let mut rng = rand::weak_rng();
|
||||
|
||||
for _ in 0..n {
|
||||
let i = rng.gen() % n;
|
||||
let i = rng.gen::<usize>() % n;
|
||||
map.insert(i, i);
|
||||
}
|
||||
|
||||
// measure
|
||||
b.iter(|| {
|
||||
let k = rng.gen() % n;
|
||||
let k = rng.gen::<usize>() % n;
|
||||
map.insert(k, k);
|
||||
map.remove(&k);
|
||||
});
|
||||
@ -77,7 +77,7 @@ macro_rules! map_find_rand_bench {
|
||||
|
||||
// setup
|
||||
let mut rng = rand::weak_rng();
|
||||
let mut keys: Vec<_> = (0..n).map(|_| rng.gen() % n).collect();
|
||||
let mut keys: Vec<_> = (0..n).map(|_| rng.gen::<usize>() % n).collect();
|
||||
|
||||
for &k in &keys {
|
||||
map.insert(k, k);
|
||||
|
@ -256,7 +256,7 @@ fn ziggurat<R: Rng, P, Z>(
|
||||
return zero_case(rng, u);
|
||||
}
|
||||
// algebraically equivalent to f1 + DRanU()*(f0 - f1) < 1
|
||||
if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen() < pdf(x) {
|
||||
if f_tab[i + 1] + (f_tab[i] - f_tab[i + 1]) * rng.gen::<f64>() < pdf(x) {
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ macro_rules! float_impl {
|
||||
}
|
||||
}
|
||||
fn sample_range<R: Rng>(r: &Range<$ty>, rng: &mut R) -> $ty {
|
||||
r.low + r.range * rng.gen()
|
||||
r.low + r.range * rng.gen::<$ty>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,3 +32,21 @@ extern fn eh_personality() {}
|
||||
pub trait Copy : PhantomFn<Self> {
|
||||
// Empty.
|
||||
}
|
||||
|
||||
#[lang="rem"]
|
||||
pub trait Rem<RHS=Self> {
|
||||
/// The resulting type after applying the `%` operator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
type Output = Self;
|
||||
|
||||
/// The method for the `%` operator
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
fn rem(self, rhs: RHS) -> Self::Output;
|
||||
}
|
||||
|
||||
impl Rem for i32 {
|
||||
type Output = i32;
|
||||
|
||||
#[inline]
|
||||
fn rem(self, other: i32) -> i32 { self % other }
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ fn lerp(a: f32, b: f32, v: f32) -> f32 { a * (1.0 - v) + b * v }
|
||||
fn smooth(v: f32) -> f32 { v * v * (3.0 - 2.0 * v) }
|
||||
|
||||
fn random_gradient<R: Rng>(r: &mut R) -> Vec2 {
|
||||
let v = PI * 2.0 * r.gen();
|
||||
let v = PI * 2.0 * r.gen::<f32>();
|
||||
Vec2 { x: v.cos(), y: v.sin() }
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ pub fn main() {
|
||||
}
|
||||
|
||||
// raw slice with explicit cast
|
||||
let a = &[1, 2, 3] as *const [_];
|
||||
let a = &[1, 2, 3] as *const [i32];
|
||||
unsafe {
|
||||
let b = (*a)[2];
|
||||
assert!(b == 3);
|
||||
@ -96,7 +96,7 @@ pub fn main() {
|
||||
assert!(len == 3);
|
||||
}
|
||||
|
||||
let a = &mut [1, 2, 3] as *mut [_];
|
||||
let a = &mut [1, 2, 3] as *mut [i32];
|
||||
unsafe {
|
||||
let b = (*a)[2];
|
||||
assert!(b == 3);
|
||||
|
@ -10,5 +10,8 @@
|
||||
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn wsucc(n: isize) -> isize { 0 + { return n + 1 } }
|
||||
use std::num::Int;
|
||||
|
||||
fn wsucc<T:Int>(n: T) -> T { n + { return n } }
|
||||
|
||||
pub fn main() { }
|
||||
|
@ -12,5 +12,5 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
pub fn main() {
|
||||
{|i| if 1 == i { }};
|
||||
{|i: u32| if 1 == i { }};
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ use std::mem;
|
||||
|
||||
fn main() {
|
||||
let y = 0u8;
|
||||
let closure = move |x| y + x;
|
||||
let closure = move |x: u8| y + x;
|
||||
|
||||
// Check that both closures are capturing by value
|
||||
assert_eq!(1, mem::size_of_val(&closure));
|
||||
|
@ -12,13 +12,13 @@
|
||||
// pretty-expanded FIXME #23616
|
||||
|
||||
fn main() {
|
||||
if let Ok(x) = "3.1415".parse() {
|
||||
if let Ok(x) = "3.1415".parse::<f64>() {
|
||||
assert_eq!(false, x <= 0.0);
|
||||
}
|
||||
if let Ok(x) = "3.1415".parse() {
|
||||
if let Ok(x) = "3.1415".parse::<f64>() {
|
||||
assert_eq!(3.1415, x + 0.0);
|
||||
}
|
||||
if let Ok(mut x) = "3.1415".parse() {
|
||||
if let Ok(mut x) = "3.1415".parse::<f64>() {
|
||||
assert_eq!(8.1415, { x += 5.0; x });
|
||||
}
|
||||
}
|
||||
|
@ -25,19 +25,19 @@ fn main() {
|
||||
assert!(thread::spawn(move|| { min_val::<i16>() / -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i32>() / -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i64>() / -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1isize / zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 / zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 / zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 / zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 / zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1isize / zero::<isize>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 / zero::<i8>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 / zero::<i16>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 / zero::<i32>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 / zero::<i64>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<isize>() % -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i8>() % -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i16>() % -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i32>() % -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { min_val::<i64>() % -1; }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1isize % zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 % zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 % zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 % zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 % zero(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1isize % zero::<isize>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i8 % zero::<i8>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i16 % zero::<i16>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i32 % zero::<i32>(); }).join().is_err());
|
||||
assert!(thread::spawn(move|| { 1i64 % zero::<i64>(); }).join().is_err());
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ use reexported_static_methods::Boz;
|
||||
use reexported_static_methods::Bort;
|
||||
|
||||
pub fn main() {
|
||||
assert_eq!(42, Foo::foo());
|
||||
assert_eq!(84, Baz::bar());
|
||||
assert_eq!(42_isize, Foo::foo());
|
||||
assert_eq!(84_isize, Baz::bar());
|
||||
assert!(Boz::boz(1));
|
||||
assert_eq!("bort()".to_string(), Bort::bort());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user