Skip to content

Fix mismatched_lifetime_syntaxes #508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/blocker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl Blocker {
}

#[cfg(feature = "unsync-regex-caching")]
fn borrow_regex_manager(&self) -> std::cell::RefMut<RegexManager> {
fn borrow_regex_manager(&self) -> std::cell::RefMut<'_, RegexManager> {
#[allow(unused_mut)]
let mut manager = self.regex_manager.borrow_mut();

Expand All @@ -107,7 +107,7 @@ impl Blocker {
}

#[cfg(not(feature = "unsync-regex-caching"))]
fn borrow_regex_manager(&self) -> std::sync::MutexGuard<RegexManager> {
fn borrow_regex_manager(&self) -> std::sync::MutexGuard<'_, RegexManager> {
let mut manager = self.regex_manager.lock().unwrap();
manager.update_time();
manager
Expand Down
49 changes: 0 additions & 49 deletions src/data_format/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};

use crate::blocker::Blocker;
use crate::cosmetic_filter_cache::{CosmeticFilterCache, HostnameRuleDb, ProceduralOrActionFilter};
use crate::filters::network::{NetworkFilter, NetworkFilterMaskHelper};
use crate::network_filter_list::NetworkFilterList;
use crate::utils::Hash;

Expand Down Expand Up @@ -182,54 +181,6 @@ pub(crate) struct LegacyScriptletResourceStorage {
resources: HashMap<String, LegacyScriptletResource>,
}

/// `_bug` is no longer used, and is removed from future format versions.
#[derive(Debug, Clone, Serialize)]
struct NetworkFilterSerializeFmt<'a> {
mask: &'a crate::filters::network::NetworkFilterMask,
filter: &'a crate::filters::network::FilterPart,
opt_domains: &'a Option<Vec<crate::utils::Hash>>,
opt_not_domains: &'a Option<Vec<crate::utils::Hash>>,
redirect: &'a Option<String>,
hostname: &'a Option<String>,
csp: &'a Option<String>,
_bug: Option<u32>,
tag: &'a Option<String>,
raw_line: Option<String>,
id: &'a crate::utils::Hash,
}

/// Generic over `Borrow<NetworkFilter>` because `tagged_filters_all` requires `&'a NetworkFilter`
/// while `NetworkFilterList` requires `&'a Arc<NetworkFilter>`.
impl<'a, T> From<&'a T> for NetworkFilterSerializeFmt<'a>
where
T: std::borrow::Borrow<NetworkFilter>,
{
fn from(v: &'a T) -> NetworkFilterSerializeFmt<'a> {
let v = v.borrow();
NetworkFilterSerializeFmt {
mask: &v.mask,
filter: &v.filter,
opt_domains: &v.opt_domains,
opt_not_domains: &v.opt_not_domains,
redirect: if v.is_redirect() {
&v.modifier_option
} else {
&None
},
hostname: &v.hostname,
csp: if v.is_csp() {
&v.modifier_option
} else {
&None
},
_bug: None,
tag: &v.tag,
raw_line: v.raw_line.as_ref().map(|raw| *raw.clone()),
id: &v.id,
}
}
}

/// Forces a `NetworkFilterList` to be serialized by converting to an
/// intermediate representation that is constructed with `NetworkFilterFmt` instead.
fn serialize_network_filter_list<S>(list: &NetworkFilterList, s: S) -> Result<S::Ok, S::Error>
Expand Down
13 changes: 10 additions & 3 deletions src/filters/fb_network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ use crate::regex_manager::RegexManager;
use crate::request::Request;
use crate::utils::{Hash, ShortHash};

#[allow(dead_code, clippy::all, unused_imports, unsafe_code)]
#[allow(unknown_lints)]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary for old Rust versions to support disabling mismatched_lifetime_syntaxes

#[allow(
dead_code,
clippy::all,
unused_imports,
unsafe_code,
mismatched_lifetime_syntaxes
)]
#[path = "../flatbuffers/fb_network_filter_generated.rs"]
pub mod flat;
use flat::fb;
Expand Down Expand Up @@ -173,7 +180,7 @@ impl<'a> FlatPatterns<'a> {
}

#[inline(always)]
pub fn iter(&self) -> FlatPatternsIterator {
pub fn iter(&self) -> FlatPatternsIterator<'_> {
FlatPatternsIterator {
patterns: self,
len: self.patterns.map_or(0, |d| d.len()),
Expand Down Expand Up @@ -272,7 +279,7 @@ impl<'a> FlatNetworkFilter<'a> {
}

#[inline(always)]
pub fn patterns(&self) -> FlatPatterns {
pub fn patterns(&self) -> FlatPatterns<'_> {
FlatPatterns::new(self.fb_filter.patterns())
}

Expand Down
2 changes: 1 addition & 1 deletion src/filters/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ impl FilterPart {
}
}

pub fn iter(&self) -> FilterPartIterator {
pub fn iter(&self) -> FilterPartIterator<'_> {
FilterPartIterator {
filter_part: self,
index: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/network_filter_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl NetworkFilterList {
})
}

pub fn get_filter_map(&self) -> FlatFilterMap<ShortHash, fb::NetworkFilter> {
pub fn get_filter_map(&self) -> FlatFilterMap<'_, ShortHash, fb::NetworkFilter<'_>> {
let filters_list = self.memory.filter_list();
FlatFilterMap::new(
fb_vector_to_slice(filters_list.filter_map_index()),
Expand Down
Loading