···3838 if let Some(unary_expr) = UnaryOp::cast(node.clone());
3939 if unary_expr.operator() == UnaryOpKind::Invert;
4040 if let Some(value_expr) = unary_expr.value();
4141- if let Some(paren_expr) = Paren::cast(value_expr.clone());
4141+ if let Some(paren_expr) = Paren::cast(value_expr);
4242 if let Some(inner_expr) = paren_expr.inner();
4343 if let Some(bin_expr) = BinOp::cast(inner_expr);
4444 if let Some(BinOpKind::Equal) = bin_expr.operator();
+2-3
lib/src/lints/empty_pattern.rs
···4848 if let Some(arg) = lambda_expr.arg();
4949 if let Some(body) = lambda_expr.body();
50505151- if let Some(pattern) = Pattern::cast(arg.clone());
5151+ if let Some(pattern) = Pattern::cast(arg);
52525353 // no patterns within `{ }`
5454 if pattern.entries().count() == 0;
···7575 if let Some(attr_set) = AttrSet::cast(body.clone());
7676 if attr_set
7777 .entries()
7878- .map(|e| e.key())
7979- .flatten()
7878+ .filter_map(|e| e.key())
8079 .any(|k| k.node().to_string() == "imports");
8180 then {
8281 true
+2-2
lib/src/lints/faster_groupby.rs
···50505151 // a heuristic to lint on nixpkgs.lib.groupBy
5252 // and lib.groupBy and its variants
5353- if select_from.text().to_string() != "builtins";
5454- if group_by_attr.text().to_string() == "groupBy";
5353+ if select_from.text() != "builtins";
5454+ if group_by_attr.text() == "groupBy";
55555656 then {
5757 let at = node.text_range();
+2-2
lib/src/lints/faster_zipattrswith.rs
···50505151 // a heuristic to lint on nixpkgs.lib.zipAttrsWith
5252 // and lib.zipAttrsWith and its variants
5353- if select_from.text().to_string() != "builtins";
5454- if zip_attrs_with.text().to_string() == "zipAttrsWith";
5353+ if select_from.text() != "builtins";
5454+ if zip_attrs_with.text() == "zipAttrsWith";
55555656 then {
5757 let at = node.text_range();
+3-3
lib/src/lints/repeated_keys.rs
···5555 if components.next().is_some();
56565757 if let Some(parent_node) = node.parent();
5858- if let Some(parent_attr_set) = AttrSet::cast(parent_node.clone());
5858+ if let Some(parent_attr_set) = AttrSet::cast(parent_node);
59596060 if !parent_attr_set.recursive();
6161 let occurrences = parent_attr_set.entries().filter_map(|kv_scrutinee| {
···9292 let third_message = {
9393 let remaining_occurrences = iter.count();
9494 let mut message = match remaining_occurrences {
9595- 0 => format!("... and here."),
9696- 1 => format!("... and here (`1` occurrence omitted)."),
9595+ 0 => "... and here.".to_string(),
9696+ 1 => "... and here (`1` occurrence omitted).".to_string(),
9797 n => format!("... and here (`{}` occurrences omitted).", n),
9898 };
9999 message.push_str(&format!(" Try `{} = {{ {}=...; {}=...; {}=...; }}` instead.", first_component_ident.as_str(), first_subkey, second_subkey, third_subkey));
+2-2
lib/src/lints/useless_has_attr.rs
···3939 if let Some(if_else_expr) = IfElse::cast(node.clone());
4040 if let Some(condition_expr) = if_else_expr.condition();
4141 if let Some(default_expr) = if_else_expr.else_body();
4242- if let Some(cond_bin_expr) = BinOp::cast(condition_expr.clone());
4242+ if let Some(cond_bin_expr) = BinOp::cast(condition_expr);
4343 if let Some(BinOpKind::IsSet) = cond_bin_expr.operator();
44444545 // set ? attr_path
···50505151 // check if body of the `if` expression is of the form `set.attr_path`
5252 if let Some(body_expr) = if_else_expr.body();
5353- if let Some(body_select_expr) = Select::cast(body_expr.clone());
5353+ if let Some(body_select_expr) = Select::cast(body_expr);
5454 let expected_body = make::select(&set, &attr_path);
55555656 // text comparison will do for now
+3-3
lib/src/make.rs
···7788fn ast_from_text<N: TypedNode>(text: &str) -> N {
99 let parse = rnix::parse(text);
1010- let node = match parse.node().descendants().find_map(N::cast) {
1010+1111+ match parse.node().descendants().find_map(N::cast) {
1112 Some(it) => it,
1213 None => {
1314 panic!(
···1617 text
1718 )
1819 }
1919- };
2020- node
2020+ }
2121}
22222323pub fn parenthesize(node: &SyntaxNode) -> types::Paren {
+2-2
lib/src/session.rs
···22222323fn parse_number(s: &str) -> Option<u16> {
2424 s.chars()
2525- .take_while(|c| c.is_digit(10))
2525+ .take_while(|c| c.is_ascii_digit())
2626 .collect::<String>()
2727 .parse::<u16>()
2828 .ok()
···3232 let mut parts = s.split('.');
3333 let major = parse_number(parts.next()?)?;
3434 let minor = parse_number(parts.next()?)?;
3535- let patch = parts.next().map(|p| parse_number(p)).flatten();
3535+ let patch = parts.next().and_then(parse_number);
3636 Some(Version {
3737 major,
3838 minor,