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"]
1010
1111[dependencies ]
1212clippy_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 "
1717serde = { version = " 1.0" , features = [" derive" ] }
1818tfhe-versionable = " 0.4.0"
1919
Original file line number Diff line number Diff 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) {
Original file line number Diff line number Diff line change 11use rustc_ast:: tokenstream:: TokenTree ;
22use rustc_hir:: def_id:: DefId ;
3+ use rustc_hir:: AttrArgs ;
34use rustc_lint:: LateContext ;
45use rustc_middle:: ty:: { Ty , TyKind } ;
56use 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.
1617pub 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 }
You can’t perform that action at this time.
0 commit comments