Skip to content

Commit

Permalink
Update rustc and clippy (tikv#1607)
Browse files Browse the repository at this point in the history
  • Loading branch information
tennix authored and siddontang committed Feb 14, 2017
1 parent fdd16f2 commit b4d6018
Show file tree
Hide file tree
Showing 13 changed files with 133 additions and 34 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ matrix:
include:
- os: linux
rust: nightly
env: COMPILER=g++-4.8 RUSTC_DATE=2016-12-19 CXX=g++-4.8
env: COMPILER=g++-4.8 RUSTC_DATE=2017-02-12 RUSTFMT_VERSION=v0.6.0 SKIP_FORMAT_CHECK=true CXX=g++-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'zlib1g-dev', 'libbz2-dev', 'libsnappy-dev', 'curl', 'libdw-dev', 'libelf-dev', 'elfutils', 'binutils-dev']
- os: linux
rust: nightly
env: COMPILER=g++-4.8 RUSTC_DATE=2016-08-06 ENABLE_FEATURES=default SKIP_TESTS=true CXX=g++-4.8
env: COMPILER=g++-4.8 RUSTC_DATE=2017-02-12 RUSTFMT_VERSION=v0.6.0 ENABLE_FEATURES=default SKIP_TESTS=true CXX=g++-4.8
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8', 'zlib1g-dev', 'libbz2-dev', 'libsnappy-dev', 'curl', 'libdw-dev', 'libelf-dev', 'elfutils', 'binutils-dev']
- os: osx
rust: nightly
env: COMPILER=clang++ RUSTC_DATE=2016-12-19 CXX=clang++
env: COMPILER=clang++ RUSTC_DATE=2017-02-12 SKIP_FORMAT_CHECK=true CXX=clang++

install:
- export LOCAL_DIR=$HOME/.cache/
Expand Down
116 changes: 107 additions & 9 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions benches/benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@
#![cfg_attr(feature = "dev", plugin(clippy))]
#![cfg_attr(not(feature = "dev"), allow(unknown_lints))]

#[macro_use]
extern crate log;
extern crate test;
extern crate mio;
extern crate rand;
#[macro_use]
extern crate tikv;
extern crate time;

Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ machine:
CPPFLAGS: "-I$HOME/.local/include"
CXXFLAGS: "-I$HOME/.local/include"
PKG_CONFIG_PATH: "$PKG_CONFIG_PATH:$HOME/.local/lib/pkgconfig"
RUSTC_DATE: "2016-12-19"
RUSTC_DATE: "2017-02-12"
LOCAL_PREFIX: "$HOME/.local"
# used by cargo
LIBRARY_PATH: "$LIBRARY_PATH:$HOME/.local/lib"
Expand Down
3 changes: 1 addition & 2 deletions docker/release_dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ RUN yum update -y && \
yum install -y devtoolset-4-gcc-c++ python27 && \
yum clean all

RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --date=2016-08-06 --disable-sudo -y --channel=nightly
RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --date=2017-02-12 --disable-sudo -y --channel=nightly

ADD https://github.com/pingcap/tikv/archive/master.tar.gz /master.tar.gz

Expand All @@ -25,4 +25,3 @@ RUN chmod a+x ./release.sh
WORKDIR /tikv

ENTRYPOINT ["/release.sh"]

2 changes: 1 addition & 1 deletion docker/rust_dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ RUN cd / && \
cd / && \
rm -rf /rocksdb-4.12.fb /rocksdb.tar.gz

RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --date=2016-08-06 --disable-sudo -y --channel=nightly
RUN curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --date=2017-02-12 --disable-sudo -y --channel=nightly
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#![allow(module_inception)]
#![allow(should_implement_trait)]
#![allow(large_enum_variant)]

#[macro_use]
extern crate log;
Expand Down
4 changes: 2 additions & 2 deletions src/raftstore/store/snap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ mod v1 {
let cap = cmp::min(self.left, DEFAULT_READ_BUFFER_SIZE);
let mut buf = vec![0; cap];
while self.left > 0 {
try!(self.read(&mut buf));
let _ = try!(self.read(&mut buf));
}
}
self.res = Some(try!(self.reader.read_u32::<BigEndian>()));
Expand Down Expand Up @@ -601,7 +601,7 @@ mod v1 {

// read partially should not affect validation.
reader = f1.get_validation_reader().unwrap();
reader.read(&mut [0, 0]).unwrap();
reader.read_exact(&mut [0, 0]).unwrap();
reader.validate().unwrap();

// read fully should not affect validation.
Expand Down
12 changes: 6 additions & 6 deletions src/raftstore/store/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {

let start_key = data_key(msg.get_start_key());
if let Some((_, &exist_region_id)) = self.region_ranges
.range(Excluded(&start_key), Unbounded::<&Key>)
.range((Excluded(start_key), Unbounded::<Key>))
.next() {
let exist_region = self.region_peers[&exist_region_id].region();
if enc_start_key(exist_region) < data_end_key(msg.get_end_key()) {
Expand Down Expand Up @@ -732,7 +732,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
return Ok(false);
}
if let Some((_, &exist_region_id)) = self.region_ranges
.range(Excluded(&enc_start_key(&snap_region)), Unbounded::<&Key>)
.range((Excluded(enc_start_key(&snap_region)), Unbounded::<Key>))
.next() {
let exist_region = self.region_peers[&exist_region_id].region();
if enc_start_key(exist_region) < enc_end_key(&snap_region) {
Expand Down Expand Up @@ -1150,7 +1150,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
// received by the TiKV driver is newer than the meta cached in the driver, the meta is
// updated.
if let Some((_, &next_region_id)) = self.region_ranges
.range(Excluded(&enc_end_key(peer.region())), Unbounded::<&Key>)
.range((Excluded(enc_end_key(peer.region())), Unbounded::<Key>))
.next() {
let next_region = self.region_peers[&next_region_id].region();
new_regions.push(next_region.to_owned());
Expand Down Expand Up @@ -1180,7 +1180,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
}

fn on_report_region_flow(&mut self, event_loop: &mut EventLoop<Self>) {
for (_, peer) in &mut self.region_peers {
for peer in self.region_peers.values_mut() {
if !peer.is_leader() {
peer.written_bytes = 0;
peer.written_keys = 0;
Expand Down Expand Up @@ -1290,7 +1290,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
self.register_split_region_check_tick(event_loop);
return;
}
for (_, peer) in &mut self.region_peers {
for peer in self.region_peers.values_mut() {
if !peer.is_leader() {
continue;
}
Expand Down Expand Up @@ -1321,7 +1321,7 @@ impl<T: Transport, C: PdClient> Store<T, C> {
}

fn on_compact_check_tick(&mut self, event_loop: &mut EventLoop<Self>) {
for (_, peer) in &mut self.region_peers {
for peer in self.region_peers.values_mut() {
if peer.delete_keys_hint < self.cfg.region_compact_delete_keys_count {
continue;
}
Expand Down
6 changes: 3 additions & 3 deletions src/util/codec/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub fn encode_msg<T: io::Write, M: protobuf::Message + ?Sized>(w: &mut T,
-> Result<()> {
let payload_len = msg.compute_size();
let header = encode_msg_header(msg_id, payload_len as usize);
try!(w.write(&header));
try!(w.write_all(&header));
try!(msg.write_to_writer(w));

Ok(())
Expand All @@ -62,8 +62,8 @@ pub fn decode_msg<T: io::Read, M: protobuf::Message>(r: &mut T, m: &mut M) -> Re
pub fn encode_data<T: io::Write>(w: &mut T, msg_id: u64, data: &[u8]) -> Result<()> {
let header = encode_msg_header(msg_id, data.len());

try!(w.write(&header));
try!(w.write(data));
try!(w.write_all(&header));
try!(w.write_all(data));

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion tests/raftstore/pd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl Cluster {

fn get_region(&self, key: Vec<u8>) -> Option<metapb::Region> {
self.regions
.range::<Key, Key>(Excluded(&key), Unbounded)
.range((Excluded(key), Unbounded))
.next()
.map(|(_, region)| region.clone())
}
Expand Down
5 changes: 3 additions & 2 deletions tests/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct CaseTraceLogger {

impl LogWriter for CaseTraceLogger {
fn write(&self, args: Arguments) {
let tag = util::get_tag_from_thread_name().unwrap_or("".into());
let tag = util::get_tag_from_thread_name().unwrap_or_else(|| "".into());
let _ = if let Some(ref out) = self.f {
let mut w = out.lock().unwrap();
write!(w, "{} {}", tag, args)
Expand All @@ -89,7 +89,8 @@ impl Drop for CaseTraceLogger {
// A help function to initial logger.
pub fn init_log() {
let output = env::var("LOG_FILE").ok();
let level = logger::get_level_by_string(&env::var("LOG_LEVEL").unwrap_or("debug".to_owned()));
let level = logger::get_level_by_string(&env::var("LOG_LEVEL")
.unwrap_or_else(|_| "debug".to_owned()));
let writer = output.map(|f| Mutex::new(File::create(f).unwrap()));
// we don't mind set it multiple times.
let _ = logger::init_log(CaseTraceLogger { f: writer }, level);
Expand Down
6 changes: 4 additions & 2 deletions travis-build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,17 @@ prepare_rust:
sh ~/rust/lib/rustlib/uninstall.sh && sh ~/rust-installer/rustup.sh --date=${RUSTC_DATE} --prefix=~/rust --disable-sudo --channel=nightly

prepare-rustfmt: | prepare_rust
cargo install --vers =0.6.0 rustfmt || exit 0
curl -L http://download.pingcap.org/rustfmt-${RUSTFMT_VERSION}-linux-amd64.tar.gz -o rustfmt-${RUSTFMT_VERSION}-linux-amd64.tar.gz && \
mkdir -p ${HOME}/.cargo/bin && tar xzf rustfmt-${RUSTFMT_VERSION}-linux-amd64.tar.gz -C ${HOME}/.cargo/bin --strip-components=1
# cargo install --vers =0.6.0 rustfmt || exit 0

prepare_linux: ${LOCAL_DIR}/lib/librocksdb.so ${LOCAL_DIR}/bin/kcov ${LOCAL_DIR}/bin/pd-server prepare-rustfmt | prepare_rust

prepare_brew:
brew update && \
brew install gflags snappy

prepare_osx: ${LOCAL_DIR}/lib/librocksdb.dylib ${LOCAL_DIR}/bin/pd-server prepare-rustfmt | prepare_brew prepare_rust
prepare_osx: ${LOCAL_DIR}/lib/librocksdb.dylib ${LOCAL_DIR}/bin/pd-server | prepare_brew prepare_rust

test_linux test_osx:
export CI=true && ${CI_BUILD_DIR}/test.sh
Expand Down

0 comments on commit b4d6018

Please sign in to comment.