From 42d526bced1b8f0642add9f067d915ef441d01be Mon Sep 17 00:00:00 2001 From: Nikolay Kim Date: Wed, 17 Jul 2019 11:16:38 +0600 Subject: [PATCH] mark some fn as unsafe --- .travis.yml | 12 ++++++------ actix-ioframe/CHANGES.md | 2 +- actix-ioframe/src/cell.rs | 4 ++-- actix-ioframe/src/dispatcher.rs | 12 +++++++----- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index d9019c5c..006dae93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,9 +10,9 @@ matrix: include: - rust: stable - rust: beta - - rust: nightly-2019-03-02 + - rust: nightly-2019-06-15 allow_failures: - - rust: nightly-2019-03-02 + - rust: nightly-2019-06-15 env: global: @@ -25,8 +25,8 @@ before_install: - sudo apt-get install -y openssl libssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev before_cache: | - if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-03-02" ]]; then - RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install cargo-tarpaulin + if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-06-15" ]]; then + RUSTFLAGS="--cfg procmacro2_semver_exempt" cargo install --version 0.6.11 cargo-tarpaulin fi # Add clippy @@ -35,14 +35,14 @@ before_script: script: - | - if [[ "$TRAVIS_RUST_VERSION" != "nightly-2019-03-02" ]]; then + if [[ "$TRAVIS_RUST_VERSION" != "nightly-2019-06-15" ]]; then cargo clean cargo test --all --all-features -- --nocapture fi after_success: - | - if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-03-02" ]]; then + if [[ "$TRAVIS_RUST_VERSION" == "nightly-2019-06-15" ]]; then taskset -c 0 cargo tarpaulin --all --all-features --out Xml echo "Uploaded code coverage" bash <(curl -s https://codecov.io/bash) diff --git a/actix-ioframe/CHANGES.md b/actix-ioframe/CHANGES.md index a958a328..0f084238 100644 --- a/actix-ioframe/CHANGES.md +++ b/actix-ioframe/CHANGES.md @@ -1,5 +1,5 @@ # Changes -## [0.1.0] - 2019-xx-xx +## [0.1.0] - 2019-07-17 * Initial release diff --git a/actix-ioframe/src/cell.rs b/actix-ioframe/src/cell.rs index 1794dd66..e517aca1 100644 --- a/actix-ioframe/src/cell.rs +++ b/actix-ioframe/src/cell.rs @@ -29,7 +29,7 @@ impl Cell { } } - pub fn get_mut(&mut self) -> &mut T { - unsafe { &mut *self.inner.as_ref().get() } + pub(crate) unsafe fn get_mut(&mut self) -> &mut T { + &mut *self.inner.as_ref().get() } } diff --git a/actix-ioframe/src/dispatcher.rs b/actix-ioframe/src/dispatcher.rs index a43646c3..54e5deb5 100644 --- a/actix-ioframe/src/dispatcher.rs +++ b/actix-ioframe/src/dispatcher.rs @@ -153,7 +153,7 @@ where }; let mut cell = self.inner.clone(); - cell.get_mut().task.register(); + unsafe { cell.get_mut().task.register() }; tokio_current_thread::spawn( self.service .call(Item::new(self.state.clone(), self.sink.clone(), item)) @@ -163,9 +163,11 @@ where Ok(None) => return Ok(()), Err(err) => Err(err), }; - let inner = cell.get_mut(); - inner.buf.push_back(item); - inner.task.notify(); + unsafe { + let inner = cell.get_mut(); + inner.buf.push_back(item); + inner.task.notify(); + } Ok(()) }), ); @@ -181,7 +183,7 @@ where /// write to framed object fn poll_write(&mut self) -> bool { - let inner = self.inner.get_mut(); + let inner = unsafe { self.inner.get_mut() }; let mut rx_done = self.rx.is_none(); let mut buf_empty = inner.buf.is_empty(); loop {