Skip to content

Commit

Permalink
Fix warnings when building with all-targets, no-default-features (#5212)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Jul 10, 2024
1 parent a4728d6 commit 05769e3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion components/casemap/benches/casemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use icu_casemap::CaseMapper;
use icu_locale_core::langid;
#[cfg(feature = "bench")]
use icu_normalizer::DecomposingNormalizer;

const TEST_STRING_EN: &str = "One of the key design principles of ICU4X is to make locale data small and portable, allowing it to be pulled from multiple sources depending on the needs of the application. This document explains how that goal can be achieved.";

// First 50 lines of the Iliad, in precomposed Greek
// (The Iliad is thousands of years old and public domain)
// Sources can be found in https://www.perseus.tufts.edu/hopper/text?doc=Perseus:text:1999.01.0133 or https://www.sacred-texts.com/cla/homer/greek/ili01.htm
#[cfg(feature = "bench")]
const ILIAD: &str = include_str!("data/Iliad.txt");

fn overview_bench(c: &mut Criterion) {
Expand Down Expand Up @@ -48,9 +50,10 @@ fn overview_bench(c: &mut Criterion) {
});
});
}
fn greek_uppercasing(c: &mut Criterion) {
fn greek_uppercasing(_c: &mut Criterion) {
#[cfg(feature = "bench")]
{
let c = _c;
let casemapper = CaseMapper::new();
let root = langid!("und");
let el = langid!("el");
Expand Down
2 changes: 1 addition & 1 deletion components/list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
//! Note: this last example is not fully internationalized. See [icu4x/2192](https://github.com/unicode-org/icu4x/issues/2192)
//! for full unit handling.
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![cfg_attr(
not(test),
deny(
Expand Down
2 changes: 1 addition & 1 deletion ffi/capi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

// https://github.com/unicode-org/icu4x/blob/main/documents/process/boilerplate.md#library-annotations
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(any(test, feature = "std")), no_std)]
#![cfg_attr(
not(test),
deny(
Expand Down
5 changes: 5 additions & 0 deletions utils/writeable/benches/writeable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ impl Writeable for WriteableMessage<'_> {
writeable::impl_display_with_writeable!(WriteableMessage<'_>);

/// A sample type implementing Display
#[cfg(feature = "bench")]
struct DisplayMessage<'s> {
message: &'s str,
}

#[cfg(feature = "bench")]
impl fmt::Display for DisplayMessage<'_> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.message)
}
}

/// A sample type that contains multiple fields
#[cfg(feature = "bench")]
struct ComplexWriteable<'a> {
prefix: &'a str,
n0: usize,
Expand All @@ -44,6 +47,7 @@ struct ComplexWriteable<'a> {
suffix: &'a str,
}

#[cfg(feature = "bench")]
impl Writeable for ComplexWriteable<'_> {
fn write_to<W: fmt::Write + ?Sized>(&self, sink: &mut W) -> fmt::Result {
self.prefix.write_to(sink)?;
Expand All @@ -63,6 +67,7 @@ impl Writeable for ComplexWriteable<'_> {
}
}

#[cfg(feature = "bench")]
writeable::impl_display_with_writeable!(ComplexWriteable<'_>);

const SHORT_STR: &str = "short";
Expand Down
3 changes: 3 additions & 0 deletions utils/zerotrie/benches/overview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@

use criterion::{black_box, criterion_group, criterion_main, Criterion};
use litemap::LiteMap;
#[cfg(feature = "bench")]
use std::collections::HashMap;
use zerotrie::ZeroTrieExtendedCapacity;
use zerotrie::ZeroTriePerfectHash;
use zerotrie::ZeroTrieSimpleAscii;
#[cfg(feature = "bench")]
use zerovec::ZeroHashMap;
#[cfg(feature = "bench")]
use zerovec::ZeroMap;

mod testdata {
Expand Down
1 change: 1 addition & 0 deletions utils/zerovec/benches/zeromap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ fn bench_deserialize_zerohashmap(c: &mut Criterion) {
});
}

#[cfg(feature = "bench")]
fn bench_deserialize_large_zerohashmap(c: &mut Criterion) {
let buf = large_zerohashmap_postcard_bytes();
c.bench_function("zerohashmap/deserialize/large", |b| {
Expand Down

0 comments on commit 05769e3

Please sign in to comment.