Skip to content

Commit

Permalink
Merge #8
Browse files Browse the repository at this point in the history
8: Clippy fixes r=torkleyy a=dbkaplun

* Verify clippy + rustfmt before passing
* Build for rust stable, beta, and nightly


Co-authored-by: Dan Kaplun <[email protected]>
  • Loading branch information
bors[bot] and dbkaplun committed May 16, 2018
2 parents 824a0f3 + 0d61858 commit bd18124
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
19 changes: 17 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
language: rust
rust:
- stable
- beta
- nightly

env:
global:
Expand All @@ -13,5 +17,16 @@ after_script:
- mv target/doc doc
- curl http://www.rust-ci.org/artifacts/put?t=$RUSTCI_TOKEN | sh



cache: cargo
matrix:
fast_finish: true
include:
- rust: nightly-2018-05-06
env: # use env so updating versions causes cache invalidation
- CLIPPY_VERSION=0.0.197
before_script:
- rustup component add rustfmt-preview
- cargo install clippy --version $CLIPPY_VERSION || echo "clippy already installed"
script:
- cargo fmt -- --write-mode=check
- cargo clippy
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,14 @@ impl<'a, T> FromRawPtr for &'a T {
/// Transforms lifetime of the second pointer to match the first.
#[inline]
unsafe fn copy_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, ptr: &T) -> &'a T {
mem::transmute(ptr)
&*(ptr as *const T)
}

/// Transforms lifetime of the second pointer to match the first.
#[inline]
#[allow(unknown_lints, mut_from_ref)]
unsafe fn copy_mut_lifetime<'a, S: ?Sized, T: ?Sized + 'a>(_ptr: &'a S, ptr: &mut T) -> &'a mut T {
mem::transmute(ptr)
&mut *(ptr as *mut T)
}

/// This is a restricted version of the Atom. It allows for only
Expand Down Expand Up @@ -284,7 +285,7 @@ where
P: IntoRawPtr + FromRawPtr + Deref<Target = T>,
{
/// If the Atom is set, get the value
pub fn get<'a>(&'a self, order: Ordering) -> Option<&'a T> {
pub fn get(&self, order: Ordering) -> Option<&T> {
let ptr = self.inner.inner.load(order);
let val = unsafe { Atom::inner_from_raw(ptr) };
val.map(|v: P| {
Expand All @@ -299,7 +300,7 @@ where

impl<T> AtomSetOnce<Box<T>> {
/// If the Atom is set, get the value
pub fn get_mut<'a>(&'a mut self, order: Ordering) -> Option<&'a mut T> {
pub fn get_mut(&mut self, order: Ordering) -> Option<&mut T> {
let ptr = self.inner.inner.load(order);
let val = unsafe { Atom::inner_from_raw(ptr) };
val.map(move |mut v: Box<T>| {
Expand All @@ -317,7 +318,7 @@ where
T: Clone + IntoRawPtr + FromRawPtr,
{
/// Duplicate the inner pointer if it is set
pub fn dup<'a>(&self, order: Ordering) -> Option<T> {
pub fn dup(&self, order: Ordering) -> Option<T> {
let ptr = self.inner.inner.load(order);
let val = unsafe { Atom::inner_from_raw(ptr) };
val.map(|v: T| {
Expand Down

0 comments on commit bd18124

Please sign in to comment.