Skip to content

Commit f60be3e

Browse files
committed
chore(ci): update tfhe-lints for newer compiler version
1 parent d402bc8 commit f60be3e

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

utils/tfhe-lints/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ crate-type = ["cdylib"]
1010

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

1515
[dev-dependencies]
16-
dylint_testing = "3.2.1"
16+
dylint_testing = "4.0.0"
1717
serde = { version = "1.0", features = ["derive"] }
1818
tfhe-versionable = "0.4.0"
1919

utils/tfhe-lints/src/serialize_without_versionize.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ impl SerializeWithoutVersionizeInner {
2323
self.versionize_trait
2424
.get_or_init(|| {
2525
let versionize_trait = cx.tcx.all_traits().find(|def_id| {
26-
cx.match_def_path(*def_id, symbols_list_from_str(&VERSIONIZE_TRAIT).as_slice())
26+
let path = cx.get_def_path(*def_id);
27+
path == symbols_list_from_str(&VERSIONIZE_TRAIT)
2728
});
2829

2930
versionize_trait
@@ -85,8 +86,8 @@ impl<'tcx> LateLintPass<'tcx> for SerializeWithoutVersionize {
8586

8687
// Check if the implemented trait is `Serialize`
8788
if let Some(def_id) = trait_ref.trait_def_id() {
88-
if cx.match_def_path(def_id, symbols_list_from_str(&SERIALIZE_TRAIT).as_slice())
89-
{
89+
let path = cx.get_def_path(def_id);
90+
if path == symbols_list_from_str(&SERIALIZE_TRAIT) {
9091
// Try to find an implementation of versionize for this type
9192
let mut found_impl = false;
9293
if let Some(versionize_trait) = self.0.versionize_trait(cx) {

utils/tfhe-lints/src/utils.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use rustc_ast::tokenstream::TokenTree;
22
use rustc_hir::def_id::DefId;
3+
use rustc_hir::AttrArgs;
34
use rustc_lint::LateContext;
45
use rustc_middle::ty::{Ty, TyKind};
56
use rustc_span::Symbol;
@@ -11,16 +12,19 @@ pub fn symbols_list_from_str(list: &[&str]) -> Vec<Symbol> {
1112

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

21-
if let Some(TokenTree::Token(tool_token, _)) = trees.next() {
22-
if tool_token.is_ident_named(Symbol::intern(lint_name)) {
23-
return true;
22+
for id in 0..len {
23+
if let Some(TokenTree::Token(tool_token, _)) = args.tokens.get(id) {
24+
if tool_token.is_ident_named(Symbol::intern(lint_name)) {
25+
return true;
26+
}
27+
}
2428
}
2529
}
2630
}

0 commit comments

Comments
 (0)