mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-03 07:04:53 +00:00
Use #[expect(lint)]
over #[allow(lint)]
where possible (#17822)
This commit is contained in:
parent
8535af8516
commit
fa628018b2
148 changed files with 221 additions and 268 deletions
|
@ -519,7 +519,7 @@ impl TextWidth {
|
|||
let char_width = match c {
|
||||
'\t' => indent_width.value(),
|
||||
'\n' => return TextWidth::Multiline,
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
c => c.width().unwrap_or(0) as u32,
|
||||
};
|
||||
width += char_width;
|
||||
|
|
|
@ -280,7 +280,7 @@ impl Format<IrFormatContext<'_>> for &[FormatElement] {
|
|||
| FormatElement::SourceCodeSlice { .. }) => {
|
||||
fn write_escaped(element: &FormatElement, f: &mut Formatter<IrFormatContext>) {
|
||||
let (text, text_width) = match element {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
FormatElement::Token { text } => {
|
||||
(*text, TextWidth::Width(Width::new(text.len() as u32)))
|
||||
}
|
||||
|
|
|
@ -379,7 +379,7 @@ impl PartialEq for LabelId {
|
|||
}
|
||||
|
||||
impl LabelId {
|
||||
#[allow(clippy::needless_pass_by_value)]
|
||||
#[expect(clippy::needless_pass_by_value)]
|
||||
pub fn of<T: LabelDefinition>(label: T) -> Self {
|
||||
Self {
|
||||
value: label.value(),
|
||||
|
|
|
@ -925,7 +925,7 @@ pub struct FormatState<Context> {
|
|||
group_id_builder: UniqueGroupIdBuilder,
|
||||
}
|
||||
|
||||
#[allow(clippy::missing_fields_in_debug)]
|
||||
#[expect(clippy::missing_fields_in_debug)]
|
||||
impl<Context> std::fmt::Debug for FormatState<Context>
|
||||
where
|
||||
Context: std::fmt::Debug,
|
||||
|
|
|
@ -331,7 +331,7 @@ impl<'a> Printer<'a> {
|
|||
FormatElement::Tag(StartVerbatim(kind)) => {
|
||||
if let VerbatimKind::Verbatim { length } = kind {
|
||||
// SAFETY: Ruff only supports formatting files <= 4GB
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
self.state.verbatim_markers.push(TextRange::at(
|
||||
TextSize::from(self.state.buffer.len() as u32),
|
||||
*length,
|
||||
|
@ -464,7 +464,7 @@ impl<'a> Printer<'a> {
|
|||
self.push_marker();
|
||||
|
||||
match text {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
Text::Token(token) => {
|
||||
self.state.buffer.push_str(token);
|
||||
self.state.line_width += token.len() as u32;
|
||||
|
@ -831,7 +831,7 @@ impl<'a> Printer<'a> {
|
|||
} else {
|
||||
self.state.buffer.push(char);
|
||||
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
let char_width = if char == '\t' {
|
||||
self.options.indent_width.value()
|
||||
} else {
|
||||
|
@ -1480,7 +1480,7 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> {
|
|||
u32::from(indent.level()) * self.options().indent_width() + u32::from(indent.align());
|
||||
|
||||
match text {
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
Text::Token(token) => {
|
||||
self.state.line_width += token.len() as u32;
|
||||
}
|
||||
|
@ -1511,7 +1511,7 @@ impl<'a, 'print> FitsMeasurer<'a, 'print> {
|
|||
}
|
||||
}
|
||||
// SAFETY: A u32 is sufficient to format files <= 4GB
|
||||
#[allow(clippy::cast_possible_truncation)]
|
||||
#[expect(clippy::cast_possible_truncation)]
|
||||
c => c.width().unwrap_or(0) as u32,
|
||||
};
|
||||
self.state.line_width += char_width;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue