chore: drop redundant 'static lifetimes in statics and consts (Sonar S8863) (#1713)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Dylan M. Taylor
2026-10-24 04:30:39 -04:00
committed by GitHub
co-authored by Claude Sonnet 5.5
parent f90d286721
commit bfd95b258b
4 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -371,7 +371,7 @@ fn locale_code(words: &[&str]) -> Option<String> {
/// from documents, so at most [`MAX_TAGS`] are kept; past that a new tag is unknown (`None`).
fn intern_tag(tag: String) -> Option<&'static str> {
const MAX_TAGS: usize = 512;
static TAGS: std::sync::Mutex<Vec<&'static str>> = std::sync::Mutex::new(Vec::new());
static TAGS: std::sync::Mutex<Vec<&str>> = std::sync::Mutex::new(Vec::new());
let mut tags = TAGS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
if let Some(t) = tags.iter().find(|t| **t == tag) {
return Some(t);
+2 -2
View File
@@ -148,7 +148,7 @@ pub struct FaceRef(&'static FontFace);
impl FaceRef {
/// The handle for a loaded face (memoised per face).
pub fn of(face: &Arc<FontFace>) -> FaceRef {
static LEAKED: RwLock<Vec<Option<&'static FontFace>>> = RwLock::new(Vec::new());
static LEAKED: RwLock<Vec<Option<&FontFace>>> = RwLock::new(Vec::new());
let id = face.id as usize;
if let Some(Some(f)) = LEAKED.read().unwrap_or_else(PoisonError::into_inner).get(id) {
return FaceRef(f);
@@ -579,7 +579,7 @@ fn script_chain(c: char) -> Option<&'static [&'static str]> {
/// The Japanese fallback chain: the craft-fonts Japanese faces' families in document order
/// (Mincho first; none without craft-fonts), then [`JAPANESE_FALLBACKS`].
fn japanese_chain() -> &'static [&'static str] {
static CHAIN: std::sync::OnceLock<Vec<&'static str>> = std::sync::OnceLock::new();
static CHAIN: std::sync::OnceLock<Vec<&str>> = std::sync::OnceLock::new();
CHAIN.get_or_init(|| {
let mut chain: Vec<&'static str> = Vec::new();
for f in crate::japanese_document_fonts() {
+2 -2
View File
@@ -738,8 +738,8 @@ mod tests {
impl<const BITS: u16> tiff::encoder::colortype::ColorType for Palette<BITS> {
type Inner = u8;
const TIFF_VALUE: tiff::tags::PhotometricInterpretation = tiff::tags::PhotometricInterpretation::RGBPalette;
const BITS_PER_SAMPLE: &'static [u16] = &[BITS];
const SAMPLE_FORMAT: &'static [tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint];
const BITS_PER_SAMPLE: &[u16] = &[BITS];
const SAMPLE_FORMAT: &[tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint];
fn horizontal_predict(row: &[u8], result: &mut Vec<u8>) {
result.extend_from_slice(row);
}
+12 -12
View File
@@ -4465,18 +4465,18 @@ pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
}
fn lookup<'a>(lang: &str, s: &'a str) -> &'a str {
static GERMAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static JAPANESE: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static TRANSLATIONS: OnceLock<HashMap<&'static str, [&'static str; 5]>> = OnceLock::new();
static ARABIC: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static UKRAINIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static PORTUGUESE_BR: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static ITALIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static POLISH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static RUSSIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static CZECH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static FRENCH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static GEORGIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
static GERMAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static JAPANESE: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static TRANSLATIONS: OnceLock<HashMap<&str, [&str; 5]>> = OnceLock::new();
static ARABIC: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static UKRAINIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static PORTUGUESE_BR: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static ITALIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static POLISH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static RUSSIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static CZECH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static FRENCH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
static GEORGIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
if lang == "ar" {
return ARABIC.get_or_init(|| ar::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
}