Skip to content

Commit

Permalink
Merge pull request image-rs#364 from ruud-v-a/warnings
Browse files Browse the repository at this point in the history
Resolve warnings for latest nightly
  • Loading branch information
nwin committed Apr 3, 2015
2 parents d7dff70 + 2637c07 commit 47c9ff8
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 23 deletions.
1 change: 0 additions & 1 deletion src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use std::slice::{ Chunks, ChunksMut };
use std::any::TypeId;
use std::ops::{ Deref, DerefMut, Index, IndexMut };
use std::marker::{ Reflect, PhantomData };
use std::num::Int;
use std::iter::repeat;
use std::path::Path;
use std::io;
Expand Down
6 changes: 3 additions & 3 deletions src/gif/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::io;
use std::io::Write;
use byteorder::{WriteBytesExt, LittleEndian};
use std::num::Int;

use buffer::{ImageBuffer, Pixel};
use color::{Rgb, Rgba};
Expand Down Expand Up @@ -58,13 +57,14 @@ where Container: Deref<Target=[u8]> + DerefMut {

/// Encodes the image
pub fn encode<W: Write>(&mut self, w: &mut W) -> io::Result<()> {
use std::u16;
// Header
try!(w.write_all(b"GIF89a"));
// Logical screen descriptor
let height = self.image.height();
let width = self.image.width();
if width > <u16 as Int>::max_value() as u32 ||
height > <u16 as Int>::max_value() as u32 {
if width > u16::MAX as u32 ||
height > u16::MAX as u32 {
return Err(io::Error::new(
io::ErrorKind::InvalidInput,
"Image dimensions are too large for the gif format.",
Expand Down
2 changes: 0 additions & 2 deletions src/jpeg/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ use std::slice;
use std::io::Read;
use std::default::Default;
use std::collections::vec_map::VecMap;
use std::num::Float;
use std::iter::repeat;
use std::num::wrapping::WrappingOps;
use byteorder::{ReadBytesExt, BigEndian};

use color;
Expand Down
1 change: 0 additions & 1 deletion src/jpeg/entropy.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::iter::repeat;
use std::io::Read;
use byteorder::ReadBytesExt;
use std::num::wrapping::WrappingOps;

use image;
use image::ImageResult;
Expand Down
2 changes: 0 additions & 2 deletions src/jpeg/transform.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::num::wrapping::WrappingOps;

// The forward dct's output coefficients are scaled by 8
// The inverse dct's output samples are clamped to the range [0, 255]
fn level_shift_up(a: i32) -> u8 {
Expand Down
2 changes: 0 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@
#![deny(missing_copy_implementations)]
#![feature(core)]
#![feature(collections)]
#![feature(io)]
#![feature(std_misc)]
#![feature(rustc_private)]
#![feature(step_by)]
#![feature(convert)]
#![feature(slice_patterns)]
#![cfg_attr(test, feature(test))]

Expand Down
5 changes: 3 additions & 2 deletions src/math/nq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*
*/

use std::num::Float;
use std::cmp::{
max,
min
Expand Down Expand Up @@ -184,7 +183,9 @@ impl NeuQuant {
/// for frequently chosen neurons, freq[i] is high and bias[i] is negative
/// bias[i] = gamma*((1/self.netsize)-freq[i])
fn contest (&mut self, b: f64, g: f64, r: f64, a: f64) -> i32 {
let mut bestd = Float::max_value();
use std::f64;

let mut bestd = f64::MAX;
let mut bestbiasd: f64 = bestd;
let mut bestpos = -1;
let mut bestbiaspos: i32 = bestpos;
Expand Down
1 change: 0 additions & 1 deletion src/png/filter.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::num::SignedInt;
use std::num::Wrapping as w;

#[derive(FromPrimitive, Debug)]
Expand Down
2 changes: 0 additions & 2 deletions src/ppm/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ impl<'a, W: Write> PPMEncoder<'a, W> {
}

fn max_pixel_value(pixel_type: color::ColorType) -> u16 {
use std::num::Int;

match pixel_type {
Gray(n) => 2u16.pow(n as u32) - 1,
RGB(n) => 2u16.pow(n as u32) - 1,
Expand Down
9 changes: 7 additions & 2 deletions src/tiff/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::io::{self, Read, Seek};
use std::mem;
use std::num::{ Int, Float, FromPrimitive };
use std::num::FromPrimitive;
use std::collections::HashMap;
use byteorder;
use num;

use image;
use image::{
Expand Down Expand Up @@ -77,7 +78,11 @@ pub struct TIFFDecoder<R> where R: Read + Seek {
compression_method: CompressionMethod
}

fn rev_hpredict_nsamp<T: Int>(mut image: Vec<T>, size: (u32, u32), samples: usize) -> Vec<T> {
fn rev_hpredict_nsamp<T>(mut image: Vec<T>,
size: (u32, u32),
samples: usize)
-> Vec<T>
where T: num::Num + Copy {
let width = size.0 as usize;
let height = size.1 as usize;
for row in (0..height) {
Expand Down
7 changes: 2 additions & 5 deletions tests/reference_images.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
//! Compares the decoding results with reference renderings.
#![feature(core)]
use std::fs;
use std::num;
use std::u32;
use std::path::PathBuf;


extern crate image;
extern crate glob;

Expand All @@ -14,7 +12,6 @@ const IMAGE_DIR: &'static str = "images";
const OUTPUT_DIR: &'static str = "output";
const REFERENCE_DIR: &'static str = "reference";


fn process_images<F>(dir: &str, input_decoder: Option<&str>, func: F)
where F: Fn(&PathBuf, PathBuf, &str) {
let base: PathBuf = BASE_PATH.iter().collect();
Expand Down Expand Up @@ -94,7 +91,7 @@ fn check_references() {
.split(".").take(2)
.collect::<Vec<_>>().connect(".")
);
let ref_crc = num::from_str_radix(filename
let ref_crc = u32::from_str_radix(filename
.as_os_str()
.to_str().unwrap()
.split(".").nth(2).unwrap(), 16
Expand Down

0 comments on commit 47c9ff8

Please sign in to comment.