From fadc1b6e353f8a65082d486e128c8dbf6d9bc43c Mon Sep 17 00:00:00 2001 From: Arthur Meyre Date: Mon, 3 Mar 2025 16:59:43 +0100 Subject: [PATCH 1/2] chore(ci): force installation of toolchain for tfhe-lints --- Makefile | 2 ++ toolchain.txt | 2 +- utils/tfhe-lints/Cargo.toml | 6 +++--- utils/tfhe-lints/rust-toolchain | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 00e92b4415..1cb4862076 100644 --- a/Makefile +++ b/Makefile @@ -431,6 +431,7 @@ clippy_versionable: install_rs_check_toolchain .PHONY: clippy_tfhe_lints # Run clippy lints on tfhe-lints clippy_tfhe_lints: install_cargo_dylint # the toolchain is selected with toolchain.toml cd utils/tfhe-lints && \ + rustup toolchain install && \ cargo clippy --all-targets -- --no-deps -D warnings .PHONY: clippy_all # Run all clippy targets @@ -907,6 +908,7 @@ test_versionable: install_rs_build_toolchain .PHONY: test_tfhe_lints # Run test on tfhe-lints test_tfhe_lints: install_cargo_dylint cd utils/tfhe-lints && \ + rustup toolchain install && \ cargo test # The backward compat data repo holds historical binary data but also rust code to generate and load them. diff --git a/toolchain.txt b/toolchain.txt index 5e36f78b5b..abba71dcb6 100644 --- a/toolchain.txt +++ b/toolchain.txt @@ -1 +1 @@ -nightly-2025-02-19 +nightly-2025-02-20 diff --git a/utils/tfhe-lints/Cargo.toml b/utils/tfhe-lints/Cargo.toml index fbf2d17602..2e15349f9e 100644 --- a/utils/tfhe-lints/Cargo.toml +++ b/utils/tfhe-lints/Cargo.toml @@ -9,7 +9,7 @@ publish = false crate-type = ["cdylib"] [dependencies] -clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "ff4a26d442bead94a4c96fb1de967374bc4fbd8e" } +clippy_utils = { git = "https://github.com/rust-lang/rust-clippy", rev = "238edf273d195c8e472851ebd60571f77f978ac8" } dylint_linting = "3.2.1" [dev-dependencies] @@ -21,5 +21,5 @@ tfhe-versionable = "0.4.0" rustc_private = true [[example]] -name = "ui" -path = "ui/main.rs" +name = "ui" +path = "ui/main.rs" diff --git a/utils/tfhe-lints/rust-toolchain b/utils/tfhe-lints/rust-toolchain index e5dee9dafd..33813026b3 100644 --- a/utils/tfhe-lints/rust-toolchain +++ b/utils/tfhe-lints/rust-toolchain @@ -1,3 +1,4 @@ [toolchain] -channel = "nightly-2024-11-28" +channel = "nightly-2025-02-20" components = ["llvm-tools-preview", "rustc-dev"] +profile = "default" From 160cc5fded11b2c709692ea777caea45f0e4b9e4 Mon Sep 17 00:00:00 2001 From: Nicolas Sarlin Date: Tue, 4 Mar 2025 11:37:18 +0100 Subject: [PATCH 2/2] chore(ci): update tfhe-lints for newer compiler version --- utils/tfhe-lints/Cargo.toml | 4 ++-- .../src/serialize_without_versionize.rs | 7 ++++--- utils/tfhe-lints/src/utils.rs | 16 ++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) 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; + } + } } } }