Misc. small tweaks from perusing modules (#9383)

This commit is contained in:
Charlie Marsh 2024-01-03 13:30:25 -04:00 committed by GitHub
parent 7b6baff734
commit 0e202718fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 5 deletions

View file

@ -68,6 +68,7 @@ impl Rule {
} }
} }
} }
impl Linter { impl Linter {
pub const fn upstream_categories(&self) -> Option<&'static [UpstreamCategoryAndPrefix]> { pub const fn upstream_categories(&self) -> Option<&'static [UpstreamCategoryAndPrefix]> {
match self { match self {

View file

@ -1,6 +1,7 @@
use bitflags::bitflags;
use crate::helpers::map_subscript; use crate::helpers::map_subscript;
use crate::{self as ast, Expr, Stmt}; use crate::{self as ast, Expr, Stmt};
use bitflags::bitflags;
bitflags! { bitflags! {
#[derive(Default, Debug, Copy, Clone, PartialEq, Eq)] #[derive(Default, Debug, Copy, Clone, PartialEq, Eq)]

View file

@ -1,7 +1,9 @@
use crate::{ElifElseClause, Expr, Stmt, StmtIf}; use std::iter;
use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer};
use ruff_text_size::{Ranged, TextRange}; use ruff_text_size::{Ranged, TextRange};
use std::iter;
use crate::{ElifElseClause, Expr, Stmt, StmtIf};
/// Return the `Range` of the first `Elif` or `Else` token in an `If` statement. /// Return the `Range` of the first `Elif` or `Else` token in an `If` statement.
pub fn elif_else_range(clause: &ElifElseClause, contents: &str) -> Option<TextRange> { pub fn elif_else_range(clause: &ElifElseClause, contents: &str) -> Option<TextRange> {
@ -17,11 +19,12 @@ pub enum BranchKind {
Elif, Elif,
} }
#[derive(Debug)]
pub struct IfElifBranch<'a> { pub struct IfElifBranch<'a> {
pub kind: BranchKind, pub kind: BranchKind,
pub test: &'a Expr, pub test: &'a Expr,
pub body: &'a [Stmt], pub body: &'a [Stmt],
pub range: TextRange, range: TextRange,
} }
impl Ranged for IfElifBranch<'_> { impl Ranged for IfElifBranch<'_> {

View file

@ -265,8 +265,8 @@ impl<'a> Deref for Definitions<'a> {
} }
impl<'a> IntoIterator for Definitions<'a> { impl<'a> IntoIterator for Definitions<'a> {
type IntoIter = std::vec::IntoIter<Self::Item>;
type Item = Definition<'a>; type Item = Definition<'a>;
type IntoIter = std::vec::IntoIter<Self::Item>;
fn into_iter(self) -> Self::IntoIter { fn into_iter(self) -> Self::IntoIter {
self.0.into_iter() self.0.into_iter()