Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: build for macOS #431

Merged
merged 14 commits into from
May 10, 2024
42 changes: 18 additions & 24 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,29 +125,28 @@ jobs:
strategy:
matrix:
target:
- intel-catalina
- intel-bigsur
- m1-bigsur
- intel-monterey
- intel-ventura
- silicon-sonoma
include:
- target: intel-catalina
os: macOS-10.15
- target: intel-monterey
os: macOS-12.0
toolchain_target: x86_64-apple-darwin
toolchain: stable
aux_args: ""
default: false
- target: intel-bigsur
os: macOS-11.0
aux_args: --target x86_64-apple-darwin
default: true
- target: intel-ventura
os: macOS-13.0
toolchain_target: x86_64-apple-darwin
toolchain: stable
aux_args: --target x86_64-apple-darwin
default: true
- target: silicon-sonoma
os: macOS-14.0
toolchain_target: aarch64-apple-darwin
toolchain: stable
aux_args: ""
default: false
# TODO enable again and try to find out why this fails
# - target: m1-bigsur
# os: macOS-11.0
# toolchain_target: aarch64-apple-darwin
# toolchain: nightly
# aux_args: --target aarch64-apple-darwin
# default: true

steps:
- name: Checkout repository
Expand All @@ -158,19 +157,14 @@ jobs:
- name: Install stable toolchain
uses: actions-rs/toolchain@v1.0.6
with:
toolchain: stable
toolchain: ${{ matrix.toolchain }}
target: ${{ matrix.toolchain_target }}
override: true
default: ${{ matrix.default }}

- name: Install htslib dependencies
run: brew install bzip2 zlib xz curl-openssl

#- uses: actions-rs/toolchain@v1.0.6
# with:
# toolchain: ${{ matrix.toolchain }}
# target: ${{ matrix.toolchain_target }}
# #override: true
# default: ${{ matrix.default }}

- name: Test
uses: actions-rs/cargo@v1.0.1
with:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ bio-types = ">=0.9"
byteorder = "1.3"
custom_derive = "0.1"
derive-new = "0.5"
hts-sys = {version = "2.1.1", default-features = false}
hts-sys = {version = "2.1.4", default-features = false, features = ["bindgen"]}
ieee754 = "0.2"
lazy_static = "1.4"
libc = "0.2"
Expand Down
8 changes: 4 additions & 4 deletions src/bam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,12 +1122,12 @@

//println!("{}", str::from_utf8(&header_string).unwrap());
let rec = htslib::sam_hdr_parse(
((l_text + 1) as usize).try_into().unwrap(),

Check warning on line 1125 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

casting to the same type is unnecessary (`usize` -> `usize`)

warning: casting to the same type is unnecessary (`usize` -> `usize`) --> src/bam/mod.rs:1125:17 | 1125 | ((l_text + 1) as usize).try_into().unwrap(), | ^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(l_text + 1)` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast

Check warning on line 1125 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

useless conversion to the same type: `usize`

warning: useless conversion to the same type: `usize` --> src/bam/mod.rs:1125:17 | 1125 | ((l_text + 1) as usize).try_into().unwrap(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: consider removing `.try_into()` = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `#[warn(clippy::useless_conversion)]` on by default
text as *const c_char,
);

(*rec).text = text as *mut c_char;
(*rec).l_text = l_text as u64;
(*rec).l_text = l_text;
rec
};

Expand Down Expand Up @@ -1288,7 +1288,7 @@
}
};

match self.reader.read(&mut record) {

Check warning on line 1291 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> src/bam/mod.rs:1291:32 | 1291 | match self.reader.read(&mut record) { | ^^^^^^^^^^^ help: change this to: `record` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
None => None,
Some(Ok(_)) => Some(Ok(Rc::clone(&self.record))),
Some(Err(err)) => Some(Err(err)),
Expand Down Expand Up @@ -1392,9 +1392,9 @@
header_string.len(),
);

let rec = htslib::sam_hdr_parse((l_text + 1) as u64, text as *const c_char);
let rec = htslib::sam_hdr_parse((l_text + 1), text as *const c_char);

Check warning on line 1395 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (no-default-features)

unnecessary parentheses around function argument

Check warning on line 1395 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (no-default-features)

unnecessary parentheses around function argument

Check warning on line 1395 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unnecessary parentheses around function argument

warning: unnecessary parentheses around function argument --> src/bam/mod.rs:1395:45 | 1395 | let rec = htslib::sam_hdr_parse((l_text + 1), text as *const c_char); | ^ ^ | = note: `#[warn(unused_parens)]` on by default help: remove these parentheses | 1395 - let rec = htslib::sam_hdr_parse((l_text + 1), text as *const c_char); 1395 + let rec = htslib::sam_hdr_parse(l_text + 1, text as *const c_char); |

Check warning on line 1395 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (all-features)

unnecessary parentheses around function argument

Check warning on line 1395 in src/bam/mod.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (all-features)

unnecessary parentheses around function argument
(*rec).text = text as *mut c_char;
(*rec).l_text = l_text as u64;
(*rec).l_text = l_text;
rec
};

Expand Down Expand Up @@ -1580,7 +1580,7 @@
assert_eq!(c1.inner().core.l_qname, b1.inner().core.l_qname);
assert_eq!(c1.inner().core.n_cigar, b1.inner().core.n_cigar);
assert_eq!(c1.inner().core.l_qseq, b1.inner().core.l_qseq);
assert_eq!(c1.inner().core.isize, b1.inner().core.isize);
assert_eq!(c1.inner().core.isize_, b1.inner().core.isize_);
//... except m_data
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/bam/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
Record {
inner: {
#[allow(clippy::uninit_assumed_init)]
let mut inner = unsafe { MaybeUninit::uninit().assume_init() };

Check warning on line 129 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (no-default-features)

the type `hts_sys::bam1_t` does not permit being left uninitialized

Check warning on line 129 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

the type `hts_sys::bam1_t` does not permit being left uninitialized

warning: the type `hts_sys::bam1_t` does not permit being left uninitialized --> src/bam/record.rs:129:42 | 129 | let mut inner = unsafe { MaybeUninit::uninit().assume_init() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | this code causes undefined behavior when executed | help: use `MaybeUninit<T>` instead, and only call `assume_init` after initialization is done | = note: integers must be initialized = note: `#[warn(invalid_value)]` on by default

Check warning on line 129 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (all-features)

the type `hts_sys::bam1_t` does not permit being left uninitialized
unsafe {
::libc::memcpy(
&mut inner as *mut htslib::bam1_t as *mut ::libc::c_void,
Expand All @@ -152,8 +152,8 @@

let mut sam_string = htslib::kstring_t {
s: sam_copy.as_ptr() as *mut c_char,
l: sam_copy.len() as u64,
m: sam_copy.len() as u64,
l: sam_copy.len(),
m: sam_copy.len(),
};

let succ = unsafe {
Expand Down Expand Up @@ -286,12 +286,12 @@

/// Get insert size.
pub fn insert_size(&self) -> i64 {
self.inner().core.isize
self.inner().core.isize_
}

/// Set insert size.
pub fn set_insert_size(&mut self, insert_size: i64) {
self.inner_mut().core.isize = insert_size;
self.inner_mut().core.isize_ = insert_size;
}

fn qname_capacity(&self) -> usize {
Expand Down Expand Up @@ -800,7 +800,7 @@
ctag,
b'A' as c_char,
size_of::<u8>() as i32,
[v].as_mut_ptr() as *mut u8,

Check warning on line 803 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)

warning: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) --> src/bam/record.rs:803:21 | 803 | [v].as_mut_ptr() as *mut u8, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[v].as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast = note: `#[warn(clippy::unnecessary_cast)]` on by default
),
Aux::I8(v) => htslib::bam_aux_append(
self.inner_ptr_mut(),
Expand All @@ -814,7 +814,7 @@
ctag,
b'C' as c_char,
size_of::<u8>() as i32,
[v].as_mut_ptr() as *mut u8,

Check warning on line 817 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`)

warning: casting raw pointers to the same type and constness is unnecessary (`*mut u8` -> `*mut u8`) --> src/bam/record.rs:817:21 | 817 | [v].as_mut_ptr() as *mut u8, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `[v].as_mut_ptr()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
),
Aux::I16(v) => htslib::bam_aux_append(
self.inner_ptr_mut(),
Expand Down Expand Up @@ -1609,7 +1609,7 @@

/// Return encoded base. Complexity: O(1).
#[inline]
pub unsafe fn encoded_base_unchecked(&self, i: usize) -> u8 {

Check warning on line 1612 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unsafe function's docs miss `# Safety` section

warning: unsafe function's docs miss `# Safety` section --> src/bam/record.rs:1612:5 | 1612 | pub unsafe fn encoded_base_unchecked(&self, i: usize) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc = note: `#[warn(clippy::missing_safety_doc)]` on by default
encoded_base_unchecked(self.encoded, i)
}

Expand All @@ -1617,7 +1617,7 @@
/// Use index based access seq()[i], for checked, safe access.
/// Complexity: O(1).
#[inline]
pub unsafe fn decoded_base_unchecked(&self, i: usize) -> u8 {

Check warning on line 1620 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unsafe function's docs miss `# Safety` section

warning: unsafe function's docs miss `# Safety` section --> src/bam/record.rs:1620:5 | 1620 | pub unsafe fn decoded_base_unchecked(&self, i: usize) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_safety_doc
*decode_base_unchecked(self.encoded_base_unchecked(i))
}

Expand Down Expand Up @@ -2234,7 +2234,7 @@
/// This function allocates memory for the state structure
/// and initializes the iterator to the start of the modification
/// records.
fn new<'a>(r: &'a Record) -> Result<BaseModificationState<'a>> {

Check warning on line 2237 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

warning: the following explicit lifetimes could be elided: 'a --> src/bam/record.rs:2237:12 | 2237 | fn new<'a>(r: &'a Record) -> Result<BaseModificationState<'a>> { | ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes = note: `#[warn(clippy::needless_lifetimes)]` on by default help: elide the lifetimes | 2237 - fn new<'a>(r: &'a Record) -> Result<BaseModificationState<'a>> { 2237 + fn new(r: &Record) -> Result<BaseModificationState<'_>> { |
let mut bm = unsafe {
BaseModificationState {
record: r,
Expand All @@ -2258,7 +2258,7 @@

let types = bm.recorded();
bm.buffer.reserve(types.len());
return Ok(bm);

Check warning on line 2261 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2261:9 | 2261 | return Ok(bm); | ^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 2261 - return Ok(bm); 2261 + Ok(bm) |
}

pub fn buffer_next_mods(&mut self) -> Result<usize> {
Expand Down Expand Up @@ -2286,7 +2286,7 @@
// not update the length so needs to be manually set
self.buffer.set_len(ret as usize);

return Ok(ret as usize);

Check warning on line 2289 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2289:13 | 2289 | return Ok(ret as usize); | ^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2289 - return Ok(ret as usize); 2289 + Ok(ret as usize) |
}
}

Expand All @@ -2311,7 +2311,7 @@
/// and the ascii code for the canonical base.
/// If there are multiple modifications with the same code this will return the data
/// for the first mod. See https://github.com/samtools/htslib/issues/1635
pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> {

Check warning on line 2314 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

this lifetime isn't used in the function definition

warning: this lifetime isn't used in the function definition --> src/bam/record.rs:2314:23 | 2314 | pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> { | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes = note: `#[warn(clippy::extra_unused_lifetimes)]` on by default
unsafe {
let mut strand: i32 = 0;
let mut implicit: i32 = 0;
Expand All @@ -2326,13 +2326,13 @@
&mut canonical,
);
if ret == -1 {
return Err(Error::BamBaseModificationTypeNotFound);

Check warning on line 2329 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2329:17 | 2329 | return Err(Error::BamBaseModificationTypeNotFound); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2329 - return Err(Error::BamBaseModificationTypeNotFound); 2329 + Err(Error::BamBaseModificationTypeNotFound) |
} else {
return Ok(BaseModificationMetadata {
strand,
implicit,
canonical: canonical.try_into().unwrap(),
});

Check warning on line 2335 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2331:17 | 2331 | / return Ok(BaseModificationMetadata { 2332 | | strand, 2333 | | implicit, 2334 | | canonical: canonical.try_into().unwrap(), 2335 | | }); | |__________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2331 ~ Ok(BaseModificationMetadata { 2332 + strand, 2333 + implicit, 2334 + canonical: canonical.try_into().unwrap(), 2335 ~ }) |
}
}
}
Expand All @@ -2353,7 +2353,7 @@
}

impl BaseModificationsPositionIter<'_> {
fn new<'a>(r: &'a Record) -> Result<BaseModificationsPositionIter<'a>> {

Check warning on line 2356 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

warning: the following explicit lifetimes could be elided: 'a --> src/bam/record.rs:2356:12 | 2356 | fn new<'a>(r: &'a Record) -> Result<BaseModificationsPositionIter<'a>> { | ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 2356 - fn new<'a>(r: &'a Record) -> Result<BaseModificationsPositionIter<'a>> { 2356 + fn new(r: &Record) -> Result<BaseModificationsPositionIter<'_>> { |
let state = BaseModificationState::new(r)?;
Ok(BaseModificationsPositionIter { mod_state: state })
}
Expand All @@ -2362,8 +2362,8 @@
return self.mod_state.recorded();
}

pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> {

Check warning on line 2365 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

this lifetime isn't used in the function definition

warning: this lifetime isn't used in the function definition --> src/bam/record.rs:2365:23 | 2365 | pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> { | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
return self.mod_state.query_type(code);

Check warning on line 2366 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2366:9 | 2366 | return self.mod_state.query_type(code); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2366 - return self.mod_state.query_type(code); 2366 + self.mod_state.query_type(code) |
}
}

Expand All @@ -2380,13 +2380,13 @@
match ret {
Ok(num_mods) => {
if num_mods == 0 {
return None;

Check warning on line 2383 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2383:21 | 2383 | return None; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2383 - return None; 2383 + None |
} else {
let data = (self.mod_state.buffer_pos, self.mod_state.buffer.clone());
return Some(Ok(data));

Check warning on line 2386 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2386:21 | 2386 | return Some(Ok(data)); | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2386 - return Some(Ok(data)); 2386 + Some(Ok(data)) |
}
}
Err(e) => return Some(Err(e)),

Check warning on line 2389 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2389:23 | 2389 | Err(e) => return Some(Err(e)), | ^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2389 | Err(e) => Some(Err(e)), | ~~~~~~~~~~~~
}
}
}
Expand All @@ -2399,7 +2399,7 @@
}

impl BaseModificationsIter<'_> {
fn new<'a>(r: &'a Record) -> Result<BaseModificationsIter<'a>> {

Check warning on line 2402 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

the following explicit lifetimes could be elided: 'a

warning: the following explicit lifetimes could be elided: 'a --> src/bam/record.rs:2402:12 | 2402 | fn new<'a>(r: &'a Record) -> Result<BaseModificationsIter<'a>> { | ^^ ^^ ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_lifetimes help: elide the lifetimes | 2402 - fn new<'a>(r: &'a Record) -> Result<BaseModificationsIter<'a>> { 2402 + fn new(r: &Record) -> Result<BaseModificationsIter<'_>> { |
let state = BaseModificationState::new(r)?;
Ok(BaseModificationsIter {
mod_state: state,
Expand All @@ -2411,8 +2411,8 @@
return self.mod_state.recorded();
}

pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> {

Check warning on line 2414 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

this lifetime isn't used in the function definition

warning: this lifetime isn't used in the function definition --> src/bam/record.rs:2414:23 | 2414 | pub fn query_type<'a>(&self, code: i32) -> Result<BaseModificationMetadata> { | ^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#extra_unused_lifetimes
return self.mod_state.query_type(code);

Check warning on line 2415 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2415:9 | 2415 | return self.mod_state.query_type(code); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2415 - return self.mod_state.query_type(code); 2415 + self.mod_state.query_type(code) |
}
}

Expand Down Expand Up @@ -2446,7 +2446,7 @@
self.mod_state.buffer[self.buffer_idx],
);
self.buffer_idx += 1;
return Some(Ok(data));

Check warning on line 2449 in src/bam/record.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bam/record.rs:2449:9 | 2449 | return Some(Ok(data)); | ^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 2449 - return Some(Ok(data)); 2449 + Some(Ok(data)) |
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/bam/record_serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Serialize for Record {
state.serialize_field("seq_len", &core.l_qseq)?;
state.serialize_field("mtid", &core.mtid)?;
state.serialize_field("mpos", &core.mpos)?;
state.serialize_field("isize", &core.isize)?;
state.serialize_field("isize", &core.isize_)?;
state.serialize_field("data", Bytes::new(self.data()))?;
state.end()
}
Expand Down Expand Up @@ -138,7 +138,7 @@ impl<'de> Deserialize<'de> for Record {
let mpos = seq
.next_element()?
.ok_or_else(|| de::Error::invalid_length(0, &self))?;
let isize = seq
let isize_ = seq
.next_element()?
.ok_or_else(|| de::Error::invalid_length(0, &self))?;
let data = seq
Expand All @@ -159,7 +159,7 @@ impl<'de> Deserialize<'de> for Record {
m.l_qseq = seq_len;
m.mtid = mtid;
m.mpos = mpos;
m.isize = isize;
m.isize_ = isize_;
}

rec.set_data(&data);
Expand Down Expand Up @@ -271,7 +271,7 @@ impl<'de> Deserialize<'de> for Record {
let seq_len = seq_len.ok_or_else(|| de::Error::missing_field("seq_len"))?;
let mtid = mtid.ok_or_else(|| de::Error::missing_field("mtid"))?;
let mpos = mpos.ok_or_else(|| de::Error::missing_field("mpos"))?;
let isize = isize.ok_or_else(|| de::Error::missing_field("isize"))?;
let isize_ = isize.ok_or_else(|| de::Error::missing_field("isize"))?;
let data = data
.ok_or_else(|| de::Error::missing_field("data"))?
.into_vec();
Expand All @@ -289,7 +289,7 @@ impl<'de> Deserialize<'de> for Record {
m.l_qseq = seq_len;
m.mtid = mtid;
m.mpos = mpos;
m.isize = isize;
m.isize_ = isize_;
}

rec.set_data(&data);
Expand Down
2 changes: 1 addition & 1 deletion src/bcf/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,18 @@
}

impl Buffer {
pub fn new() -> Self {
Buffer {
inner: ptr::null_mut(),
len: 0,
}
}

Check warning on line 120 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

you should consider adding a `Default` implementation for `Buffer`

warning: you should consider adding a `Default` implementation for `Buffer` --> src/bcf/record.rs:115:5 | 115 | / pub fn new() -> Self { 116 | | Buffer { 117 | | inner: ptr::null_mut(), 118 | | len: 0, 119 | | } 120 | | } | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#new_without_default = note: `#[warn(clippy::new_without_default)]` on by default help: try adding this | 114 + impl Default for Buffer { 115 + fn default() -> Self { 116 + Self::new() 117 + } 118 + } |
}

impl Drop for Buffer {
fn drop(&mut self) {
unsafe {
::libc::free(self.inner as *mut ::libc::c_void);

Check warning on line 126 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

casting raw pointers to the same type and constness is unnecessary (`*mut libc::c_void` -> `*mut libc::c_void`)

warning: casting raw pointers to the same type and constness is unnecessary (`*mut libc::c_void` -> `*mut libc::c_void`) --> src/bcf/record.rs:126:26 | 126 | ::libc::free(self.inner as *mut ::libc::c_void); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `self.inner` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_cast
}
}
}
Expand All @@ -131,7 +131,7 @@
#[derive(new, Debug)]
pub struct BufferBacked<'a, T: 'a + fmt::Debug, B: Borrow<Buffer> + 'a> {
value: T,
buffer: B,

Check warning on line 134 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (no-default-features)

field `buffer` is never read

Check warning on line 134 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

field `buffer` is never read

warning: field `buffer` is never read --> src/bcf/record.rs:134:5 | 132 | pub struct BufferBacked<'a, T: 'a + fmt::Debug, B: Borrow<Buffer> + 'a> { | ------------ field in this struct 133 | value: T, 134 | buffer: B, | ^^^^^^ | = note: `BufferBacked` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis = note: `#[warn(dead_code)]` on by default

Check warning on line 134 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / Testing-Features (all-features)

field `buffer` is never read
#[new(default)]
phantom: PhantomData<&'a B>,
}
Expand Down Expand Up @@ -1008,7 +1008,7 @@
}

pub fn remove_alleles(&mut self, remove: &[bool]) -> Result<()> {
let rm_set = unsafe { htslib::kbs_init(remove.len() as u64) };
let rm_set = unsafe { htslib::kbs_init(remove.len()) };

for (i, &r) in remove.iter().enumerate() {
if r {
Expand Down Expand Up @@ -1094,7 +1094,7 @@
fn clone(&self) -> Self {
let inner = unsafe {
let inner = htslib::bcf_dup(self.inner);
inner

Check warning on line 1097 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

returning the result of a `let` binding from a block

warning: returning the result of a `let` binding from a block --> src/bcf/record.rs:1097:13 | 1096 | let inner = htslib::bcf_dup(self.inner); | ---------------------------------------- unnecessary `let` binding 1097 | inner | ^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#let_and_return = note: `#[warn(clippy::let_and_return)]` on by default help: return the expression directly | 1096 ~ 1097 ~ htslib::bcf_dup(self.inner) |
};
Record {
inner,
Expand Down Expand Up @@ -1193,7 +1193,7 @@

impl fmt::Display for Genotype {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let &Genotype(ref alleles) = self;

Check warning on line 1196 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

dereferencing a tuple pattern where every element takes a reference

warning: dereferencing a tuple pattern where every element takes a reference --> src/bcf/record.rs:1196:13 | 1196 | let &Genotype(ref alleles) = self; | ^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrowed_reference = note: `#[warn(clippy::needless_borrowed_reference)]` on by default help: try removing the `&` and `ref` parts | 1196 - let &Genotype(ref alleles) = self; 1196 + let Genotype(alleles) = self; |
write!(f, "{}", alleles[0])?;
for a in &alleles[1..] {
let sep = match a {
Expand Down Expand Up @@ -1326,7 +1326,7 @@
/// as along as the data is accessed. If parts of the data are accessed while
/// the BufferBacked object is already dropped, you will access unallocated
/// memory.
pub fn string(mut self) -> Result<Option<BufferBacked<'b, Vec<&'b [u8]>, B>>> {

Check warning on line 1329 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

very complex type used. Consider factoring parts into `type` definitions

warning: very complex type used. Consider factoring parts into `type` definitions --> src/bcf/record.rs:1329:32 | 1329 | pub fn string(mut self) -> Result<Option<BufferBacked<'b, Vec<&'b [u8]>, B>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity = note: `#[warn(clippy::type_complexity)]` on by default
self.data(htslib::BCF_HT_STR).map(|data| {
data.map(|ret| {
BufferBacked::new(
Expand Down Expand Up @@ -1445,7 +1445,7 @@
)
}
.chunks(self.values_per_sample())
.map(|s| trim_slice(s))

Check warning on line 1448 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant closure

warning: redundant closure --> src/bcf/record.rs:1448:22 | 1448 | .map(|s| trim_slice(s)) | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `trim_slice` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure = note: `#[warn(clippy::redundant_closure)]` on by default
.collect(),
self.buffer,
)
Expand All @@ -1468,7 +1468,7 @@
)
}
.chunks(self.values_per_sample())
.map(|s| trim_slice(s))

Check warning on line 1471 in src/bcf/record.rs

View workflow job for this annotation

GitHub Actions / clippy

redundant closure

warning: redundant closure --> src/bcf/record.rs:1471:22 | 1471 | .map(|s| trim_slice(s)) | ^^^^^^^^^^^^^^^^^ help: replace the closure with the function itself: `trim_slice` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
.collect(),
self.buffer,
)
Expand Down
15 changes: 3 additions & 12 deletions src/bgzf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,7 @@
impl std::io::Read for Reader {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
let nbytes = unsafe {
htslib::bgzf_read(
self.inner,
buf.as_mut_ptr() as *mut libc::c_void,
buf.len() as u64,
)
htslib::bgzf_read(self.inner, buf.as_mut_ptr() as *mut libc::c_void, buf.len())
};
if nbytes < 0 {
Err(std::io::Error::new(
Expand Down Expand Up @@ -232,7 +228,7 @@
// This should be unreachable
Ok(i) => return Err(Error::BgzfInvalidCompressionLevel { level: i }),
};
return Ok(ffi::CString::new(write_string).unwrap());

Check warning on line 231 in src/bgzf/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> src/bgzf/mod.rs:231:9 | 231 | return Ok(ffi::CString::new(write_string).unwrap()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 231 - return Ok(ffi::CString::new(write_string).unwrap()); 231 + Ok(ffi::CString::new(write_string).unwrap()) |
}

/// Set the thread pool to use for parallel compression.
Expand All @@ -257,13 +253,8 @@

impl std::io::Write for Writer {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
let nbytes = unsafe {
htslib::bgzf_write(
self.inner,
buf.as_ptr() as *mut libc::c_void,
buf.len() as u64,
)
};
let nbytes =
unsafe { htslib::bgzf_write(self.inner, buf.as_ptr() as *mut libc::c_void, buf.len()) };
if nbytes < 0 {
Err(std::io::Error::new(
std::io::ErrorKind::Other,
Expand Down