Skip to content

Commit 5349361

Browse files
Fix nightly clippy (#5094)
1 parent 0392b2b commit 5349361

File tree

21 files changed

+58
-88
lines changed

21 files changed

+58
-88
lines changed

components/datetime/src/external_loaders.rs

-29
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,6 @@ pub(crate) trait AnyCalendarLoader {
3535
fn load(&self, locale: &DataLocale) -> Result<AnyCalendar, DataError>;
3636
}
3737

38-
/// Helper for type resolution with optional loader arguments
39-
pub(crate) struct PhantomLoader {
40-
_not_constructible: core::convert::Infallible,
41-
}
42-
43-
impl FixedDecimalFormatterLoader for PhantomLoader {
44-
fn load(
45-
&self,
46-
_locale: &DataLocale,
47-
_options: FixedDecimalFormatterOptions,
48-
) -> Result<FixedDecimalFormatter, DataError> {
49-
unreachable!() // not constructible
50-
}
51-
}
52-
53-
impl WeekCalculatorLoader for PhantomLoader {
54-
#[inline]
55-
fn load(&self, _locale: &DataLocale) -> Result<WeekCalculator, DataError> {
56-
unreachable!() // not constructible
57-
}
58-
}
59-
60-
impl AnyCalendarLoader for PhantomLoader {
61-
#[inline]
62-
fn load(&self, _locale: &DataLocale) -> Result<AnyCalendar, DataError> {
63-
unreachable!() // not constructible
64-
}
65-
}
66-
6738
/// Loader for types from other crates using compiled data.
6839
#[cfg(feature = "compiled_data")]
6940
pub(crate) struct ExternalLoaderCompiledData;

components/datetime/src/neo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ impl<R: DateTimeMarkers> NeoFormatter<R> {
12861286
/// ```
12871287
pub fn convert_and_format<'a, I>(&'a self, datetime: &I) -> FormattedNeoDateTime
12881288
where
1289-
I: ?Sized + ConvertCalendar,
1289+
I: ConvertCalendar,
12901290
I::Converted<'a>: NeoGetField<<R::D as DateMarkers>::YearInput>
12911291
+ NeoGetField<<R::D as DateMarkers>::MonthInput>
12921292
+ NeoGetField<<R::D as DateMarkers>::DayOfMonthInput>

components/experimental/src/transliterate/compile/pass1.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@
4949
//! ### Cursors (`|@@@ rest`, `rest @@@|`, `rest | rest`)
5050
//! There are three kinds of cursors.
5151
//! * `|@@@ rest`: The cursor is at the beginning of the replacement and has placeholders. We call
52-
//! this a cursor with _right_ placeholders, because they are on the right of the cursor.
52+
//! this a cursor with _right_ placeholders, because they are on the right of the cursor.
5353
//! * `rest @@@|`: The cursor is at the end of the replacement and has placeholders. We call this
54-
//! a cursor with _left_ placeholders, because they are on the left of the cursor.
54+
//! a cursor with _left_ placeholders, because they are on the left of the cursor.
5555
//! * `rest | rest`: The cursor is in the middle of the replacement and has no placeholders. We call
56-
//! this a pure cursor.
56+
//! this a pure cursor.
5757
//!
5858
//! Pure cursors get a reserved code point that is inlined into the replacement encoding where the
5959
//! cursor appears. Cursors with placeholders are encoded like back references, so two more

components/experimental/src/unicodeset_parse/parse.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1430,9 +1430,9 @@ where
14301430
/// # Limitations
14311431
///
14321432
/// * Currently, we only support the [ECMA-262 properties](https://tc39.es/ecma262/#table-nonbinary-unicode-properties).
1433-
/// The property names must match the exact spelling listed in ECMA-262. Note that we do support UTS35 syntax for elided `General_Category`
1434-
/// and `Script` property names, i.e., `[:Latn:]` and `[:Ll:]` are both valid, with the former implying the `Script` property, and the latter the
1435-
/// `General_Category` property.
1433+
/// The property names must match the exact spelling listed in ECMA-262. Note that we do support UTS35 syntax for elided `General_Category`
1434+
/// and `Script` property names, i.e., `[:Latn:]` and `[:Ll:]` are both valid, with the former implying the `Script` property, and the latter the
1435+
/// `General_Category` property.
14361436
/// * We do not support `\N{Unicode code point name}` character escaping. Use any other escape method described in UTS35.
14371437
///
14381438
/// ✨ *Enabled with the `compiled_data` Cargo feature.*

components/experimental/src/units/ratio.rs

+4
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ impl FromStr for IcuRatio {
348348
/// - Simple fractions: e.g., "1/2".
349349
/// - Decimals: e.g., "1.5".
350350
/// - Mixed fractions: e.g., "1.5/6", "1.4/5.6".
351+
///
351352
/// Note: Scientific notation is not supported.
352353
fn parse_fraction(decimal: &str) -> Result<IcuRatio, RatioFromStrError> {
353354
let mut components = decimal.split('/');
@@ -375,10 +376,13 @@ impl FromStr for IcuRatio {
375376
}
376377

377378
/// Parses a decimal number from a string input.
379+
///
378380
/// Accepts input in various decimal formats, including:
379381
/// - Whole numbers: "1"
380382
/// - Decimal numbers: "1.5"
383+
///
381384
/// An empty string input is interpreted as "0".
385+
///
382386
/// Note: Fractional inputs are not supported in this context.
383387
fn parse_decimal(decimal: &str) -> Result<IcuRatio, RatioFromStrError> {
384388
let is_negative = decimal.starts_with('-');

components/locale_core/benches/fixtures/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
use serde::Deserialize;
66

77
#[derive(Deserialize)]
8+
#[allow(dead_code)]
89
pub struct SubtagData {
910
pub valid: Vec<String>,
1011
pub invalid: Vec<String>,
1112
}
1213

1314
#[derive(Deserialize)]
15+
#[allow(dead_code)]
1416
pub struct Subtags {
1517
pub language: SubtagData,
1618
pub script: SubtagData,
@@ -19,6 +21,7 @@ pub struct Subtags {
1921
}
2022

2123
#[derive(Deserialize)]
24+
#[allow(dead_code)]
2225
pub struct LocaleList {
2326
pub canonicalized: Vec<String>,
2427
pub casing: Vec<String>,

components/locale_core/src/langid.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ impl LanguageIdentifier {
315315
/// regions. However, this differs from [RFC6497 (BCP 47 Extension T)], which specifies:
316316
///
317317
/// > _The canonical form for all subtags in the extension is lowercase, with the fields
318-
/// ordered by the separators, alphabetically._
318+
/// > ordered by the separators, alphabetically._
319319
///
320320
/// Hence, this method is used inside [`Transform Extensions`] to be able to get the correct
321321
/// canonicalization of the language identifier.
@@ -350,7 +350,7 @@ impl LanguageIdentifier {
350350
/// regions. However, this differs from [RFC6497 (BCP 47 Extension T)], which specifies:
351351
///
352352
/// > _The canonical form for all subtags in the extension is lowercase, with the fields
353-
/// ordered by the separators, alphabetically._
353+
/// > ordered by the separators, alphabetically._
354354
///
355355
/// Hence, this method is used inside [`Transform Extensions`] to be able to get the correct
356356
/// canonicalization of the language identifier.

components/locale_core/src/subtags/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! which represent different fields of the structure.
77
//!
88
//! * [`Language`] is the only mandatory field, which when empty,
9-
//! takes the value `und`.
9+
//! takes the value `und`.
1010
//! * [`Script`] is an optional field representing the written script used by the locale.
1111
//! * [`Region`] is the region used by the locale.
1212
//! * [`Variants`] is a list of optional [`Variant`] subtags containing information about the

components/plurals/benches/fixtures/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use icu_plurals::PluralCategory;
88
use serde::Deserialize;
99

1010
#[derive(Deserialize)]
11+
#[allow(dead_code)]
1112
pub struct NumbersFixture {
1213
pub isize: Vec<i64>,
1314
pub usize: Vec<u64>,
@@ -17,13 +18,15 @@ pub struct NumbersFixture {
1718
}
1819

1920
#[derive(Debug, Deserialize)]
21+
#[allow(dead_code)]
2022
pub struct PluralsFixture {
2123
pub langs: Vec<LanguageIdentifier>,
2224
}
2325

2426
/// Describes a number to construct from plural operands, as `value * 10^(exponent)`. Construction
2527
/// from value and exponent is because sometimes we want to preserve trailing zeros.
2628
#[derive(Deserialize)]
29+
#[allow(dead_code)]
2730
pub struct FromFixedDecimals {
2831
pub value: i64,
2932
pub exponent: i16,

components/plurals/tests/fixtures/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ use serde::Deserialize;
1010

1111
/// Defines the data-driven test sets for the operands.
1212
#[derive(Deserialize)]
13+
#[allow(dead_code)]
1314
pub struct OperandsTestSet {
1415
pub string: Vec<OperandsTest<String>>,
1516
pub int: Vec<OperandsTest<isize>>,
@@ -20,6 +21,7 @@ pub struct OperandsTestSet {
2021
/// A single test case verifying the conversion from [FixedDecimal] into
2122
/// [PluralOperands].
2223
#[derive(Debug, Deserialize)]
24+
#[allow(dead_code)]
2325
pub struct FromTestCase {
2426
/// The [FixedDecimal] input
2527
pub input: FixedDecimalInput,
@@ -99,12 +101,14 @@ impl From<PluralOperandsInput> for PluralOperands {
99101
}
100102

101103
#[derive(Debug, Clone, Deserialize)]
104+
#[allow(dead_code)]
102105
pub struct OperandsTest<T> {
103106
pub input: T,
104107
pub output: PluralOperandsInput,
105108
}
106109

107110
#[derive(Deserialize)]
111+
#[allow(dead_code)]
108112
pub struct RuleTest {
109113
pub rule: String,
110114
pub input: PluralOperandsInput,
@@ -113,12 +117,14 @@ pub struct RuleTest {
113117

114118
#[derive(Deserialize)]
115119
#[serde(untagged)]
120+
#[allow(dead_code)]
116121
pub enum RuleTestOutput {
117122
Value(bool),
118123
Error(String),
119124
}
120125

121126
#[derive(Deserialize)]
127+
#[allow(dead_code)]
122128
pub struct RuleTestSet(pub Vec<RuleTest>);
123129

124130
#[derive(Clone, Copy, Debug, Deserialize)]
@@ -162,6 +168,7 @@ impl PartialEq<PluralCategory> for &PluralCategoryInput {
162168
}
163169

164170
#[derive(Deserialize)]
171+
#[allow(dead_code)]
165172
pub struct CategoriesTest {
166173
pub langid: String,
167174
pub plural_type: PluralRuleTypeInput,

provider/bikeshed/src/decimal/decimal_pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl FromStr for DecimalSubPattern {
4444
// TODO(#567): Handle quoted literals in prefix and suffix.
4545
// i = boundary between prefix and body
4646
// j = boundary between body and suffix
47-
let i = subpattern.find(|c: char| matches!(c, '#' | '0' | ',' | '.'));
47+
let i = subpattern.find(['#', '0', ',', '.']);
4848
let i = match i {
4949
Some(i) => i,
5050
None => return Err(Error::NoBodyInSubpattern),

provider/icu4x-datagen/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ macro_rules! cb {
635635
$marker,
636636
)+
637637
$(
638-
#[cfg(feature = "experimental_components")]
638+
#[cfg(feature = "experimental")]
639639
$emarker,
640640
)+
641641
]

tools/bakeddata-scripts/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn main() {
102102

103103
let _ = std::fs::remove_dir_all(&path);
104104
for dir in ["", "src", "data"] {
105-
std::fs::create_dir(&path.join(dir)).unwrap();
105+
std::fs::create_dir(path.join(dir)).unwrap();
106106
}
107107
for (file, template) in [
108108
("build.rs", include_str!("../template/build.rs.template")),

tools/benchmark/memory/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ fn extract_bytes_from_log_line(preamble: &str, text: &str) -> u64 {
8383
///
8484
/// 1. Process the CLI arguments to get the os, and examples.
8585
/// 2. Loop through each example and:
86-
/// a. Create the directory for the benchmarks to go in.
87-
/// b. Run `cargo run --example {example}` with the appropriate settings.
88-
/// c. Extract the dhat stderr, and process out the interesting bytes.
89-
/// d. Add the output to an `ndjson` file.
90-
/// e. Move the dhat-heap.json file to the benchmark folder.
86+
/// a. Create the directory for the benchmarks to go in.
87+
/// b. Run `cargo run --example {example}` with the appropriate settings.
88+
/// c. Extract the dhat stderr, and process out the interesting bytes.
89+
/// d. Add the output to an `ndjson` file.
90+
/// e. Move the dhat-heap.json file to the benchmark folder.
9191
fn main() {
9292
let ProcessedArgs { os, examples } = process_cli_args();
9393

utils/calendrical_calculations/src/chinese_based.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ const MAX_ITERS_FOR_MONTHS_OF_YEAR: u8 = 14;
1313
/// To do so, calendars should:
1414
///
1515
/// - Implement `fn location` by providing a location at which observations of the moon are recorded, which
16-
/// may change over time (the zone is important, long, lat, and elevation are not relevant for these calculations)
16+
/// may change over time (the zone is important, long, lat, and elevation are not relevant for these calculations)
1717
/// - Define `const EPOCH` as a `RataDie` marking the start date of the era of the Calendar for internal use,
18-
/// which may not accurately reflect how years or eras are marked traditionally or seen by end-users
18+
/// which may not accurately reflect how years or eras are marked traditionally or seen by end-users
1919
pub trait ChineseBased {
2020
/// Given a fixed date, return the location used for observations of the new moon in order to
2121
/// calculate the beginning of months. For multiple Chinese-based lunar calendars, this has

utils/litemap/benches/litemap.rs

-3
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,6 @@ fn overview_bench(c: &mut Criterion) {
5757
bench_deserialize_large(c);
5858
bench_lookup(c);
5959
bench_lookup_large(c);
60-
61-
#[cfg(feature = "generate")]
62-
generate_test_data();
6360
}
6461

6562
fn build_litemap(large: bool) -> LiteMap<String, String> {

utils/zerovec/src/map/map.rs

+10-16
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,8 @@ where
323323

324324
impl<'a, K, V> ZeroMap<'a, K, V>
325325
where
326-
K: ZeroMapKV<'a, Container = ZeroVec<'a, K>> + ?Sized,
326+
K: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, K>>,
327327
V: ZeroMapKV<'a> + ?Sized,
328-
K: AsULE,
329328
{
330329
/// Cast a `ZeroMap<K, V>` to `ZeroMap<P, V>` where `K` and `P` are [`AsULE`] types
331330
/// with the same representation.
@@ -335,7 +334,7 @@ where
335334
/// If `K` and `P` have different ordering semantics, unexpected behavior may occur.
336335
pub fn cast_zv_k_unchecked<P>(self) -> ZeroMap<'a, P, V>
337336
where
338-
P: AsULE<ULE = K::ULE> + ZeroMapKV<'a, Container = ZeroVec<'a, P>> + ?Sized,
337+
P: AsULE<ULE = K::ULE> + ZeroMapKV<'a, Container = ZeroVec<'a, P>>,
339338
{
340339
ZeroMap {
341340
keys: self.keys.cast(),
@@ -355,7 +354,7 @@ where
355354
/// Panics if `K::ULE` and `P::ULE` are not the same size.
356355
pub fn try_convert_zv_k_unchecked<P>(self) -> Result<ZeroMap<'a, P, V>, ZeroVecError>
357356
where
358-
P: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, P>> + ?Sized,
357+
P: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, P>>,
359358
{
360359
Ok(ZeroMap {
361360
keys: self.keys.try_into_converted()?,
@@ -367,8 +366,7 @@ where
367366
impl<'a, K, V> ZeroMap<'a, K, V>
368367
where
369368
K: ZeroMapKV<'a> + ?Sized,
370-
V: ZeroMapKV<'a, Container = ZeroVec<'a, V>> + ?Sized,
371-
V: AsULE,
369+
V: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, V>>,
372370
{
373371
/// Cast a `ZeroMap<K, V>` to `ZeroMap<K, P>` where `V` and `P` are [`AsULE`] types
374372
/// with the same representation.
@@ -378,7 +376,7 @@ where
378376
/// If `V` and `P` have different ordering semantics, unexpected behavior may occur.
379377
pub fn cast_zv_v_unchecked<P>(self) -> ZeroMap<'a, K, P>
380378
where
381-
P: AsULE<ULE = V::ULE> + ZeroMapKV<'a, Container = ZeroVec<'a, P>> + ?Sized,
379+
P: AsULE<ULE = V::ULE> + ZeroMapKV<'a, Container = ZeroVec<'a, P>>,
382380
{
383381
ZeroMap {
384382
keys: self.keys,
@@ -398,7 +396,7 @@ where
398396
/// Panics if `V::ULE` and `P::ULE` are not the same size.
399397
pub fn try_convert_zv_v_unchecked<P>(self) -> Result<ZeroMap<'a, K, P>, ZeroVecError>
400398
where
401-
P: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, P>> + ?Sized,
399+
P: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, P>>,
402400
{
403401
Ok(ZeroMap {
404402
keys: self.keys,
@@ -468,8 +466,7 @@ where
468466
impl<'a, K, V> ZeroMap<'a, K, V>
469467
where
470468
K: ZeroMapKV<'a> + ?Sized + Ord,
471-
V: ZeroMapKV<'a> + ?Sized,
472-
V: Copy,
469+
V: Copy + ZeroMapKV<'a>,
473470
{
474471
/// For cases when `V` is fixed-size, obtain a direct copy of `V` instead of `V::ULE`.
475472
///
@@ -523,8 +520,7 @@ where
523520
impl<'a, K, V> ZeroMap<'a, K, V>
524521
where
525522
K: ZeroMapKV<'a> + ?Sized,
526-
V: ZeroMapKV<'a, Container = ZeroVec<'a, V>> + ?Sized,
527-
V: AsULE + Copy,
523+
V: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, V>>,
528524
{
529525
/// Similar to [`Self::iter()`] except it returns a direct copy of the values instead of references
530526
/// to `V::ULE`, in cases when `V` is fixed-size
@@ -544,10 +540,8 @@ where
544540

545541
impl<'a, K, V> ZeroMap<'a, K, V>
546542
where
547-
K: ZeroMapKV<'a, Container = ZeroVec<'a, K>> + ?Sized,
548-
V: ZeroMapKV<'a, Container = ZeroVec<'a, V>> + ?Sized,
549-
K: AsULE + Copy,
550-
V: AsULE + Copy,
543+
K: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, K>>,
544+
V: AsULE + ZeroMapKV<'a, Container = ZeroVec<'a, V>>,
551545
{
552546
/// Similar to [`Self::iter()`] except it returns a direct copy of the keys values instead of references
553547
/// to `K::ULE` and `V::ULE`, in cases when `K` and `V` are fixed-size

utils/zerovec/src/yoke_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use yoke::*;
2020

2121
// This impl is similar to the impl on Cow and is safe for the same reasons
2222
/// This impl requires enabling the optional `yoke` Cargo feature of the `zerovec` crate
23-
unsafe impl<'a, T: 'static + AsULE + ?Sized> Yokeable<'a> for ZeroVec<'static, T> {
23+
unsafe impl<'a, T: 'static + AsULE> Yokeable<'a> for ZeroVec<'static, T> {
2424
type Output = ZeroVec<'a, T>;
2525
#[inline]
2626
fn transform(&'a self) -> &'a Self::Output {

0 commit comments

Comments
 (0)