Skip to content

Commit b077494

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

File tree

10 files changed

+43
-37
lines changed

10 files changed

+43
-37
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/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/stream_safe.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mod tests {
110110
use crate::normalize::decompose_compatible;
111111

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

115115
use core::char;
116116

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy