diff --git a/utils/tfhe-lints/Cargo.toml b/utils/tfhe-lints/Cargo.toml index 2e15349f9e..13d4f70a8a 100644 --- a/utils/tfhe-lints/Cargo.toml +++ b/utils/tfhe-lints/Cargo.toml @@ -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" diff --git a/utils/tfhe-lints/src/serialize_without_versionize.rs b/utils/tfhe-lints/src/serialize_without_versionize.rs index e90069c05e..423efee8e4 100644 --- a/utils/tfhe-lints/src/serialize_without_versionize.rs +++ b/utils/tfhe-lints/src/serialize_without_versionize.rs @@ -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 @@ -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) { diff --git a/utils/tfhe-lints/src/utils.rs b/utils/tfhe-lints/src/utils.rs index 644d916c4d..2c3f4c93b7 100644 --- a/utils/tfhe-lints/src/utils.rs +++ b/utils/tfhe-lints/src/utils.rs @@ -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; @@ -11,16 +12,19 @@ pub fn symbols_list_from_str(list: &[&str]) -> Vec { /// 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; + } + } } } }