Use #[expect(lint)] over #[allow(lint)] where possible (#17822)

This commit is contained in:
Micha Reiser 2025-05-03 21:20:31 +02:00 committed by GitHub
parent 8535af8516
commit fa628018b2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
148 changed files with 221 additions and 268 deletions

View file

@ -1459,7 +1459,7 @@ impl<'src> Lexer<'src> {
/// Retrieves the current offset of the cursor within the source code.
// SAFETY: Lexer doesn't allow files larger than 4GB
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
#[inline]
fn offset(&self) -> TextSize {
TextSize::new(self.source.len() as u32) - self.cursor.text_len()

View file

@ -62,7 +62,7 @@ impl<'src> Cursor<'src> {
///
/// Use [`Cursor::rest`] to get the remaining text.
// SAFETY: The `source.text_len` call in `new` would panic if the string length is larger than a `u32`.
#[allow(clippy::cast_possible_truncation)]
#[expect(clippy::cast_possible_truncation)]
pub(super) fn text_len(&self) -> TextSize {
TextSize::new(self.chars.as_str().len() as u32)
}

View file

@ -210,7 +210,7 @@ pub(crate) struct TokenSourceCheckpoint {
/// of `contents`.
///
/// See [#9546](https://github.com/astral-sh/ruff/pull/9546) for a more detailed explanation.
#[allow(dead_code)]
#[expect(dead_code)]
fn allocate_tokens_vec(contents: &str) -> Vec<Token> {
let lower_bound = contents.len().saturating_mul(15) / 100;
Vec::with_capacity(lower_bound)

View file

@ -274,7 +274,7 @@ fn extract_options(source: &str) -> Option<ParseOptions> {
// Use it for quickly debugging a parser issue.
#[test]
#[ignore]
#[allow(clippy::print_stdout)]
#[expect(clippy::print_stdout)]
fn parser_quick_test() {
let source = "\
f'{'