Skip to content

Commit

Permalink
chore(ci): update tfhe-lints for newer compiler version
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarlin-zama committed Mar 5, 2025
1 parent ba5fae8 commit 5172951
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions utils/tfhe-lints/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ crate-type = ["cdylib"]

[dependencies]
clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "238edf273d195c8e472851ebd60571f77f978ac8" }
dylint_linting = "3.2.1"
dylint_linting = "4.0.0"

[dev-dependencies]
dylint_testing = "3.2.1"
dylint_testing = "4.0.0"
serde = { version = "1.0", features = ["derive"] }
tfhe-versionable = "0.4.0"

Expand Down
7 changes: 4 additions & 3 deletions utils/tfhe-lints/src/serialize_without_versionize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ impl SerializeWithoutVersionizeInner {
self.versionize_trait
.get_or_init(|| {
let versionize_trait = cx.tcx.all_traits().find(|def_id| {
cx.match_def_path(*def_id, symbols_list_from_str(&VERSIONIZE_TRAIT).as_slice())
let path = cx.get_def_path(*def_id);
path == symbols_list_from_str(&VERSIONIZE_TRAIT)
});

versionize_trait
Expand Down Expand Up @@ -85,8 +86,8 @@ impl<'tcx> LateLintPass<'tcx> for SerializeWithoutVersionize {

// Check if the implemented trait is `Serialize`
if let Some(def_id) = trait_ref.trait_def_id() {
if cx.match_def_path(def_id, symbols_list_from_str(&SERIALIZE_TRAIT).as_slice())
{
let path = cx.get_def_path(def_id);
if path == symbols_list_from_str(&SERIALIZE_TRAIT) {
// Try to find an implementation of versionize for this type
let mut found_impl = false;
if let Some(versionize_trait) = self.0.versionize_trait(cx) {
Expand Down
16 changes: 10 additions & 6 deletions utils/tfhe-lints/src/utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use rustc_ast::tokenstream::TokenTree;
use rustc_hir::def_id::DefId;
use rustc_hir::AttrArgs;
use rustc_lint::LateContext;
use rustc_middle::ty::{Ty, TyKind};
use rustc_span::Symbol;
Expand All @@ -11,16 +12,19 @@ pub fn symbols_list_from_str(list: &[&str]) -> Vec<Symbol> {

/// Checks if the lint is allowed for the item represented by [`DefId`].
/// This shouldn't be necessary since the lints are declared with the
/// `declare_tool_lint` macro but for a mysterious reason this does not
/// `impl_late_lint` macro but for a mysterious reason this does not
/// work automatically.
pub fn is_allowed_lint(cx: &LateContext<'_>, target: DefId, lint_name: &str) -> bool {
for attr in cx.tcx.get_attrs(target, Symbol::intern("allow")) {
let tokens = attr.get_normal_item().args.inner_tokens();
let mut trees = tokens.trees();
if let AttrArgs::Delimited(args) = &attr.get_normal_item().args {
let len = args.tokens.len();

if let Some(TokenTree::Token(tool_token, _)) = trees.next() {
if tool_token.is_ident_named(Symbol::intern(lint_name)) {
return true;
for id in 0..len {
if let Some(TokenTree::Token(tool_token, _)) = args.tokens.get(id) {
if tool_token.is_ident_named(Symbol::intern(lint_name)) {
return true;
}
}
}
}
}
Expand Down

0 comments on commit 5172951

Please sign in to comment.