Switch to Rust 2024 edition (#18129)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
use std::borrow::Cow;
|
||||
|
||||
use ruff_formatter::{format_args, write, FormatError, FormatOptions, SourceCode};
|
||||
use ruff_formatter::{FormatError, FormatOptions, SourceCode, format_args, write};
|
||||
use ruff_python_ast::{AnyNodeRef, NodeKind, PySourceType};
|
||||
use ruff_python_trivia::{
|
||||
is_pragma_comment, lines_after, lines_after_ignoring_trivia, lines_before, CommentLinePosition,
|
||||
CommentLinePosition, is_pragma_comment, lines_after, lines_after_ignoring_trivia, lines_before,
|
||||
};
|
||||
use ruff_text_size::{Ranged, TextLen, TextRange};
|
||||
|
||||
@@ -381,14 +381,13 @@ impl Format<PyFormatContext<'_>> for FormatTrailingEndOfLineComment<'_> {
|
||||
0
|
||||
} else {
|
||||
// Start with 2 because of the two leading spaces.
|
||||
let width = 2u32.saturating_add(
|
||||
|
||||
2u32.saturating_add(
|
||||
TextWidth::from_text(&normalized_comment, f.options().indent_width())
|
||||
.width()
|
||||
.expect("Expected comment not to contain any newlines")
|
||||
.value(),
|
||||
);
|
||||
|
||||
width
|
||||
)
|
||||
};
|
||||
|
||||
write!(
|
||||
|
||||
@@ -514,7 +514,7 @@ mod tests {
|
||||
|
||||
use ruff_formatter::SourceCode;
|
||||
use ruff_python_ast::{Mod, PySourceType};
|
||||
use ruff_python_parser::{parse, ParseOptions, Parsed};
|
||||
use ruff_python_parser::{ParseOptions, Parsed, parse};
|
||||
use ruff_python_trivia::CommentRanges;
|
||||
|
||||
use crate::comments::Comments;
|
||||
|
||||
@@ -4,15 +4,15 @@ use ruff_python_ast::{
|
||||
self as ast, AnyNodeRef, Comprehension, Expr, ModModule, Parameter, Parameters, StringLike,
|
||||
};
|
||||
use ruff_python_trivia::{
|
||||
find_only_token_in_range, first_non_trivia_token, indentation_at_offset, BackwardsTokenizer,
|
||||
CommentRanges, SimpleToken, SimpleTokenKind, SimpleTokenizer,
|
||||
BackwardsTokenizer, CommentRanges, SimpleToken, SimpleTokenKind, SimpleTokenizer,
|
||||
find_only_token_in_range, first_non_trivia_token, indentation_at_offset,
|
||||
};
|
||||
use ruff_source_file::LineRanges;
|
||||
use ruff_text_size::{Ranged, TextLen, TextRange};
|
||||
use std::cmp::Ordering;
|
||||
|
||||
use crate::comments::visitor::{CommentPlacement, DecoratedComment};
|
||||
use crate::expression::expr_slice::{assign_comment_in_slice, ExprSliceCommentSection};
|
||||
use crate::expression::expr_slice::{ExprSliceCommentSection, assign_comment_in_slice};
|
||||
use crate::expression::parentheses::is_expression_parenthesized;
|
||||
use crate::other::parameters::{
|
||||
assign_argument_separator_comment_placement, find_parameter_separators,
|
||||
@@ -2256,7 +2256,9 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
max_empty_lines("# trailing comment\n\n# own line comment\n\n\n# an other own line comment\n# block"),
|
||||
max_empty_lines(
|
||||
"# trailing comment\n\n# own line comment\n\n\n# an other own line comment\n# block"
|
||||
),
|
||||
2
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user