Skip to content

Commit

Permalink
icu_capi clippy cleanup (unicode-org#4355)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Nov 27, 2023
1 parent 6f1a04b commit 0197253
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 19 deletions.
2 changes: 2 additions & 0 deletions ffi/capi/c/include/ICU4XList.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ffi/capi/c/include/ICU4XReorderedIndexMap.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ffi/capi/cpp/docs/source/bidi_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ffi/capi/cpp/docs/source/list_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ffi/capi/cpp/include/ICU4XList.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ffi/capi/cpp/include/ICU4XList.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions ffi/capi/cpp/include/ICU4XReorderedIndexMap.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions ffi/capi/cpp/include/ICU4XReorderedIndexMap.hpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions ffi/capi/dart/package/lib/src/List.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions ffi/capi/dart/package/lib/src/ReorderedIndexMap.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ffi/capi/js/package/docs/source/bidi_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ffi/capi/js/package/docs/source/list_ffi.rst

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ffi/capi/js/package/lib/ICU4XList.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ffi/capi/js/package/lib/ICU4XList.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions ffi/capi/js/package/lib/ICU4XReorderedIndexMap.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions ffi/capi/js/package/lib/ICU4XReorderedIndexMap.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion ffi/capi/src/bidi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,16 @@ pub mod ffi {
}

/// The length of this map
#[allow(clippy::len_without_is_empty)]
#[diplomat::attr(dart, rename = "length")]
pub fn len(&self) -> usize {
self.0.len()
}

/// Whether this map is empty
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}

/// Get element at `index`. Returns 0 when out of bounds
/// (note that 0 is also a valid in-bounds value, please use `len()`
/// to avoid out-of-bounds)
Expand Down
9 changes: 6 additions & 3 deletions ffi/capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@
// Exhaustiveness and Debug is not required for Diplomat types
)
)]
#![allow(clippy::upper_case_acronyms)]
#![allow(clippy::needless_lifetimes)]
#![allow(clippy::result_unit_err)]
// Diplomat limitations
#![allow(
clippy::needless_lifetimes,
clippy::result_unit_err,
clippy::should_implement_trait
)]

//! This crate contains the source of truth for the [Diplomat](https://github.com/rust-diplomat/diplomat)-generated
//! FFI bindings. This generates the C, C++, JavaScript, and TypeScript bindings. This crate also contains the `extern "C"`
Expand Down
6 changes: 5 additions & 1 deletion ffi/capi/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ pub mod ffi {
}

/// The number of elements in this list
#[allow(clippy::len_without_is_empty)] // don't need to follow Rust conventions over FFI
#[diplomat::attr(dart, rename = "length")]
pub fn len(&self) -> usize {
self.0.len()
}

/// Whether this list is empty
pub fn is_empty(&self) -> bool {
self.0.is_empty()
}
}

#[diplomat::rust_link(icu::list::ListLength, Enum)]
Expand Down
1 change: 0 additions & 1 deletion ffi/capi/src/locale.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ pub mod ffi {

/// Clones the [`ICU4XLocale`].
#[diplomat::rust_link(icu::locid::Locale, Struct)]
#[allow(clippy::should_implement_trait)]
pub fn clone(&self) -> Box<ICU4XLocale> {
Box::new(ICU4XLocale(self.0.clone()))
}
Expand Down
1 change: 0 additions & 1 deletion ffi/capi/src/properties_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ pub mod ffi {
/// Advance the iterator by one and return the next range.
///
/// If the iterator is out of items, `done` will be true
#[allow(clippy::should_implement_trait)] // Rust isn't calling this code
pub fn next(&mut self) -> CodePointRangeIteratorResult {
self.0
.next()
Expand Down
3 changes: 0 additions & 3 deletions ffi/capi/src/segmenter_grapheme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ pub mod ffi {
impl<'a> ICU4XGraphemeClusterBreakIteratorUtf8<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::GraphemeClusterBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::GraphemeClusterBreakIterator::Item,
Expand All @@ -119,7 +118,6 @@ pub mod ffi {
impl<'a> ICU4XGraphemeClusterBreakIteratorUtf16<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::GraphemeClusterBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::GraphemeClusterBreakIterator::Item,
Expand All @@ -137,7 +135,6 @@ pub mod ffi {
impl<'a> ICU4XGraphemeClusterBreakIteratorLatin1<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::GraphemeClusterBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::GraphemeClusterBreakIterator::Item,
Expand Down
3 changes: 0 additions & 3 deletions ffi/capi/src/segmenter_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ pub mod ffi {
impl<'a> ICU4XLineBreakIteratorUtf8<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::LineBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::LineBreakIterator::Item,
Expand All @@ -205,7 +204,6 @@ pub mod ffi {
impl<'a> ICU4XLineBreakIteratorUtf16<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::LineBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::LineBreakIterator::Item,
Expand All @@ -223,7 +221,6 @@ pub mod ffi {
impl<'a> ICU4XLineBreakIteratorLatin1<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::LineBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::LineBreakIterator::Item,
Expand Down
3 changes: 0 additions & 3 deletions ffi/capi/src/segmenter_sentence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ pub mod ffi {
impl<'a> ICU4XSentenceBreakIteratorUtf8<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::SentenceBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::SentenceBreakIterator::Item,
Expand All @@ -106,7 +105,6 @@ pub mod ffi {
impl<'a> ICU4XSentenceBreakIteratorUtf16<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::SentenceBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::SentenceBreakIterator::Item,
Expand All @@ -124,7 +122,6 @@ pub mod ffi {
impl<'a> ICU4XSentenceBreakIteratorLatin1<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::SentenceBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::SentenceBreakIterator::Item,
Expand Down
3 changes: 0 additions & 3 deletions ffi/capi/src/segmenter_word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub mod ffi {
impl<'a> ICU4XWordBreakIteratorUtf8<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::WordBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::WordBreakIterator::Item,
Expand Down Expand Up @@ -154,7 +153,6 @@ pub mod ffi {
impl<'a> ICU4XWordBreakIteratorUtf16<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::WordBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::WordBreakIterator::Item,
Expand Down Expand Up @@ -184,7 +182,6 @@ pub mod ffi {
impl<'a> ICU4XWordBreakIteratorLatin1<'a> {
/// Finds the next breakpoint. Returns -1 if at the end of the string or if the index is
/// out of range of a 32-bit signed integer.
#[allow(clippy::should_implement_trait)]
#[diplomat::rust_link(icu::segmenter::WordBreakIterator::next, FnInStruct)]
#[diplomat::rust_link(
icu::segmenter::WordBreakIterator::Item,
Expand Down

0 comments on commit 0197253

Please sign in to comment.