File tree Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Expand file tree Collapse file tree 3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ crate-type = ["cdylib"]
10
10
11
11
[dependencies ]
12
12
clippy_utils = { git = " https://github.com/rust-lang/rust-clippy" , rev = " 238edf273d195c8e472851ebd60571f77f978ac8" }
13
- dylint_linting = " 3.2.1 "
13
+ dylint_linting = " 4.0.0 "
14
14
15
15
[dev-dependencies ]
16
- dylint_testing = " 3.2.1 "
16
+ dylint_testing = " 4.0.0 "
17
17
serde = { version = " 1.0" , features = [" derive" ] }
18
18
tfhe-versionable = " 0.4.0"
19
19
Original file line number Diff line number Diff line change @@ -23,7 +23,8 @@ impl SerializeWithoutVersionizeInner {
23
23
self . versionize_trait
24
24
. get_or_init ( || {
25
25
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 )
27
28
} ) ;
28
29
29
30
versionize_trait
@@ -85,8 +86,8 @@ impl<'tcx> LateLintPass<'tcx> for SerializeWithoutVersionize {
85
86
86
87
// Check if the implemented trait is `Serialize`
87
88
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 ) {
90
91
// Try to find an implementation of versionize for this type
91
92
let mut found_impl = false ;
92
93
if let Some ( versionize_trait) = self . 0 . versionize_trait ( cx) {
Original file line number Diff line number Diff line change 1
1
use rustc_ast:: tokenstream:: TokenTree ;
2
2
use rustc_hir:: def_id:: DefId ;
3
+ use rustc_hir:: AttrArgs ;
3
4
use rustc_lint:: LateContext ;
4
5
use rustc_middle:: ty:: { Ty , TyKind } ;
5
6
use rustc_span:: Symbol ;
@@ -11,16 +12,19 @@ pub fn symbols_list_from_str(list: &[&str]) -> Vec<Symbol> {
11
12
12
13
/// Checks if the lint is allowed for the item represented by [`DefId`].
13
14
/// 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
15
16
/// work automatically.
16
17
pub fn is_allowed_lint ( cx : & LateContext < ' _ > , target : DefId , lint_name : & str ) -> bool {
17
18
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 ( ) ;
20
21
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
+ }
24
28
}
25
29
}
26
30
}
You can’t perform that action at this time.
0 commit comments