tangled
alpha
login
or
join now
oppi.li
/
statix
0
fork
atom
Lints and suggestions for the Nix programming language
0
fork
atom
overview
issues
pulls
pipelines
refactor(legacy_let_syntax): inline fn key_is_ident
mightyiam.tngl.sh
6 months ago
00a00ac5
45de97da
+7
-14
1 changed file
expand all
collapse all
unified
split
lib
src
lints
legacy_let_syntax.rs
+7
-14
lib/src/lints/legacy_let_syntax.rs
···
3
3
use macros::lint;
4
4
use rnix::{
5
5
NodeOrToken, SyntaxElement, SyntaxKind,
6
6
-
types::{EntryHolder, Ident, Key, LegacyLet, TokenWrapper, TypedNode},
6
6
+
types::{EntryHolder, Ident, LegacyLet, TokenWrapper, TypedNode},
7
7
};
8
8
9
9
/// ## What it does
···
52
52
53
53
if !legacy_let
54
54
.entries()
55
55
-
.any(|kv| matches!(kv.key(), Some(k) if key_is_ident(&k, "body")))
55
55
+
.filter_map(|kv| {
56
56
+
let key = kv.key()?;
57
57
+
let first_component = key.path().next()?;
58
58
+
Ident::cast(first_component)
59
59
+
})
60
60
+
.any(|ident| ident.as_str() == "body")
56
61
{
57
62
return None;
58
63
}
···
73
78
)
74
79
}
75
80
}
76
76
-
77
77
-
fn key_is_ident(key_path: &Key, ident: &str) -> bool {
78
78
-
let Some(key_node) = key_path.path().next() else {
79
79
-
return false;
80
80
-
};
81
81
-
82
82
-
let Some(key) = Ident::cast(key_node) else {
83
83
-
return false;
84
84
-
};
85
85
-
86
86
-
key.as_str() == ident
87
87
-
}