@@ -6,7 +6,7 @@ use ruff_python_ast::{
6
6
} ;
7
7
use ruff_text_size:: TextRange ;
8
8
9
- use ruff_python_ast:: node:: { AnyNodeRef , AstNode } ;
9
+ use ruff_python_ast:: node:: AnyNodeRef ;
10
10
use ruff_python_ast:: whitespace:: indentation;
11
11
use ruff_python_trivia:: {
12
12
indentation_at_offset, PythonWhitespace , SimpleToken , SimpleTokenKind , SimpleTokenizer ,
@@ -420,7 +420,7 @@ fn handle_match_comment<'a>(
420
420
// ```
421
421
// Attach the `comment` as leading comment to the next case.
422
422
if comment_indentation <= match_case_indentation {
423
- CommentPlacement :: leading ( next_case. into ( ) , comment)
423
+ CommentPlacement :: leading ( next_case, comment)
424
424
} else {
425
425
// Otherwise, delegate to `handle_trailing_body_comment`
426
426
// ```python
@@ -450,7 +450,7 @@ fn handle_match_comment<'a>(
450
450
// # Trailing match comment
451
451
// ```
452
452
// This is a trailing comment of the last case.
453
- CommentPlacement :: trailing ( match_case. into ( ) , comment)
453
+ CommentPlacement :: trailing ( match_case, comment)
454
454
} else {
455
455
// Delegate to `handle_trailing_body_comment` because it's either a trailing indent
456
456
// for the last statement in the `case` body or a comment for the parent of the `match`
@@ -628,7 +628,7 @@ fn handle_trailing_binary_expression_left_or_operator_comment<'a>(
628
628
// 3
629
629
// )
630
630
// ```
631
- CommentPlacement :: trailing ( AnyNodeRef :: from ( binary_expression. left . as_ref ( ) ) , comment)
631
+ CommentPlacement :: trailing ( binary_expression. left . as_ref ( ) , comment)
632
632
} else if comment. line_position ( ) . is_end_of_line ( ) {
633
633
// Is the operator on its own line.
634
634
if locator. contains_line_break ( TextRange :: new (
@@ -645,7 +645,7 @@ fn handle_trailing_binary_expression_left_or_operator_comment<'a>(
645
645
// 3
646
646
// )
647
647
// ```
648
- CommentPlacement :: dangling ( binary_expression. into ( ) , comment)
648
+ CommentPlacement :: dangling ( binary_expression, comment)
649
649
} else {
650
650
// ```python
651
651
// a = (
@@ -806,14 +806,14 @@ fn handle_slice_comments<'a>(
806
806
807
807
if let Some ( node) = node {
808
808
if comment. slice ( ) . start ( ) < node. start ( ) {
809
- CommentPlacement :: leading ( node. as_ref ( ) . into ( ) , comment)
809
+ CommentPlacement :: leading ( node. as_ref ( ) , comment)
810
810
} else {
811
811
// If a trailing comment is an end of line comment that's fine because we have a node
812
812
// ahead of it
813
- CommentPlacement :: trailing ( node. as_ref ( ) . into ( ) , comment)
813
+ CommentPlacement :: trailing ( node. as_ref ( ) , comment)
814
814
}
815
815
} else {
816
- CommentPlacement :: dangling ( expr_slice. as_any_node_ref ( ) , comment)
816
+ CommentPlacement :: dangling ( expr_slice, comment)
817
817
}
818
818
}
819
819
@@ -955,7 +955,7 @@ fn handle_attribute_comment<'a>(
955
955
// ```
956
956
CommentPlacement :: trailing ( comment. enclosing_node ( ) , comment)
957
957
} else {
958
- CommentPlacement :: dangling ( attribute. into ( ) , comment)
958
+ CommentPlacement :: dangling ( attribute, comment)
959
959
}
960
960
}
961
961
@@ -997,7 +997,7 @@ fn handle_expr_if_comment<'a>(
997
997
) ;
998
998
// Between `if` and `test`
999
999
if if_token. range . start ( ) < comment. slice ( ) . start ( ) && comment. slice ( ) . start ( ) < test. start ( ) {
1000
- return CommentPlacement :: leading ( test. as_ref ( ) . into ( ) , comment) ;
1000
+ return CommentPlacement :: leading ( test. as_ref ( ) , comment) ;
1001
1001
}
1002
1002
1003
1003
let else_token = find_only_token_in_range (
@@ -1009,7 +1009,7 @@ fn handle_expr_if_comment<'a>(
1009
1009
if else_token. range . start ( ) < comment. slice ( ) . start ( )
1010
1010
&& comment. slice ( ) . start ( ) < orelse. start ( )
1011
1011
{
1012
- return CommentPlacement :: leading ( orelse. as_ref ( ) . into ( ) , comment) ;
1012
+ return CommentPlacement :: leading ( orelse. as_ref ( ) , comment) ;
1013
1013
}
1014
1014
1015
1015
CommentPlacement :: Default ( comment)
@@ -1043,7 +1043,7 @@ fn handle_trailing_expression_starred_star_end_of_line_comment<'a>(
1043
1043
return CommentPlacement :: Default ( comment) ;
1044
1044
}
1045
1045
1046
- CommentPlacement :: leading ( starred. as_any_node_ref ( ) , comment)
1046
+ CommentPlacement :: leading ( starred, comment)
1047
1047
}
1048
1048
1049
1049
/// Handles trailing own line comments before the `as` keyword of a with item and
@@ -1188,7 +1188,7 @@ fn handle_comprehension_comment<'a>(
1188
1188
CommentPlacement :: Default ( comment)
1189
1189
} else {
1190
1190
// after the `in` but same line, turn into trailing on the `in` token
1191
- CommentPlacement :: dangling ( ( & comprehension. iter ) . into ( ) , comment)
1191
+ CommentPlacement :: dangling ( & comprehension. iter , comment)
1192
1192
} ;
1193
1193
}
1194
1194
@@ -1219,12 +1219,12 @@ fn handle_comprehension_comment<'a>(
1219
1219
) ;
1220
1220
if is_own_line {
1221
1221
if last_end < comment. slice ( ) . start ( ) && comment. slice ( ) . start ( ) < if_token. start ( ) {
1222
- return CommentPlacement :: dangling ( ( if_node) . into ( ) , comment) ;
1222
+ return CommentPlacement :: dangling ( if_node, comment) ;
1223
1223
}
1224
1224
} else if if_token. start ( ) < comment. slice ( ) . start ( )
1225
1225
&& comment. slice ( ) . start ( ) < if_node. range ( ) . start ( )
1226
1226
{
1227
- return CommentPlacement :: dangling ( ( if_node) . into ( ) , comment) ;
1227
+ return CommentPlacement :: dangling ( if_node, comment) ;
1228
1228
}
1229
1229
last_end = if_node. range ( ) . end ( ) ;
1230
1230
}
0 commit comments