Update to use newer Rust features.
This re-introduces several cleanups that we previously deferred for not supporting Rust 1.25.
This commit is contained in:
@@ -105,7 +105,7 @@ impl<F: Forest> NodeData<F> {
|
|||||||
let size = usize::from(size);
|
let size = usize::from(size);
|
||||||
// TODO: We could probably use `get_unchecked()` here since `size` is always in
|
// TODO: We could probably use `get_unchecked()` here since `size` is always in
|
||||||
// range.
|
// range.
|
||||||
(&keys[0..size], &tree[0..size + 1])
|
(&keys[0..size], &tree[0..=size])
|
||||||
}
|
}
|
||||||
_ => panic!("Expected inner node"),
|
_ => panic!("Expected inner node"),
|
||||||
}
|
}
|
||||||
@@ -175,10 +175,10 @@ impl<F: Forest> NodeData<F> {
|
|||||||
debug_assert!(sz <= keys.len());
|
debug_assert!(sz <= keys.len());
|
||||||
debug_assert!(index <= sz, "Can't insert at {} with {} keys", index, sz);
|
debug_assert!(index <= sz, "Can't insert at {} with {} keys", index, sz);
|
||||||
|
|
||||||
if let Some(ks) = keys.get_mut(0..sz + 1) {
|
if let Some(ks) = keys.get_mut(0..=sz) {
|
||||||
*size = (sz + 1) as u8;
|
*size = (sz + 1) as u8;
|
||||||
slice_insert(ks, index, key);
|
slice_insert(ks, index, key);
|
||||||
slice_insert(&mut tree[1..sz + 2], index, node);
|
slice_insert(&mut tree[1..=sz + 1], index, node);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
@@ -203,10 +203,10 @@ impl<F: Forest> NodeData<F> {
|
|||||||
debug_assert!(sz <= keys.len());
|
debug_assert!(sz <= keys.len());
|
||||||
debug_assert!(index <= sz);
|
debug_assert!(index <= sz);
|
||||||
|
|
||||||
if let Some(ks) = keys.get_mut(0..sz + 1) {
|
if let Some(ks) = keys.get_mut(0..=sz) {
|
||||||
*size = (sz + 1) as u8;
|
*size = (sz + 1) as u8;
|
||||||
slice_insert(ks, index, key);
|
slice_insert(ks, index, key);
|
||||||
slice_insert(&mut vals[0..sz + 1], index, value);
|
slice_insert(&mut vals[0..=sz], index, value);
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|||||||
@@ -101,14 +101,7 @@ impl Context {
|
|||||||
let code_size = self.compile(isa)?;
|
let code_size = self.compile(isa)?;
|
||||||
let old_len = mem.len();
|
let old_len = mem.len();
|
||||||
mem.resize(old_len + code_size as usize, 0);
|
mem.resize(old_len + code_size as usize, 0);
|
||||||
unsafe {
|
unsafe { self.emit_to_memory(isa, mem.as_mut_ptr().add(old_len), relocs, traps) };
|
||||||
self.emit_to_memory(
|
|
||||||
isa,
|
|
||||||
mem.as_mut_ptr().offset(old_len as isize),
|
|
||||||
relocs,
|
|
||||||
traps,
|
|
||||||
)
|
|
||||||
};
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ fn maybe_resolve_aliases(values: &PrimaryMap<Value, ValueData>, value: Value) ->
|
|||||||
let mut v = value;
|
let mut v = value;
|
||||||
|
|
||||||
// Note that values may be empty here.
|
// Note that values may be empty here.
|
||||||
for _ in 0..values.len() + 1 {
|
for _ in 0..=values.len() {
|
||||||
if let ValueData::Alias { original, .. } = values[v] {
|
if let ValueData::Alias { original, .. } = values[v] {
|
||||||
v = original;
|
v = original;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
plugin(clippy(conf_file = "../../clippy.toml"))
|
plugin(clippy(conf_file = "../../clippy.toml"))
|
||||||
)]
|
)]
|
||||||
#![cfg_attr(feature="cargo-clippy", allow(
|
#![cfg_attr(feature="cargo-clippy", allow(
|
||||||
// This requires Rust 1.27 or later.
|
|
||||||
duration_subsec,
|
|
||||||
// Produces only a false positive:
|
// Produces only a false positive:
|
||||||
while_let_loop,
|
while_let_loop,
|
||||||
// Produces many false positives, but did produce some valid lints, now fixed:
|
// Produces many false positives, but did produce some valid lints, now fixed:
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ mod details {
|
|||||||
fn fmtdur(mut dur: Duration, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmtdur(mut dur: Duration, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
// Round to nearest ms by adding 500us.
|
// Round to nearest ms by adding 500us.
|
||||||
dur += Duration::new(0, 500_000);
|
dur += Duration::new(0, 500_000);
|
||||||
let ms = dur.subsec_nanos() / 1_000_000;
|
let ms = dur.subsec_millis();
|
||||||
write!(f, "{:4}.{:03} ", dur.as_secs(), ms)
|
write!(f, "{:4}.{:03} ", dur.as_secs(), ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,7 +234,7 @@ impl<T: EntityRef> EntityList<T> {
|
|||||||
|
|
||||||
let block = pool.alloc(sclass_for_length(len));
|
let block = pool.alloc(sclass_for_length(len));
|
||||||
pool.data[block] = T::new(len);
|
pool.data[block] = T::new(len);
|
||||||
pool.data[block + 1..block + len + 1].copy_from_slice(slice);
|
pool.data[block + 1..=block + len].copy_from_slice(slice);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
index: (block + 1) as u32,
|
index: (block + 1) as u32,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ readme = "README.md"
|
|||||||
cranelift-codegen = { path = "../codegen", version = "0.22.0" }
|
cranelift-codegen = { path = "../codegen", version = "0.22.0" }
|
||||||
cranelift-module = { path = "../module", version = "0.22.0" }
|
cranelift-module = { path = "../module", version = "0.22.0" }
|
||||||
faerie = "0.5.0"
|
faerie = "0.5.0"
|
||||||
goblin = "0.0.17"
|
goblin = "0.0.19"
|
||||||
failure = "0.1.2"
|
failure = "0.1.2"
|
||||||
target-lexicon = "0.0.3"
|
target-lexicon = "0.0.3"
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,7 @@
|
|||||||
unstable_features
|
unstable_features
|
||||||
)]
|
)]
|
||||||
#![warn(unused_import_braces)]
|
#![warn(unused_import_braces)]
|
||||||
#![cfg_attr(feature = "cargo-clippy",
|
#![cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
|
||||||
allow(
|
|
||||||
type_complexity,
|
|
||||||
// This requires Rust 1.27 or later.
|
|
||||||
duration_subsec))]
|
|
||||||
#![cfg_attr(
|
#![cfg_attr(
|
||||||
feature = "cargo-clippy",
|
feature = "cargo-clippy",
|
||||||
warn(
|
warn(
|
||||||
|
|||||||
@@ -47,13 +47,7 @@ impl Display for QueueEntry {
|
|||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
let p = self.path.to_string_lossy();
|
let p = self.path.to_string_lossy();
|
||||||
match self.state {
|
match self.state {
|
||||||
State::Done(Ok(dur)) => write!(
|
State::Done(Ok(dur)) => write!(f, "{}.{:03} {}", dur.as_secs(), dur.subsec_millis(), p),
|
||||||
f,
|
|
||||||
"{}.{:03} {}",
|
|
||||||
dur.as_secs(),
|
|
||||||
dur.subsec_nanos() / 1_000_000,
|
|
||||||
p
|
|
||||||
),
|
|
||||||
State::Done(Err(ref e)) => write!(f, "FAIL {}: {}", p, e),
|
State::Done(Err(ref e)) => write!(f, "FAIL {}: {}", p, e),
|
||||||
_ => write!(f, "{}", p),
|
_ => write!(f, "{}", p),
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ readme = "README.md"
|
|||||||
cranelift-codegen = { path = "../codegen", version = "0.22.0", default-features = false }
|
cranelift-codegen = { path = "../codegen", version = "0.22.0", default-features = false }
|
||||||
cranelift-module = { path = "../module", version = "0.22.0", default-features = false }
|
cranelift-module = { path = "../module", version = "0.22.0", default-features = false }
|
||||||
cranelift-native = { path = "../native", version = "0.22.0", default-features = false }
|
cranelift-native = { path = "../native", version = "0.22.0", default-features = false }
|
||||||
region = "0.3.0"
|
region = "1.0.0"
|
||||||
libc = { version = "0.2.42", default-features = false }
|
libc = { version = "0.2.42", default-features = false }
|
||||||
errno = "0.2.4"
|
errno = "0.2.4"
|
||||||
target-lexicon = { version = "0.0.3", default-features = false }
|
target-lexicon = { version = "0.0.3", default-features = false }
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ impl Memory {
|
|||||||
pub fn allocate(&mut self, size: usize) -> Result<*mut u8, String> {
|
pub fn allocate(&mut self, size: usize) -> Result<*mut u8, String> {
|
||||||
if size <= self.current.len - self.position {
|
if size <= self.current.len - self.position {
|
||||||
// TODO: Ensure overflow is not possible.
|
// TODO: Ensure overflow is not possible.
|
||||||
let ptr = unsafe { self.current.ptr.offset(self.position as isize) };
|
let ptr = unsafe { self.current.ptr.add(self.position) };
|
||||||
self.position += size;
|
self.position += size;
|
||||||
return Ok(ptr);
|
return Ok(ptr);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user