Update rustfmt.

This commit is contained in:
Henri Sivonen
2018-12-20 14:07:00 +02:00
parent d8ee055e8f
commit 58c2c8a517
9 changed files with 35 additions and 92 deletions
+2 -10
View File
@@ -164,11 +164,7 @@ macro_rules! basic_latin_alu {
$stride_fn:ident) => {
#[cfg_attr(
feature = "cargo-clippy",
allow(
clippy::never_loop,
clippy::cast_ptr_alignment,
clippy::cast_lossless
)
allow(clippy::never_loop, clippy::cast_ptr_alignment, clippy::cast_lossless)
)]
#[inline(always)]
pub unsafe fn $name(
@@ -263,11 +259,7 @@ macro_rules! latin1_alu {
($name:ident, $src_unit:ty, $dst_unit:ty, $stride_fn:ident) => {
#[cfg_attr(
feature = "cargo-clippy",
allow(
clippy::never_loop,
clippy::cast_ptr_alignment,
clippy::cast_lossless
)
allow(clippy::never_loop, clippy::cast_ptr_alignment, clippy::cast_lossless)
)]
#[inline(always)]
pub unsafe fn $name(src: *const $src_unit, dst: *mut $dst_unit, len: usize) {
+10 -40
View File
@@ -29498,10 +29498,7 @@ pub static JIS0208_RANGE_TRIPLES: [u16; 54] = [
0x29DC, 0x000A, 0x2170, 0x29E6, 0x000A, 0x2160,
];
#[cfg(all(
feature = "less-slow-kanji-encode",
not(feature = "fast-kanji-encode")
))]
#[cfg(all(feature = "less-slow-kanji-encode", not(feature = "fast-kanji-encode")))]
static JIS0208_LEVEL1_KANJI_CODE_POINTS: [u16; 2965] = [
0x4E00, 0x4E01, 0x4E03, 0x4E07, 0x4E08, 0x4E09, 0x4E0A, 0x4E0B, 0x4E0D, 0x4E0E, 0x4E11, 0x4E14,
0x4E16, 0x4E18, 0x4E19, 0x4E1E, 0x4E21, 0x4E26, 0x4E2D, 0x4E32, 0x4E38, 0x4E39, 0x4E3B, 0x4E43,
@@ -29753,10 +29750,7 @@ static JIS0208_LEVEL1_KANJI_CODE_POINTS: [u16; 2965] = [
0x9F8D,
];
#[cfg(all(
feature = "less-slow-kanji-encode",
not(feature = "fast-kanji-encode")
))]
#[cfg(all(feature = "less-slow-kanji-encode", not(feature = "fast-kanji-encode")))]
static JIS0208_LEVEL1_KANJI_SHIFT_JIS_BYTES: [[u8; 2]; 2965] = [
[0x88, 0xEA],
[0x92, 0x9A],
@@ -113967,10 +113961,7 @@ pub fn jis0208_kanji_shift_jis_encode(bmp: u16) -> Option<(u8, u8)> {
Some((lead | 0x80, trail))
}
#[cfg(any(
feature = "less-slow-kanji-encode",
feature = "fast-kanji-encode"
))]
#[cfg(any(feature = "less-slow-kanji-encode", feature = "fast-kanji-encode"))]
#[inline(always)]
fn shift_jis_to_euc_jp(tuple: (u8, u8)) -> (u8, u8) {
let (shift_jis_lead, shift_jis_trail) = tuple;
@@ -114012,10 +114003,7 @@ pub fn jis0208_kanji_euc_jp_encode(bmp: u16) -> Option<(u8, u8)> {
Some(shift_jis_to_euc_jp((lead, trail)))
}
#[cfg(any(
feature = "less-slow-kanji-encode",
feature = "fast-kanji-encode"
))]
#[cfg(any(feature = "less-slow-kanji-encode", feature = "fast-kanji-encode"))]
#[inline(always)]
fn shift_jis_to_iso_2022_jp(tuple: (u8, u8)) -> (u8, u8) {
let (shift_jis_lead, shift_jis_trail) = tuple;
@@ -114057,10 +114045,7 @@ pub fn jis0208_kanji_iso_2022_jp_encode(bmp: u16) -> Option<(u8, u8)> {
Some(shift_jis_to_iso_2022_jp((lead, trail)))
}
#[cfg(not(any(
feature = "less-slow-kanji-encode",
feature = "fast-kanji-encode"
)))]
#[cfg(not(any(feature = "less-slow-kanji-encode", feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_shift_jis_encode(bmp: u16) -> Option<(u8, u8)> {
position(&JIS0208_LEVEL1_KANJI[..], bmp).map(|kanji_pointer| {
@@ -114073,10 +114058,7 @@ pub fn jis0208_level1_kanji_shift_jis_encode(bmp: u16) -> Option<(u8, u8)> {
})
}
#[cfg(all(
feature = "less-slow-kanji-encode",
not(feature = "fast-kanji-encode")
))]
#[cfg(all(feature = "less-slow-kanji-encode", not(feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_shift_jis_encode(bmp: u16) -> Option<(u8, u8)> {
match JIS0208_LEVEL1_KANJI_CODE_POINTS.binary_search(&bmp) {
@@ -114088,10 +114070,7 @@ pub fn jis0208_level1_kanji_shift_jis_encode(bmp: u16) -> Option<(u8, u8)> {
}
}
#[cfg(not(any(
feature = "less-slow-kanji-encode",
feature = "fast-kanji-encode"
)))]
#[cfg(not(any(feature = "less-slow-kanji-encode", feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_euc_jp_encode(bmp: u16) -> Option<(u8, u8)> {
position(&JIS0208_LEVEL1_KANJI[..], bmp).map(|kanji_pointer| {
@@ -114101,19 +114080,13 @@ pub fn jis0208_level1_kanji_euc_jp_encode(bmp: u16) -> Option<(u8, u8)> {
})
}
#[cfg(all(
feature = "less-slow-kanji-encode",
not(feature = "fast-kanji-encode")
))]
#[cfg(all(feature = "less-slow-kanji-encode", not(feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_euc_jp_encode(bmp: u16) -> Option<(u8, u8)> {
jis0208_level1_kanji_shift_jis_encode(bmp).map(shift_jis_to_euc_jp)
}
#[cfg(not(any(
feature = "less-slow-kanji-encode",
feature = "fast-kanji-encode"
)))]
#[cfg(not(any(feature = "less-slow-kanji-encode", feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_iso_2022_jp_encode(bmp: u16) -> Option<(u8, u8)> {
position(&JIS0208_LEVEL1_KANJI[..], bmp).map(|kanji_pointer| {
@@ -114123,10 +114096,7 @@ pub fn jis0208_level1_kanji_iso_2022_jp_encode(bmp: u16) -> Option<(u8, u8)> {
})
}
#[cfg(all(
feature = "less-slow-kanji-encode",
not(feature = "fast-kanji-encode")
))]
#[cfg(all(feature = "less-slow-kanji-encode", not(feature = "fast-kanji-encode")))]
#[inline(always)]
pub fn jis0208_level1_kanji_iso_2022_jp_encode(bmp: u16) -> Option<(u8, u8)> {
jis0208_level1_kanji_shift_jis_encode(bmp).map(shift_jis_to_iso_2022_jp)
+1 -2
View File
@@ -34,7 +34,6 @@ use simd_funcs::*;
all(target_endian = "little", target_feature = "neon")
)
))]
use packed_simd::u16x8;
use super::DecoderResult;
@@ -283,7 +282,7 @@ fn convert_unaligned_utf16_to_utf8<E: Endian>(
unit
}
CopyAsciiResult::Stop(read_written) => {
return (src_pos + read_written, dst_pos + read_written, false)
return (src_pos + read_written, dst_pos + read_written, false);
}
};
if dst_pos >= dst_len_minus_three {
+2 -8
View File
@@ -367,10 +367,7 @@ fn is_kanji_mapped(bmp: u16) -> bool {
#[cfg(not(feature = "fast-kanji-encode"))]
#[cfg_attr(
feature = "cargo-clippy",
allow(
clippy::if_let_redundant_pattern_matching,
clippy::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 {
@@ -391,10 +388,7 @@ fn is_kanji_mapped(bmp: u16) -> bool {
#[cfg_attr(
feature = "cargo-clippy",
allow(
clippy::if_let_redundant_pattern_matching,
clippy::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
+12 -21
View File
@@ -9,11 +9,7 @@
#![cfg_attr(
feature = "cargo-clippy",
allow(
clippy::doc_markdown,
clippy::inline_always,
clippy::new_ret_no_self
)
allow(clippy::doc_markdown, clippy::inline_always, clippy::new_ret_no_self)
)]
#![doc(html_root_url = "https://docs.rs/encoding_rs/0.8.10")]
@@ -676,7 +672,6 @@ extern crate cfg_if;
all(target_endian = "little", target_feature = "neon")
)
))]
#[macro_use(shuffle)]
extern crate packed_simd;
@@ -3658,7 +3653,7 @@ impl Decoder {
| DecoderLifeCycle::AtUtf8Start
| DecoderLifeCycle::AtUtf16LeStart
| DecoderLifeCycle::AtUtf16BeStart => {
return self.variant.max_utf8_buffer_length(byte_length)
return self.variant.max_utf8_buffer_length(byte_length);
}
DecoderLifeCycle::AtStart => {
if let Some(utf8_bom) = checked_add(3, byte_length.checked_mul(3)) {
@@ -3750,7 +3745,7 @@ impl Decoder {
| DecoderLifeCycle::AtUtf16BeStart => {
return self
.variant
.max_utf8_buffer_length_without_replacement(byte_length)
.max_utf8_buffer_length_without_replacement(byte_length);
}
DecoderLifeCycle::AtStart => {
if let Some(utf8_bom) = byte_length.checked_add(3) {
@@ -4066,7 +4061,7 @@ impl Decoder {
| DecoderLifeCycle::AtUtf8Start
| DecoderLifeCycle::AtUtf16LeStart
| DecoderLifeCycle::AtUtf16BeStart => {
return self.variant.max_utf16_buffer_length(byte_length)
return self.variant.max_utf16_buffer_length(byte_length);
}
DecoderLifeCycle::AtStart => {
if let Some(utf8_bom) = byte_length.checked_add(1) {
@@ -5305,13 +5300,11 @@ mod tests {
#[test]
fn test_decode_bomful_invalid_utf8_to_cow_without_bom_handling_and_without_replacement() {
assert!(
UTF_8
.decode_without_bom_handling_and_without_replacement(
b"\xEF\xBB\xBF\xE2\x82\xAC\x80\xC3\xA4"
)
.is_none()
);
assert!(UTF_8
.decode_without_bom_handling_and_without_replacement(
b"\xEF\xBB\xBF\xE2\x82\xAC\x80\xC3\xA4"
)
.is_none());
}
#[test]
@@ -5329,11 +5322,9 @@ mod tests {
#[test]
fn test_decode_invalid_windows_1257_to_cow_without_bom_handling_and_without_replacement() {
assert!(
WINDOWS_1257
.decode_without_bom_handling_and_without_replacement(b"abc\x80\xA1\xE4")
.is_none()
);
assert!(WINDOWS_1257
.decode_without_bom_handling_and_without_replacement(b"abc\x80\xA1\xE4")
.is_none());
}
#[test]
+5 -5
View File
@@ -35,7 +35,7 @@ macro_rules! non_fuzz_debug_assert {
($($arg:tt)*) => (if !cfg!(fuzzing) { debug_assert!($($arg)*); })
}
cfg_if!{
cfg_if! {
if #[cfg(feature = "simd-accel")] {
use ::std::intrinsics::unlikely;
} else {
@@ -218,7 +218,7 @@ macro_rules! by_unit_check_simd {
};
}
cfg_if!{
cfg_if! {
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
use simd_funcs::*;
use packed_simd::u8x16;
@@ -350,7 +350,7 @@ fn utf16_valid_up_to_alu(buffer: &[u16]) -> (usize, bool) {
}
}
cfg_if!{
cfg_if! {
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
#[inline(always)]
fn is_str_latin1_impl(buffer: &str) -> Option<usize> {
@@ -439,7 +439,7 @@ fn is_utf8_latin1_impl(buffer: &[u8]) -> Option<usize> {
}
}
cfg_if!{
cfg_if! {
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
#[inline(always)]
fn is_utf16_bidi_impl(buffer: &[u16]) -> bool {
@@ -489,7 +489,7 @@ cfg_if!{
}
}
cfg_if!{
cfg_if! {
if #[cfg(all(feature = "simd-accel", any(target_feature = "sse2", all(target_endian = "little", target_arch = "aarch64"), all(target_endian = "little", target_feature = "neon"))))] {
#[inline(always)]
fn check_utf16_for_latin1_and_bidi_impl(buffer: &[u16]) -> Latin1Bidi {
+1 -4
View File
@@ -296,10 +296,7 @@ pub fn simd_unpack(s: u8x16) -> (u16x8, u16x8) {
u8x16::splat(0),
[8, 24, 9, 25, 10, 26, 11, 27, 12, 28, 13, 29, 14, 30, 15, 31]
);
(
u16x8::from_bits(first),
u16x8::from_bits(second)
)
(u16x8::from_bits(first), u16x8::from_bits(second))
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ use ascii::basic_latin_to_ascii;
use handles::*;
use variant::*;
cfg_if!{
cfg_if! {
if #[cfg(feature = "simd-accel")] {
use ::std::intrinsics::unlikely;
use ::std::intrinsics::likely;
+1 -1
View File
@@ -11,7 +11,7 @@ use super::*;
use handles::*;
use variant::*;
cfg_if!{
cfg_if! {
if #[cfg(feature = "simd-accel")] {
use simd_funcs::*;
use packed_simd::u16x8;