Skip to content

Commit

Permalink
Make cargo check pass without warning on Rust 1.82.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hsivonen committed Oct 25, 2024
1 parent fedae45 commit eec0bde
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 35 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,6 @@ serde_json = "1.0"

[profile.release]
lto = true

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(fuzzing)'] }
2 changes: 1 addition & 1 deletion generate-encoding-data.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def null_to_zero(code_point):
for j in xrange(32 - (len(astralness) % 32)):
astralness.append(0)

data_file.write('''#[cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
data_file.write('''#[allow(clippy::unreadable_literal)]
static BIG5_ASTRALNESS: [u32; %d] = [
''' % (len(astralness) / 32))

Expand Down
19 changes: 8 additions & 11 deletions src/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ macro_rules! ascii_alu {
/// write
/// Safety-usable invariant: will return Some() when it fails
/// to convert. The first value will be a u8 that is > 127.
#[cfg_attr(feature = "cargo-clippy", allow(never_loop, cast_ptr_alignment))]
#[allow(clippy::never_loop, clippy::cast_ptr_alignment)]
#[inline(always)]
pub unsafe fn $name(
src: *const $src_unit,
Expand Down Expand Up @@ -223,10 +223,7 @@ macro_rules! basic_latin_alu {
/// write
/// Safety-usable invariant: will return Some() when it fails
/// to convert. The first value will be a u8 that is > 127.
#[cfg_attr(
feature = "cargo-clippy",
allow(never_loop, cast_ptr_alignment, cast_lossless)
)]
#[allow(clippy::never_loop, clippy::cast_ptr_alignment)]
#[inline(always)]
pub unsafe fn $name(
src: *const $src_unit,
Expand Down Expand Up @@ -345,10 +342,7 @@ macro_rules! latin1_alu {
($name:ident, $src_unit:ty, $dst_unit:ty, $stride_fn:ident) => {
/// Safety: src and dst must have len elements, src is valid for read, dst is valid for
/// write
#[cfg_attr(
feature = "cargo-clippy",
allow(never_loop, cast_ptr_alignment, cast_lossless)
)]
#[allow(clippy::never_loop, clippy::cast_ptr_alignment)]
#[inline(always)]
pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
let mut offset = 0usize;
Expand Down Expand Up @@ -1505,6 +1499,7 @@ cfg_if! {
}

cfg_if! {
/*
if #[cfg(all(feature = "simd-accel", target_endian = "little", target_arch = "disabled"))] {
/// Safety-usable invariant: Will return the value and position of the first non-ASCII byte in the slice in a Some if found.
/// In other words, the first element of the Some is always `> 127`
Expand Down Expand Up @@ -1539,7 +1534,9 @@ cfg_if! {
}
None
}
} else if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
} else
*/
if #[cfg(all(feature = "simd-accel", target_feature = "sse2"))] {
/// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
/// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
#[inline(always)]
Expand Down Expand Up @@ -1722,7 +1719,7 @@ cfg_if! {

/// Safety-usable invariant: will return Some() when it encounters non-ASCII, with the first element in the Some being
/// guaranteed to be non-ASCII (> 127), and the second being the offset where it is found
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
#[allow(clippy::cast_ptr_alignment)]
#[inline(always)]
pub fn validate_ascii(slice: &[u8]) -> Option<(u8, usize)> {
let src = slice.as_ptr();
Expand Down
2 changes: 1 addition & 1 deletion src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ pub static SINGLE_BYTE_DATA: SingleByteData = SingleByteData {
],
};

#[cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
#[allow(clippy::unreadable_literal)]
static BIG5_ASTRALNESS: [u32; 589] = [
0x445F0520, 0xB882520F, 0x400000F8, 0x044EA920, 0x00000000, 0x00010B34, 0x00000000, 0x00000000,
0x00000000, 0x0C000000, 0x00000040, 0x00000000, 0x00580400, 0x0000003C, 0x5C800000, 0xBBF3DCAD,
Expand Down
4 changes: 2 additions & 2 deletions src/handles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1180,7 +1180,7 @@ impl<'a> Utf16Source<'a> {
Space::Full(self.consumed())
}
}
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
#[allow(clippy::collapsible_if)]
#[inline(always)]
fn read(&mut self) -> char {
self.old_pos = self.pos;
Expand Down Expand Up @@ -1214,7 +1214,7 @@ impl<'a> Utf16Source<'a> {
// Unpaired low surrogate
'\u{FFFD}'
}
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
#[allow(clippy::collapsible_if)]
#[inline(always)]
fn read_enum(&mut self) -> Unicode {
self.old_pos = self.pos;
Expand Down
10 changes: 2 additions & 8 deletions src/iso_2022_jp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,10 +373,7 @@ fn is_kanji_mapped(bmp: u16) -> bool {
}

#[cfg(not(feature = "fast-kanji-encode"))]
#[cfg_attr(
feature = "cargo-clippy",
allow(if_let_redundant_pattern_matching, if_same_then_else)
)]
#[allow(clippy::if_let_redundant_pattern_matching, clippy::if_same_then_else)]
#[inline(always)]
fn is_kanji_mapped(bmp: u16) -> bool {
if 0x4EDD == bmp {
Expand All @@ -394,10 +391,7 @@ fn is_kanji_mapped(bmp: u16) -> bool {
}
}

#[cfg_attr(
feature = "cargo-clippy",
allow(if_let_redundant_pattern_matching, if_same_then_else)
)]
#[allow(clippy::if_let_redundant_pattern_matching, clippy::if_same_then_else)]
fn is_mapped_for_two_byte_encode(bmp: u16) -> bool {
// The code below uses else after return to
// keep the same structure as in EUC-JP.
Expand Down
8 changes: 5 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#![cfg_attr(
feature = "cargo-clippy",
allow(doc_markdown, inline_always, new_ret_no_self)
#![allow(
clippy::doc_markdown,
clippy::inline_always,
clippy::new_ret_no_self,
clippy::redundant_static_lifetimes
)]

//! encoding_rs is a Gecko-oriented Free Software / Open Source implementation
Expand Down
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ macro_rules! gb18030_decoder_function {
$name:ident,
$code_unit:ty,
$dest_struct:ident) => (
#[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
#[allow(clippy::never_loop)]
pub fn $name(&mut $slf,
src: &[u8],
dst: &mut [$code_unit],
Expand Down Expand Up @@ -686,7 +686,7 @@ macro_rules! euc_jp_decoder_function {
$name:ident,
$code_unit:ty,
$dest_struct:ident) => (
#[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
#[allow(clippy::never_loop)]
pub fn $name(&mut $slf,
src: &[u8],
dst: &mut [$code_unit],
Expand Down
10 changes: 5 additions & 5 deletions src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const LATIN1_MASK: usize = 0xFF00_FF00_FF00_FF00u64 as usize;
#[allow(unused_macros)]
macro_rules! by_unit_check_alu {
($name:ident, $unit:ty, $bound:expr, $mask:ident) => {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
#[allow(clippy::cast_ptr_alignment)]
#[inline(always)]
fn $name(buffer: &[$unit]) -> bool {
let mut offset = 0usize;
Expand Down Expand Up @@ -333,7 +333,7 @@ cfg_if! {

/// The second return value is true iff the last code unit of the slice was
/// reached and turned out to be a low surrogate that is part of a valid pair.
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
#[allow(clippy::collapsible_if)]
#[inline(always)]
fn utf16_valid_up_to_alu(buffer: &[u16]) -> (usize, bool) {
let len = buffer.len();
Expand Down Expand Up @@ -588,7 +588,7 @@ cfg_if! {
}
}
} else {
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
#[allow(clippy::cast_ptr_alignment)]
#[inline(always)]
fn check_utf16_for_latin1_and_bidi_impl(buffer: &[u16]) -> Latin1Bidi {
let mut offset = 0usize;
Expand Down Expand Up @@ -707,7 +707,7 @@ pub fn is_utf16_latin1(buffer: &[u16]) -> bool {
/// Returns `true` if the input is invalid UTF-8 or the input contains an
/// RTL character. Returns `false` if the input is valid UTF-8 and contains
/// no RTL characters.
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if, cyclomatic_complexity))]
#[allow(clippy::collapsible_if, clippy::cognitive_complexity)]
#[inline]
pub fn is_utf8_bidi(buffer: &[u8]) -> bool {
// As of rustc 1.25.0-nightly (73ac5d6a8 2018-01-11), this is faster
Expand Down Expand Up @@ -1137,7 +1137,7 @@ pub fn is_utf8_bidi(buffer: &[u8]) -> bool {
/// cause right-to-left behavior without the presence of right-to-left
/// characters or right-to-left controls are not checked for. As a special
/// case, U+FEFF is excluded from Arabic Presentation Forms-B.
#[cfg_attr(feature = "cargo-clippy", allow(collapsible_if))]
#[allow(clippy::collapsible_if)]
#[inline]
pub fn is_str_bidi(buffer: &str) -> bool {
// U+058F: D6 8F
Expand Down
4 changes: 2 additions & 2 deletions src/utf_8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub fn utf8_valid_up_to(src: &[u8]) -> usize {
read
}

#[cfg_attr(feature = "cargo-clippy", allow(never_loop, cyclomatic_complexity))]
#[allow(clippy::never_loop, clippy::cognitive_complexity)]
pub fn convert_utf8_to_utf16_up_to_invalid(src: &[u8], dst: &mut [u16]) -> (usize, usize) {
let mut read = 0;
let mut written = 0;
Expand Down Expand Up @@ -603,7 +603,7 @@ impl Utf8Decoder {
);
}

#[cfg_attr(feature = "cargo-clippy", allow(never_loop))]
#[allow(clippy::never_loop)]
#[inline(never)]
pub fn convert_utf16_to_utf8_partial_inner(src: &[u16], dst: &mut [u8]) -> (usize, usize) {
let mut read = 0;
Expand Down

0 comments on commit eec0bde

Please sign in to comment.