8000 Check clippy and formatting in CI · unicode-rs/unicode-normalization@0b9b162 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0b9b162

Browse files
Check clippy and formatting in CI
And also mass-reformat. `tables.rs` is ignored for now
1 parent 771ddda commit 0b9b162

13 files changed

+62
-40
lines changed

.github/workflows/rust.yml

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ on:
77
branches: [ master ]
88

99
env:
10+
CARGO_INCREMENTAL: 0
1011
CARGO_TERM_COLOR: always
12+
RUST_BACKTRACE: 1
13+
RUSTFLAGS: -D warnings
1114
RUSTDOCFLAGS: -D warnings --cfg docsrs
1215

1316
jobs:
@@ -21,17 +24,17 @@ jobs:
2124
- nightly
2225
steps:
2326
- uses: actions/checkout@v2
24-
- name: Install latest nightly
27+
- name: Install toolchain
2528
uses: actions-rs/toolchain@v1
2629
with:
2730
toolchain: ${{ matrix.rust }}
2831
override: true
2932
- name: Build
3033
run: cargo build --verbose
31-
- name: Run tests
32-
run: cargo test --verbose
34+
- name: Run tests with all features
35+
run: cargo test --all-features --verbose
3336
- name: Run tests without features
34-
run: cargo test --verbose --no-default-features
37+
run: cargo test --no-default-features --verbose
3538
- name: Package
3639
run: cargo package
3740
- name: Test package
@@ -41,6 +44,12 @@ jobs:
4144
- name: Build docs
4245
if: matrix.rust == 'nightly'
4346
run: cargo doc --all-features --verbose
47+
- name: Check formatting
48+
if: matrix.rust == 'stable'
49+
run: cargo fmt --all --check
50+
- name: Check clippy
51+
if: matrix.rust == 'stable'
52+
run: cargo clippy --all-features --all --verbose
4453
msrv:
4554
runs-on: ubuntu-latest
4655
steps:

Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@
22

33
name = "unicode-normalization"
44
version = "0.1.23"
5-
authors = ["kwantam <kwantam@gmail.com>", "Manish Goregaokar <manishsmail@gmail.com>"]
5+
authors = [
6+
"kwantam <kwantam@gmail.com>",
7+
"Manish Goregaokar <manishsmail@gmail.com>",
8+
]
69

710
homepage = "https://github.com/unicode-rs/unicode-normalization"
811
repository = "https://github.com/unicode-rs/unicode-normalization"
912
documentation = "https://docs.rs/unicode-normalization/"
1013

1114
license = "MIT/Apache-2.0"
12-
keywords = ["text", "unicode", "normalization", "decomposition", "recomposition"]
15+
keywords = [
16+
"text",
17+
"unicode",
18+
"normalization",
19+
"decomposition",
20+
"recomposition",
21+
]
1322
readme = "README.md"
1423
description = """
1524
This crate provides functions for normalization of
@@ -22,7 +31,7 @@ rust-version = "1.36"
2231

2332
edition = "2018"
2433

25-
exclude = [ "target/*", "Cargo.lock", "scripts/tmp", "*.txt", "tests/*" ]
34+
exclude = ["target/*", "Cargo.lock", "scripts/tmp", "*.txt", "tests/*"]
2635

2736
[dependencies.tinyvec]
2837
version = "1"

scripts/unicode.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,7 @@ def minimal_perfect_hash(d):
579579
data = UnicodeData()
580580
with open("tables.rs", "w", newline = "\n") as out:
581581
out.write(PREAMBLE)
582+
out.write("#![cfg_attr(rustfmt, rustfmt::skip)]\n")
582583
out.write("use crate::quick_check::IsNormalized;\n")
583584
out.write("use crate::quick_check::IsNormalized::*;\n")
584585
out.write("\n")

src/__test_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// If you're caught using this outside this crates tests/, you get to clean up the mess.
66

77
#[cfg(not(feature = "std"))]
8-
use crate::no_std_prelude::*;
8+
use alloc::string::String;
99

1010
use crate::stream_safe::StreamSafe;
1111

src/decompose.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010
use core::fmt::{self, Write};
11-
use core::iter::Fuse;
11+
use core::iter::{Fuse, FusedIterator};
1212
use core::ops::Range;
1313
use tinyvec::TinyVec;
1414

@@ -151,6 +151,8 @@ impl<I: Iterator<Item = char>> Iterator for Decompositions<I> {
151151
}
152152
}
153153

154+
impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Decompositions<I> {}
155+
154156
impl<I: Iterator<Item = char> + Clone> fmt::Display for Decompositions<I> {
155157
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
156158
for c in self.clone() {

src/lib.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,7 @@ pub use crate::recompose::Recompositions;
6262
pub use crate::replace::Replacements;
6363
pub use crate::stream_safe::StreamSafe;
6464
pub use crate::tables::UNICODE_VERSION;
65-
use core::{
66-
str::Chars,
67-
option,
68-
};
69-
70-
mod no_std_prelude;
65+
use core::{option, str::Chars};
7166

7267
mod decompose;
7368
mod lookups;
@@ -169,7 +164,6 @@ impl<'a> UnicodeNormalization<Chars<'a>> for &'a str {
169164
}
170165
}
171166

172-
173167
impl UnicodeNormalization<option::IntoIter<char>> for char {
174168
#[inline]
175169
fn nfd(self) -> Decompositions<option::IntoIter<char>> {

src/no_std_prelude.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/recompose.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
// except according to those terms.
1010

1111
use crate::decompose::Decompositions;
12-
use core::fmt::{self, Write};
12+
use core::{
13+
fmt::{self, Write},
14+
iter::FusedIterator,
15+
};
1316
use tinyvec::TinyVec;
1417

1518
#[derive(Clone)]
@@ -144,6 +147,8 @@ impl<I: Iterator<Item = char>> Iterator for Recompositions<I> {
144147
}
145148
}
146149

150+
impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Recompositions<I> {}
151+
147152
impl<I: Iterator<Item = char> + Clone> fmt::Display for Recompositions<I> {
148153
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
149154
for c in self.clone() {

src/replace.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
use core::fmt::{self, Write};
10+
use core::{
11+
fmt::{self, Write},
12+
iter::FusedIterator,
13+
};
1114
use tinyvec::ArrayVec;
1215

1316
/// External iterator for replacements for a string's characters.
@@ -51,6 +54,8 @@ impl<I: Iterator<Item = char>> Iterator for Replacements<I> {
5154
}
5255
}
5356

57+
impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for Replacements<I> {}
58+
5459
impl<I: Iterator<Item = char> + Clone> fmt::Display for Replacements<I> {
5560
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
5661
for c in self.clone() {

src/stream_safe.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::iter::FusedIterator;
2+
13
use crate::lookups::{
24
canonical_combining_class, canonical_fully_decomposed, compatibility_fully_decomposed,
35
stream_safe_trailing_nonstarters,
@@ -59,6 +61,8 @@ impl<I: Iterator<Item = char>> Iterator for StreamSafe<I> {
5961
}
6062
}
6163

64+
impl<I: Iterator<Item = char> + FusedIterator> FusedIterator for StreamSafe<I> {}
65+
6266
#[derive(Debug)]
6367
pub(crate) struct Decomposition {
6468
pub(crate) leading_nonstarters: usize,
@@ -110,7 +114,7 @@ mod tests {
110114
use crate::normalize::decompose_compatible;
111115

112116
#[cfg(not(feature = "std"))]
113-
use crate::no_std_prelude::*;
117+
use alloc::{string::String, vec::Vec};
114118

115119
use core::char;
116120

src/tables.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// NOTE: The following code was generated by "scripts/unicode.py", do not edit directly
1212

1313
#![allow(missing_docs)]
14+
#![cfg_attr(rustfmt, rustfmt::skip)]
1415
use crate::quick_check::IsNormalized;
1516
use crate::quick_check::IsNormalized::*;
1617

src/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use super::UnicodeNormalization;
1313
use core::char;
1414

1515
#[cfg(not(feature = "std"))]
16-
use crate::no_std_prelude::*;
16+
use alloc::string::{String, ToString};
1717

1818
#[test]
1919
fn test_nfd() {

tests/test_streamsafe_regression.rs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
use unicode_normalization::{
2-
is_nfc, is_nfc_stream_safe, UnicodeNormalization,
3-
};
4-
5-
#[test]
6-
fn test_streamsafe_regression(){
7-
let input = "\u{342}".repeat(55) + &"\u{344}".repeat(3);
8-
let nfc_ss = input.chars().nfc().stream_safe().collect::<String>();
9-
10-
// The result should be NFC:
11-
assert!(is_nfc(&nfc_ss));
12-
// and should be stream-safe:
13-
assert!(is_nfc_stream_safe(&nfc_ss))
14-
}
1+
use unicode_normalization::{is_nfc, is_nfc_stream_safe, UnicodeNormalization};
2+
3+
#[test]
4+
fn test_streamsafe_regression() {
5+
let input = "\u{342}".repeat(55) + &"\u{344}".repeat(3);
6+
let nfc_ss = input.chars().nfc().stream_safe().collect::<String>();
7+
8+
// The result should be NFC:
9+
assert!(is_nfc(&nfc_ss));
10+
// and should be stream-safe:
11+
assert!(is_nfc_stream_safe(&nfc_ss))
12+
}

0 commit comments

Comments
 (0)
0