Upgrade to Rust 1.78 (#11260)

This commit is contained in:
Micha Reiser 2024-05-03 14:46:21 +02:00 committed by GitHub
parent 349a4cf8ce
commit 6a1e555537
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
69 changed files with 67 additions and 549 deletions

View file

@ -4,7 +4,7 @@ use ruff_python_ast::{Expr, ExprAttribute, ExprNumberLiteral, Number};
use ruff_python_trivia::{find_only_token_in_range, SimpleTokenKind};
use ruff_text_size::{Ranged, TextRange};
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
};
@ -123,15 +123,6 @@ impl FormatNodeRule<ExprAttribute> for FormatExprAttribute {
write!(f, [format_inner])
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// handle in `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprAttribute {

View file

@ -1,7 +1,6 @@
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprBinOp;
use crate::comments::SourceComment;
use crate::expression::binary_like::BinaryLike;
use crate::expression::has_parentheses;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
@ -16,15 +15,6 @@ impl FormatNodeRule<ExprBinOp> for FormatExprBinOp {
fn fmt_fields(&self, item: &ExprBinOp, f: &mut PyFormatter) -> FormatResult<()> {
BinaryLike::Binary(item).fmt(f)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled inside of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprBinOp {

View file

@ -1,7 +1,6 @@
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprBytesLiteral;
use crate::comments::SourceComment;
use crate::expression::parentheses::{
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
};
@ -21,15 +20,6 @@ impl FormatNodeRule<ExprBytesLiteral> for FormatExprBytesLiteral {
.fmt(f),
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprBytesLiteral {

View file

@ -2,7 +2,7 @@ use ruff_formatter::FormatRuleWithOptions;
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::{Expr, ExprCall};
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
};
@ -74,14 +74,6 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
fmt_func.fmt(f)
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
Ok(())
}
}
impl NeedsParentheses for ExprCall {

View file

@ -2,7 +2,6 @@ use ruff_formatter::{FormatOwnedWithRule, FormatRefWithRule};
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::{CmpOp, ExprCompare};
use crate::comments::SourceComment;
use crate::expression::binary_like::BinaryLike;
use crate::expression::has_parentheses;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
@ -17,16 +16,6 @@ impl FormatNodeRule<ExprCompare> for FormatExprCompare {
fn fmt_fields(&self, item: &ExprCompare, f: &mut PyFormatter) -> FormatResult<()> {
BinaryLike::Compare(item).fmt(f)
}
fn fmt_dangling_comments(
&self,
dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Node can not have dangling comments
debug_assert!(dangling_comments.is_empty());
Ok(())
}
}
impl NeedsParentheses for ExprCompare {

View file

@ -64,15 +64,6 @@ impl FormatNodeRule<ExprDict> for FormatExprDict {
.with_dangling_comments(open_parenthesis_comments)
.fmt(f)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled by `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprDict {

View file

@ -3,7 +3,7 @@ use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprDictComp;
use ruff_text_size::Ranged;
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -58,15 +58,6 @@ impl FormatNodeRule<ExprDictComp> for FormatExprDictComp {
.with_dangling_comments(open_parenthesis_comments)]
)
}
fn fmt_dangling_comments(
&self,
_dangling_node_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprDictComp {

View file

@ -2,7 +2,6 @@ use ruff_python_ast::{AnyNodeRef, ExprFString};
use ruff_source_file::Locator;
use ruff_text_size::Ranged;
use crate::comments::SourceComment;
use crate::expression::parentheses::{
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
};
@ -29,15 +28,6 @@ impl FormatNodeRule<ExprFString> for FormatExprFString {
}
}
}
fn fmt_dangling_comments(
&self,
_dangling_node_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprFString {

View file

@ -2,7 +2,6 @@ use ruff_formatter::{format_args, write, FormatRuleWithOptions};
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprGenerator;
use crate::comments::SourceComment;
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -76,15 +75,6 @@ impl FormatNodeRule<ExprGenerator> for FormatExprGenerator {
)
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprGenerator {

View file

@ -3,7 +3,7 @@ use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprLambda;
use ruff_text_size::Ranged;
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
use crate::other::parameters::ParametersParentheses;
use crate::prelude::*;
@ -63,15 +63,6 @@ impl FormatNodeRule<ExprLambda> for FormatExprLambda {
write!(f, [body.format()])
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Override. Dangling comments are handled in `fmt_fields`.
Ok(())
}
}
impl NeedsParentheses for ExprLambda {

View file

@ -3,7 +3,6 @@ use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprList;
use ruff_text_size::Ranged;
use crate::comments::SourceComment;
use crate::expression::parentheses::{
empty_parenthesized, parenthesized, NeedsParentheses, OptionalParentheses,
};
@ -37,15 +36,6 @@ impl FormatNodeRule<ExprList> for FormatExprList {
.with_dangling_comments(dangling)
.fmt(f)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprList {

View file

@ -2,8 +2,6 @@ use ruff_formatter::{format_args, write, FormatResult};
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprListComp;
use crate::comments::SourceComment;
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -41,15 +39,6 @@ impl FormatNodeRule<ExprListComp> for FormatExprListComp {
.with_dangling_comments(dangling)]
)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprListComp {

View file

@ -2,7 +2,6 @@ use ruff_formatter::write;
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprName;
use crate::comments::SourceComment;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -18,16 +17,6 @@ impl FormatNodeRule<ExprName> for FormatExprName {
} = item;
write!(f, [source_text_slice(*range)])
}
fn fmt_dangling_comments(
&self,
dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Node cannot have dangling comments
debug_assert!(dangling_comments.is_empty());
Ok(())
}
}
impl NeedsParentheses for ExprName {

View file

@ -2,7 +2,7 @@ use ruff_formatter::{format_args, write};
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprNamed;
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{
in_parentheses_only_soft_line_break_or_space, NeedsParentheses, OptionalParentheses,
};
@ -42,15 +42,6 @@ impl FormatNodeRule<ExprNamed> for FormatExprNamed {
write!(f, [value.format()])
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled by `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprNamed {

View file

@ -2,7 +2,6 @@ use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprSet;
use ruff_text_size::Ranged;
use crate::comments::SourceComment;
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -28,15 +27,6 @@ impl FormatNodeRule<ExprSet> for FormatExprSet {
.with_dangling_comments(dangling)
.fmt(f)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprSet {

View file

@ -2,8 +2,6 @@ use ruff_formatter::{format_args, write, Buffer, FormatResult};
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprSetComp;
use crate::comments::SourceComment;
use crate::expression::parentheses::{parenthesized, NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -41,15 +39,6 @@ impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
.with_dangling_comments(dangling)]
)
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprSetComp {

View file

@ -146,15 +146,6 @@ impl FormatNodeRule<ExprSlice> for FormatExprSlice {
}
Ok(())
}
fn fmt_dangling_comments(
&self,
_dangling_node_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled as part of `fmt_fields`
Ok(())
}
}
/// We're in a slice, so we know there's a first colon, but with have to look into the source

View file

@ -2,7 +2,7 @@ use ruff_formatter::write;
use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprStarred;
use crate::comments::{dangling_comments, SourceComment};
use crate::comments::dangling_comments;
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
use crate::prelude::*;
@ -23,14 +23,6 @@ impl FormatNodeRule<ExprStarred> for FormatExprStarred {
write!(f, [token("*"), dangling_comments(dangling), value.format()])
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
Ok(())
}
}
impl NeedsParentheses for ExprStarred {

View file

@ -1,7 +1,6 @@
use ruff_formatter::FormatRuleWithOptions;
use ruff_python_ast::{AnyNodeRef, ExprStringLiteral};
use crate::comments::SourceComment;
use crate::expression::parentheses::{
in_parentheses_only_group, NeedsParentheses, OptionalParentheses,
};
@ -61,14 +60,6 @@ impl FormatNodeRule<ExprStringLiteral> for FormatExprStringLiteral {
.fmt(f),
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
Ok(())
}
}
impl NeedsParentheses for ExprStringLiteral {

View file

@ -2,7 +2,6 @@ use ruff_formatter::{write, FormatRuleWithOptions};
use ruff_python_ast::{AnyNodeRef, AstNode};
use ruff_python_ast::{Expr, ExprSubscript};
use crate::comments::SourceComment;
use crate::expression::expr_tuple::TupleParentheses;
use crate::expression::parentheses::{
is_expression_parenthesized, parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
@ -79,15 +78,6 @@ impl FormatNodeRule<ExprSubscript> for FormatExprSubscript {
write!(f, [format_inner])
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled inside of `fmt_fields`
Ok(())
}
}
impl NeedsParentheses for ExprSubscript {

View file

@ -4,7 +4,6 @@ use ruff_python_ast::ExprTuple;
use ruff_text_size::{Ranged, TextRange};
use crate::builders::parenthesize_if_expands;
use crate::comments::SourceComment;
use crate::expression::parentheses::{
empty_parenthesized, optional_parentheses, parenthesized, NeedsParentheses, OptionalParentheses,
};
@ -203,15 +202,6 @@ impl FormatNodeRule<ExprTuple> for FormatExprTuple {
},
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
// Handled in `fmt_fields`
Ok(())
}
}
#[derive(Debug)]

View file

@ -2,7 +2,7 @@ use ruff_python_ast::AnyNodeRef;
use ruff_python_ast::ExprUnaryOp;
use ruff_python_ast::UnaryOp;
use crate::comments::{trailing_comments, SourceComment};
use crate::comments::trailing_comments;
use crate::expression::parentheses::{
is_expression_parenthesized, NeedsParentheses, OptionalParentheses, Parentheses,
};
@ -66,14 +66,6 @@ impl FormatNodeRule<ExprUnaryOp> for FormatExprUnaryOp {
operand.format().fmt(f)
}
}
fn fmt_dangling_comments(
&self,
_dangling_comments: &[SourceComment],
_f: &mut PyFormatter,
) -> FormatResult<()> {
Ok(())
}
}
impl NeedsParentheses for ExprUnaryOp {