Skip to content

Commit

Permalink
Made everything work in rust nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
matiu2 committed Jul 2, 2019
1 parent 778a550 commit ef50f99
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/error.rs
Expand Up @@ -47,7 +47,7 @@ impl Error {
}

/// Return a reference to the lower level, inner error.
pub fn get_ref(&self) -> &(error::Error + 'static) {
pub fn get_ref(&self) -> &(dyn error::Error + 'static) {
use self::ErrorKind::*;

match self.inner {
Expand Down Expand Up @@ -84,7 +84,7 @@ impl error::Error for Error {
// Return any available cause from the inner error. Note the inner error is
// not itself the cause.
#[allow(deprecated)]
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
self.get_ref().cause()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/extensions.rs
Expand Up @@ -3,7 +3,7 @@ use std::collections::HashMap;
use std::hash::{BuildHasherDefault, Hasher};
use std::fmt;

type AnyMap = HashMap<TypeId, Box<Any + Send + Sync>, BuildHasherDefault<IdHasher>>;
type AnyMap = HashMap<TypeId, Box<dyn Any + Send + Sync>, BuildHasherDefault<IdHasher>>;

// With TypeIds as keys, there's no need to hash them. They are already hashes
// themselves, coming from the compiler. The IdHasher just holds the u64 of
Expand Down Expand Up @@ -70,7 +70,7 @@ impl Extensions {
.insert(TypeId::of::<T>(), Box::new(val))
.and_then(|boxed| {
//TODO: we can use unsafe and remove double checking the type id
(boxed as Box<Any + 'static>)
(boxed as Box<dyn Any + 'static>)
.downcast()
.ok()
.map(|boxed| *boxed)
Expand All @@ -95,7 +95,7 @@ impl Extensions {
.as_ref()
.and_then(|map| map.get(&TypeId::of::<T>()))
//TODO: we can use unsafe and remove double checking the type id
.and_then(|boxed| (&**boxed as &(Any + 'static)).downcast_ref())
.and_then(|boxed| (&**boxed as &(dyn Any + 'static)).downcast_ref())
}

/// Get a mutable reference to a type previously inserted on this `Extensions`.
Expand All @@ -116,7 +116,7 @@ impl Extensions {
.as_mut()
.and_then(|map| map.get_mut(&TypeId::of::<T>()))
//TODO: we can use unsafe and remove double checking the type id
.and_then(|boxed| (&mut **boxed as &mut (Any + 'static)).downcast_mut())
.and_then(|boxed| (&mut **boxed as &mut (dyn Any + 'static)).downcast_mut())
}


Expand All @@ -140,7 +140,7 @@ impl Extensions {
.and_then(|map| map.remove(&TypeId::of::<T>()))
.and_then(|boxed| {
//TODO: we can use unsafe and remove double checking the type id
(boxed as Box<Any + 'static>)
(boxed as Box<dyn Any + 'static>)
.downcast()
.ok()
.map(|boxed| *boxed)
Expand Down
2 changes: 1 addition & 1 deletion src/header/name.rs
Expand Up @@ -1071,7 +1071,7 @@ fn parse_hdr<'a>(
0 => Err(InvalidHeaderName::new()),
len if len > 64 => Ok(HdrName::custom(data, false)),
len => {
let mut word = &mut b[..len];
let word = &mut b[..len];
// Read from data into the buffer - transforming using `table` as we go
for i in 0..len {
word[i] = table[data[i] as usize]
Expand Down
16 changes: 8 additions & 8 deletions src/uri/path.rs
Expand Up @@ -47,7 +47,7 @@ impl PathAndQuery {
{
let mut iter = src.as_ref().iter().enumerate();

// path ...
// path ..=
for (i, &b) in &mut iter {
// See https://url.spec.whatwg.org/#path-state
match b {
Expand All @@ -65,30 +65,30 @@ impl PathAndQuery {
// percent-encoded in the path. If it should have been
// percent-encoded, then error.
0x21 |
0x24...0x3B |
0x24..=0x3B |
0x3D |
0x40...0x5F |
0x61...0x7A |
0x40..=0x5F |
0x61..=0x7A |
0x7C |
0x7E => {},

_ => return Err(ErrorKind::InvalidUriChar.into()),
}
}

// query ...
// query ..=
if query != NONE {
for (i, &b) in iter {
match b {
// While queries *should* be percent-encoded, most
// bytes are actually allowed...
// bytes are actually allowed..=
// See https://url.spec.whatwg.org/#query-state
//
// Allowed: 0x21 / 0x24 - 0x3B / 0x3D / 0x3F - 0x7E
0x21 |
0x24...0x3B |
0x24..=0x3B |
0x3D |
0x3F...0x7E => {},
0x3F..=0x7E => {},

b'#' => {
fragment = Some(i);
Expand Down
2 changes: 1 addition & 1 deletion tests/header_map_fuzz.rs
Expand Up @@ -255,7 +255,7 @@ impl Action {
}
Action::Remove { name, val } => {
// Just to help track the state, load all associated values.
map.get_all(&name).iter().collect::<Vec<_>>();
map.get_all(&name).iter().for_each(|_| ());

let actual = map.remove(&name);
assert_eq!(actual, val);
Expand Down

0 comments on commit ef50f99

Please sign in to comment.