Skip to content

Commit 29927f2

Browse files
authored
Update Rust toolchain to 1.88 and MSRV to 1.86 (astral-sh#19011)
1 parent c5995c4 commit 29927f2

File tree

59 files changed

+210
-425
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+210
-425
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 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.85"
8+
rust-version = "1.86"
99
homepage = "https://docs.astral.sh/ruff"
1010
documentation = "https://docs.astral.sh/ruff"
1111
repository = "https://github.com/astral-sh/ruff"
@@ -227,6 +227,7 @@ unnecessary_debug_formatting = "allow" # too many instances, the display also d
227227
# Without the hashes we run into a `rustfmt` bug in some snapshot tests, see #13250
228228
needless_raw_string_hashes = "allow"
229229
# Disallowed restriction lints
230+
ignore_without_reason = "allow" # Too many exsisting instances, and there's no auto fix.
230231
print_stdout = "warn"
231232
print_stderr = "warn"
232233
dbg_macro = "warn"

crates/ruff/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ ruff_linter = { workspace = true, features = ["clap", "test-rules"] }
6868
assert_fs = { workspace = true }
6969
# Avoid writing colored snapshots when running tests from the terminal
7070
colored = { workspace = true, features = ["no-color"] }
71+
dunce = { workspace = true }
7172
indoc = { workspace = true }
7273
insta = { workspace = true, features = ["filters", "json"] }
7374
insta-cmd = { workspace = true }

crates/ruff/tests/lint.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ fn extend_passed_via_config_argument() {
612612
#[test]
613613
fn nonexistent_extend_file() -> Result<()> {
614614
let tempdir = TempDir::new()?;
615-
let project_dir = tempdir.path().canonicalize()?;
615+
let project_dir = dunce::canonicalize(tempdir.path())?;
616616
fs::write(
617617
project_dir.join("ruff.toml"),
618618
r#"
@@ -653,7 +653,7 @@ extend = "ruff3.toml"
653653
#[test]
654654
fn circular_extend() -> Result<()> {
655655
let tempdir = TempDir::new()?;
656-
let project_path = tempdir.path().canonicalize()?;
656+
let project_path = dunce::canonicalize(tempdir.path())?;
657657

658658
fs::write(
659659
project_path.join("ruff.toml"),
@@ -698,7 +698,7 @@ extend = "ruff.toml"
698698
#[test]
699699
fn parse_error_extends() -> Result<()> {
700700
let tempdir = TempDir::new()?;
701-
let project_path = tempdir.path().canonicalize()?;
701+
let project_path = dunce::canonicalize(tempdir.path())?;
702702

703703
fs::write(
704704
project_path.join("ruff.toml"),
@@ -2130,7 +2130,7 @@ select = ["UP006"]
21302130
#[test]
21312131
fn requires_python_no_tool() -> Result<()> {
21322132
let tempdir = TempDir::new()?;
2133-
let project_dir = tempdir.path().canonicalize()?;
2133+
let project_dir = dunce::canonicalize(tempdir.path())?;
21342134
let ruff_toml = tempdir.path().join("pyproject.toml");
21352135
fs::write(
21362136
&ruff_toml,
@@ -2441,7 +2441,7 @@ requires-python = ">= 3.11"
24412441
#[test]
24422442
fn requires_python_no_tool_target_version_override() -> Result<()> {
24432443
let tempdir = TempDir::new()?;
2444-
let project_dir = tempdir.path().canonicalize()?;
2444+
let project_dir = dunce::canonicalize(tempdir.path())?;
24452445
let ruff_toml = tempdir.path().join("pyproject.toml");
24462446
fs::write(
24472447
&ruff_toml,
@@ -2752,7 +2752,7 @@ requires-python = ">= 3.11"
27522752
#[test]
27532753
fn requires_python_no_tool_with_check() -> Result<()> {
27542754
let tempdir = TempDir::new()?;
2755-
let project_dir = tempdir.path().canonicalize()?;
2755+
let project_dir = dunce::canonicalize(tempdir.path())?;
27562756
let ruff_toml = tempdir.path().join("pyproject.toml");
27572757
fs::write(
27582758
&ruff_toml,
@@ -2797,7 +2797,7 @@ requires-python = ">= 3.11"
27972797
#[test]
27982798
fn requires_python_ruff_toml_no_target_fallback() -> Result<()> {
27992799
let tempdir = TempDir::new()?;
2800-
let project_dir = tempdir.path().canonicalize()?;
2800+
let project_dir = dunce::canonicalize(tempdir.path())?;
28012801
let ruff_toml = tempdir.path().join("ruff.toml");
28022802
fs::write(
28032803
&ruff_toml,
@@ -3118,7 +3118,7 @@ from typing import Union;foo: Union[int, str] = 1
31183118
#[test]
31193119
fn requires_python_ruff_toml_no_target_fallback_check() -> Result<()> {
31203120
let tempdir = TempDir::new()?;
3121-
let project_dir = tempdir.path().canonicalize()?;
3121+
let project_dir = dunce::canonicalize(tempdir.path())?;
31223122
let ruff_toml = tempdir.path().join("ruff.toml");
31233123
fs::write(
31243124
&ruff_toml,
@@ -3173,7 +3173,7 @@ from typing import Union;foo: Union[int, str] = 1
31733173
#[test]
31743174
fn requires_python_pyproject_toml_above() -> Result<()> {
31753175
let tempdir = TempDir::new()?;
3176-
let project_dir = tempdir.path().canonicalize()?;
3176+
let project_dir = dunce::canonicalize(tempdir.path())?;
31773177
let outer_pyproject = tempdir.path().join("pyproject.toml");
31783178
fs::write(
31793179
&outer_pyproject,
@@ -3200,7 +3200,7 @@ from typing import Union;foo: Union[int, str] = 1
32003200
"#,
32013201
)?;
32023202

3203-
let testpy_canon = testpy.canonicalize()?;
3203+
let testpy_canon = dunce::canonicalize(testpy)?;
32043204

32053205
insta::with_settings!({
32063206
filters => vec![(tempdir_filter(&testpy_canon).as_str(), "[TMP]/foo/test.py"),(tempdir_filter(&project_dir).as_str(), "[TMP]/"),(r"(?m)^foo\\test","foo/test")]
@@ -3499,7 +3499,7 @@ from typing import Union;foo: Union[int, str] = 1
34993499
#[test]
35003500
fn requires_python_pyproject_toml_above_with_tool() -> Result<()> {
35013501
let tempdir = TempDir::new()?;
3502-
let project_dir = tempdir.path().canonicalize()?;
3502+
let project_dir = dunce::canonicalize(tempdir.path())?;
35033503
let outer_pyproject = tempdir.path().join("pyproject.toml");
35043504
fs::write(
35053505
&outer_pyproject,
@@ -3528,7 +3528,7 @@ from typing import Union;foo: Union[int, str] = 1
35283528
"#,
35293529
)?;
35303530

3531-
let testpy_canon = testpy.canonicalize()?;
3531+
let testpy_canon = dunce::canonicalize(testpy)?;
35323532

35333533
insta::with_settings!({
35343534
filters => vec![(tempdir_filter(&testpy_canon).as_str(), "[TMP]/foo/test.py"),(tempdir_filter(&project_dir).as_str(), "[TMP]/"),(r"foo\\","foo/")]
@@ -3827,7 +3827,7 @@ from typing import Union;foo: Union[int, str] = 1
38273827
#[test]
38283828
fn requires_python_ruff_toml_above() -> Result<()> {
38293829
let tempdir = TempDir::new()?;
3830-
let project_dir = tempdir.path().canonicalize()?;
3830+
let project_dir = dunce::canonicalize(tempdir.path())?;
38313831
let ruff_toml = tempdir.path().join("ruff.toml");
38323832
fs::write(
38333833
&ruff_toml,
@@ -3856,7 +3856,7 @@ from typing import Union;foo: Union[int, str] = 1
38563856
"#,
38573857
)?;
38583858

3859-
let testpy_canon = testpy.canonicalize()?;
3859+
let testpy_canon = dunce::canonicalize(testpy)?;
38603860

38613861
insta::with_settings!({
38623862
filters => vec![(tempdir_filter(&testpy_canon).as_str(), "[TMP]/foo/test.py"),(tempdir_filter(&project_dir).as_str(), "[TMP]/")]
@@ -4441,7 +4441,7 @@ from typing import Union;foo: Union[int, str] = 1
44414441
#[test]
44424442
fn requires_python_extend_from_shared_config() -> Result<()> {
44434443
let tempdir = TempDir::new()?;
4444-
let project_dir = tempdir.path().canonicalize()?;
4444+
let project_dir = dunce::canonicalize(tempdir.path())?;
44454445
let ruff_toml = tempdir.path().join("ruff.toml");
44464446
fs::write(
44474447
&ruff_toml,
@@ -4479,7 +4479,7 @@ from typing import Union;foo: Union[int, str] = 1
44794479
"#,
44804480
)?;
44814481

4482-
let testpy_canon = testpy.canonicalize()?;
4482+
let testpy_canon = dunce::canonicalize(testpy)?;
44834483

44844484
insta::with_settings!({
44854485
filters => vec![(tempdir_filter(&testpy_canon).as_str(), "[TMP]/test.py"),(tempdir_filter(&project_dir).as_str(), "[TMP]/")]

crates/ruff/tests/show_settings.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ fn display_default_settings() -> anyhow::Result<()> {
1212

1313
// Tempdir path's on macos are symlinks, which doesn't play nicely with
1414
// our snapshot filtering.
15-
let project_dir = tempdir
16-
.path()
17-
.canonicalize()
18-
.context("Failed to canonical tempdir path.")?;
15+
let project_dir =
16+
dunce::canonicalize(tempdir.path()).context("Failed to canonical tempdir path.")?;
1917

2018
std::fs::write(
2119
project_dir.join("pyproject.toml"),

crates/ruff_annotate_snippets/src/renderer/display_list.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,7 @@ impl DisplaySourceAnnotation<'_> {
821821
// Length of this annotation as displayed in the stderr output
822822
fn len(&self) -> usize {
823823
// Account for usize underflows
824-
if self.range.1 > self.range.0 {
825-
self.range.1 - self.range.0
826-
} else {
827-
self.range.0 - self.range.1
828-
}
824+
self.range.1.abs_diff(self.range.0)
829825
}
830826

831827
fn takes_space(&self) -> bool {

crates/ruff_db/src/diagnostic/render.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,22 @@ pub trait FileResolver {
637637
fn input(&self, file: File) -> Input;
638638
}
639639

640+
impl<T> FileResolver for T
641+
where
642+
T: Db,
643+
{
644+
fn path(&self, file: File) -> &str {
645+
relativize_path(self.system().current_directory(), file.path(self).as_str())
646+
}
647+
648+
fn input(&self, file: File) -> Input {
649+
Input {
650+
text: source_text(self, file),
651+
line_index: line_index(self, file),
652+
}
653+
}
654+
}
655+
640656
impl FileResolver for &dyn Db {
641657
fn path(&self, file: File) -> &str {
642658
relativize_path(self.system().current_directory(), file.path(*self).as_str())
@@ -708,7 +724,6 @@ fn relativize_path<'p>(cwd: &SystemPath, path: &'p str) -> &'p str {
708724
#[cfg(test)]
709725
mod tests {
710726

711-
use crate::Upcast;
712727
use crate::diagnostic::{Annotation, DiagnosticId, Severity, Span};
713728
use crate::files::system_path_to_file;
714729
use crate::system::{DbWithWritableSystem, SystemPath};
@@ -2221,7 +2236,7 @@ watermelon
22212236
///
22222237
/// (This will set the "printed" flag on `Diagnostic`.)
22232238
fn render(&self, diag: &Diagnostic) -> String {
2224-
diag.display(&self.db.upcast(), &self.config).to_string()
2239+
diag.display(&self.db, &self.config).to_string()
22252240
}
22262241
}
22272242

crates/ruff_db/src/lib.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,6 @@ pub trait Db: salsa::Database {
3636
fn python_version(&self) -> PythonVersion;
3737
}
3838

39-
/// Trait for upcasting a reference to a base trait object.
40-
pub trait Upcast<T: ?Sized> {
41-
fn upcast(&self) -> &T;
42-
fn upcast_mut(&mut self) -> &mut T;
43-
}
44-
4539
/// Returns the maximum number of tasks that ty is allowed
4640
/// to process in parallel.
4741
///
@@ -76,11 +70,11 @@ pub trait RustDoc {
7670
mod tests {
7771
use std::sync::{Arc, Mutex};
7872

73+
use crate::Db;
7974
use crate::files::Files;
8075
use crate::system::TestSystem;
8176
use crate::system::{DbWithTestSystem, System};
8277
use crate::vendored::VendoredFileSystem;
83-
use crate::{Db, Upcast};
8478

8579
type Events = Arc<Mutex<Vec<salsa::Event>>>;
8680

@@ -153,15 +147,6 @@ mod tests {
153147
}
154148
}
155149

156-
impl Upcast<dyn Db> for TestDb {
157-
fn upcast(&self) -> &(dyn Db + 'static) {
158-
self
159-
}
160-
fn upcast_mut(&mut self) -> &mut (dyn Db + 'static) {
161-
self
162-
}
163-
}
164-
165150
impl DbWithTestSystem for TestDb {
166151
fn test_system(&self) -> &TestSystem {
167152
&self.system

crates/ruff_db/src/system/walk_directory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ impl Display for Error {
212212
path: Some(path),
213213
err,
214214
} => {
215-
write!(f, "IO error for operation on {}: {}", path, err)
215+
write!(f, "IO error for operation on {path}: {err}")
216216
}
217217
ErrorKind::Io { path: None, err } => err.fmt(f),
218218
ErrorKind::NonUtf8Path { path } => {

crates/ruff_graph/src/db.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ use anyhow::{Context, Result};
22
use std::sync::Arc;
33
use zip::CompressionMethod;
44

5+
use ruff_db::Db as SourceDb;
56
use ruff_db::files::{File, Files};
67
use ruff_db::system::{OsSystem, System, SystemPathBuf};
78
use ruff_db::vendored::{VendoredFileSystem, VendoredFileSystemBuilder};
8-
use ruff_db::{Db as SourceDb, Upcast};
99
use ruff_python_ast::PythonVersion;
1010
use ty_python_semantic::lint::{LintRegistry, RuleSelection};
1111
use ty_python_semantic::{
@@ -66,15 +66,6 @@ impl ModuleDb {
6666
}
6767
}
6868

69-
impl Upcast<dyn SourceDb> for ModuleDb {
70-
fn upcast(&self) -> &(dyn SourceDb + 'static) {
71-
self
72-
}
73-
fn upcast_mut(&mut self) -> &mut (dyn SourceDb + 'static) {
74-
self
75-
}
76-
}
77-
7869
#[salsa::db]
7970
impl SourceDb for ModuleDb {
8071
fn vendored(&self) -> &VendoredFileSystem {

0 commit comments

Comments
 (0)