Skip to content

Commit 41d30df

Browse files
Update Rust toolchain to 1.99 and MSRV to 1.97 (#29047)
## Summary - Update the Rust toolchain to 1.99.0 and the MSRV to 1.97, following our N-2 support policy. - Address the new Clippy warnings and preserve our existing assertion and formatting macro conventions. - Update Hawk to 0.1.15 and run it with Rust 1.99.0.
1 parent 317e0a3 commit 41d30df

8 files changed

Lines changed: 87 additions & 86 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525
CARGO_PROFILE_DEV_OPT_LEVEL: 0
2626
CARGO_TERM_COLOR: always
2727
# renovate: datasource=github-releases depName=astral-sh/hawk
28-
HAWK_VERSION: 0.1.13
28+
HAWK_VERSION: 0.1.15
2929
RUSTUP_MAX_RETRIES: 10
3030
PACKAGE_NAME: ruff
3131
PYTHON_VERSION: "3.14"
@@ -355,13 +355,13 @@ jobs:
355355
cache-workspace-crates: "false"
356356
save-if: ${{ github.ref == 'refs/heads/main' }}
357357
- name: "Install Rust toolchain"
358-
run: rustup toolchain install 1.98.0
358+
run: rustup toolchain install 1.99.0
359359
- name: "Install Hawk"
360360
run: |
361361
curl --proto '=https' --tlsv1.2 -LsSf \
362362
"https://github.com/astral-sh/hawk/releases/download/${HAWK_VERSION}/cargo-hawk-installer.sh" | sh
363363
- name: "Hawk"
364-
run: cargo +1.98.0 hawk check --target-dir target/hawk -D warnings
364+
run: cargo +1.99.0 hawk check --target-dir target/hawk -D warnings
365365

366366
cargo-publish-dry-run:
367367
name: "cargo publish dry-run"

‎Cargo.toml‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ resolver = "2"
55
[workspace.package]
66
# Please update rustfmt.toml when bumping the Rust edition
77
edition = "2024"
8-
rust-version = "1.96"
8+
rust-version = "1.97"
99
homepage = "https://docs.astral.sh/ruff"
1010
documentation = "https://docs.astral.sh/ruff"
1111
repository = "https://github.com/astral-sh/ruff"
@@ -272,6 +272,7 @@ pedantic = { level = "warn", priority = -2 }
272272
# Enabled at the crate level
273273
disallowed_methods = "allow"
274274
# Allowed pedantic lints
275+
assert_is_empty = "allow"
275276
char_lit_as_u8 = "allow"
276277
collapsible_else_if = "allow"
277278
collapsible_if = "allow"
@@ -282,6 +283,8 @@ missing_errors_doc = "allow"
282283
missing_panics_doc = "allow"
283284
module_name_repetitions = "allow"
284285
must_use_candidate = "allow"
286+
# Our formatting macros share names with std macros but use square brackets.
287+
nonstandard_macro_braces = "allow"
285288
similar_names = "allow"
286289
single_match_else = "allow"
287290
too_many_lines = "allow"

‎crates/ruff/src/lib.rs‎

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -430,96 +430,95 @@ pub fn check(args: CheckCommand, global_options: GlobalConfigArgs) -> Result<Exi
430430
)?;
431431
printer.write_continuously(&mut writer, &diagnostics, preview, prefer_rule_codes)?;
432432
}
433+
}
434+
// Generate lint violations.
435+
let diagnostics = if is_stdin {
436+
commands::check_stdin::check_stdin(
437+
cli.stdin_filename.map(fs::normalize_path).as_deref(),
438+
&pyproject_config,
439+
&config_arguments,
440+
noqa.into(),
441+
fix_mode,
442+
)?
433443
} else {
434-
// Generate lint violations.
435-
let diagnostics = if is_stdin {
436-
commands::check_stdin::check_stdin(
437-
cli.stdin_filename.map(fs::normalize_path).as_deref(),
438-
&pyproject_config,
439-
&config_arguments,
440-
noqa.into(),
441-
fix_mode,
442-
)?
443-
} else {
444-
commands::check::check(
445-
&files,
446-
&pyproject_config,
447-
&config_arguments,
448-
cache.into(),
449-
noqa.into(),
450-
fix_mode,
451-
unsafe_fixes,
452-
)?
453-
};
454-
455-
// Always try to print violations (though the printer itself may suppress output)
456-
// If we're writing fixes via stdin, the transformed source code goes to the writer
457-
// so send the summary to stderr instead
458-
let mut summary_writer = if is_stdin && matches!(fix_mode, FixMode::Apply | FixMode::Diff) {
459-
stderr_writer
460-
} else {
461-
writer
462-
};
463-
if cli.statistics {
464-
printer.write_statistics(&diagnostics, &mut summary_writer)?;
465-
} else {
466-
printer.write_once(
467-
&diagnostics,
468-
&mut summary_writer,
469-
preview,
470-
prefer_rule_codes,
471-
)?;
472-
}
444+
commands::check::check(
445+
&files,
446+
&pyproject_config,
447+
&config_arguments,
448+
cache.into(),
449+
noqa.into(),
450+
fix_mode,
451+
unsafe_fixes,
452+
)?
453+
};
454+
455+
// Always try to print violations (though the printer itself may suppress output)
456+
// If we're writing fixes via stdin, the transformed source code goes to the writer
457+
// so send the summary to stderr instead
458+
let mut summary_writer = if is_stdin && matches!(fix_mode, FixMode::Apply | FixMode::Diff) {
459+
stderr_writer
460+
} else {
461+
writer
462+
};
463+
if cli.statistics {
464+
printer.write_statistics(&diagnostics, &mut summary_writer)?;
465+
} else {
466+
printer.write_once(
467+
&diagnostics,
468+
&mut summary_writer,
469+
preview,
470+
prefer_rule_codes,
471+
)?;
472+
}
473473

474-
if !cli.exit_zero {
475-
let max_severity = diagnostics
476-
.inner
477-
.iter()
478-
.map(Diagnostic::severity)
479-
.max()
480-
.unwrap_or(Severity::Info);
481-
if max_severity.is_fatal() {
482-
// When a panic/fatal error is reported, prompt the user to open an issue on github.
483-
// Diagnostics with severity `fatal` will be sorted to the bottom, and printing the
484-
// message here instead of attaching it to the diagnostic ensures that we only print
485-
// it once instead of repeating it for each diagnostic. Prints to stderr to prevent
486-
// the message from being captured by tools parsing the normal output.
487-
let message = "Panic during linting indicates a bug in Ruff. If you could open an issue at:
474+
if !cli.exit_zero {
475+
let max_severity = diagnostics
476+
.inner
477+
.iter()
478+
.map(Diagnostic::severity)
479+
.max()
480+
.unwrap_or(Severity::Info);
481+
if max_severity.is_fatal() {
482+
// When a panic/fatal error is reported, prompt the user to open an issue on github.
483+
// Diagnostics with severity `fatal` will be sorted to the bottom, and printing the
484+
// message here instead of attaching it to the diagnostic ensures that we only print
485+
// it once instead of repeating it for each diagnostic. Prints to stderr to prevent
486+
// the message from being captured by tools parsing the normal output.
487+
let message = "Panic during linting indicates a bug in Ruff. If you could open an issue at:
488488
489489
https://github.com/astral-sh/ruff/issues/new?title=%5BLinter%20panic%5D
490490
491491
...with the relevant file contents, the `pyproject.toml` settings, and the stack trace above, we'd be very appreciative!
492492
";
493-
error!("{message}");
494-
return Ok(ExitStatus::Error);
493+
error!("{message}");
494+
return Ok(ExitStatus::Error);
495+
}
496+
if cli.diff {
497+
// If we're printing a diff, we always want to exit non-zero if there are
498+
// any fixable violations (since we've printed the diff, but not applied the
499+
// fixes).
500+
if !diagnostics.fixed.is_empty() {
501+
return Ok(ExitStatus::Failure);
495502
}
496-
if cli.diff {
497-
// If we're printing a diff, we always want to exit non-zero if there are
498-
// any fixable violations (since we've printed the diff, but not applied the
499-
// fixes).
503+
} else if fix_only {
504+
// If we're only fixing, we want to exit zero (since we've fixed all fixable
505+
// violations), unless we're explicitly asked to exit non-zero on fix.
506+
if cli.exit_non_zero_on_fix {
500507
if !diagnostics.fixed.is_empty() {
501508
return Ok(ExitStatus::Failure);
502509
}
503-
} else if fix_only {
504-
// If we're only fixing, we want to exit zero (since we've fixed all fixable
505-
// violations), unless we're explicitly asked to exit non-zero on fix.
506-
if cli.exit_non_zero_on_fix {
507-
if !diagnostics.fixed.is_empty() {
508-
return Ok(ExitStatus::Failure);
509-
}
510+
}
511+
} else {
512+
// If we're running the linter (not just fixing), we want to exit non-zero if
513+
// there are any violations, unless we're explicitly asked to exit zero on
514+
// fix.
515+
if cli.exit_non_zero_on_fix {
516+
if !diagnostics.fixed.is_empty() || !diagnostics.inner.is_empty() {
517+
return Ok(ExitStatus::Failure);
510518
}
511519
} else {
512-
// If we're running the linter (not just fixing), we want to exit non-zero if
513-
// there are any violations, unless we're explicitly asked to exit zero on
514-
// fix.
515-
if cli.exit_non_zero_on_fix {
516-
if !diagnostics.fixed.is_empty() || !diagnostics.inner.is_empty() {
517-
return Ok(ExitStatus::Failure);
518-
}
519-
} else {
520-
if !diagnostics.inner.is_empty() {
521-
return Ok(ExitStatus::Failure);
522-
}
520+
if !diagnostics.inner.is_empty() {
521+
return Ok(ExitStatus::Failure);
523522
}
524523
}
525524
}

‎crates/ty_module_resolver/src/module_name.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ impl ModuleName {
7979
///
8080
/// assert_eq!(ModuleName::new_static("foo.bar.baz").unwrap().components().collect::<Vec<_>>(), vec!["foo", "bar", "baz"]);
8181
/// ```
82-
#[must_use]
8382
pub fn components(&self) -> impl DoubleEndedIterator<Item = &str> {
8483
self.0.split('.')
8584
}

‎crates/ty_python_semantic/src/place.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ fn builtins_symbol_impl<'db>(
708708
resolver_environment,
709709
&ModuleName::new_static("__builtins__").unwrap(),
710710
)
711-
.and_then(&resolver)
711+
.and_then(resolver)
712712
.or_else(|| {
713713
resolve_module_confident(db, resolver_environment, &KnownModule::Builtins.name())
714714
.and_then(resolver)

‎crates/ty_python_semantic/src/types/display.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ impl Drop for TypeDetailGuard<'_, '_, '_, '_> {
538538
fn drop(&mut self) {
539539
// The fallibility here is primarily retrieving `TypeWriter::Details`
540540
// everything else is ideally-never-fails pedantry (yay for pedantry!)
541-
if let TypeWriter::Details(details) = &mut self.inner
541+
if let TypeWriter::Details(details) = &mut *self.inner
542542
&& let Some(start) = self.start
543543
&& let Some(payload) = self.payload.take()
544544
{

‎crates/ty_python_semantic/src/types/infer/builder/enum_call.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ fn next_auto_value<'db>(
209209
if last <= 0 {
210210
Type::int_literal(1)
211211
} else {
212-
let shift = i64::BITS - last.leading_zeros();
212+
let shift = last.cast_unsigned().bit_width();
213213
1_u64
214214
.checked_shl(shift)
215215
.and_then(|value| i64::try_from(value).ok())

‎rust-toolchain.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.98.0"
2+
channel = "1.99.0"

0 commit comments

Comments
 (0)