Switch to Rust 2024 edition (#18129)

This commit is contained in:
Micha Reiser 2025-05-16 13:25:28 +02:00 committed by GitHub
parent e67b35743a
commit 9ae698fe30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
1082 changed files with 4211 additions and 3300 deletions

View file

@ -9,7 +9,7 @@ use anyhow::bail;
use ruff_db::system::{SystemPath, SystemPathBuf};
use rustc_hash::FxHashMap;
use ruff_index::{newtype_index, IndexVec};
use ruff_index::{IndexVec, newtype_index};
use ruff_python_ast::PySourceType;
use ruff_python_trivia::Cursor;
use ruff_source_file::{LineIndex, LineRanges, OneIndexed};
@ -540,7 +540,9 @@ impl<'s> Parser<'s> {
let backtick_offset_start = self.offset() - "```".text_len();
if self.preceding_blank_lines < 1 && self.explicit_path.is_none() {
bail!("Code blocks must start on a new line and be preceded by at least one blank line.");
bail!(
"Code blocks must start on a new line and be preceded by at least one blank line."
);
}
self.skip_whitespace();
@ -553,7 +555,9 @@ impl<'s> Parser<'s> {
self.skip_whitespace();
if !self.cursor.eat_char('\n') {
bail!("Trailing code-block metadata is not supported. Only the code block language can be specified.");
bail!(
"Trailing code-block metadata is not supported. Only the code block language can be specified."
);
}
if let Some(position) =
@ -702,7 +706,9 @@ impl<'s> Parser<'s> {
"py" | "python" => EmbeddedFilePath::Autogenerated(PySourceType::Python),
"pyi" => EmbeddedFilePath::Autogenerated(PySourceType::Stub),
"" => {
bail!("Cannot auto-generate file name for code block with empty language specifier in test `{test_name}`");
bail!(
"Cannot auto-generate file name for code block with empty language specifier in test `{test_name}`"
);
}
_ => {
bail!(
@ -719,7 +725,9 @@ impl<'s> Parser<'s> {
match self.current_section_files.entry(path.clone()) {
Entry::Vacant(entry) => {
if has_merged_snippets {
bail!("Merged snippets in test `{test_name}` are not allowed in the presence of other files.");
bail!(
"Merged snippets in test `{test_name}` are not allowed in the presence of other files."
);
}
let index = self.files.push(EmbeddedFile {
@ -740,7 +748,9 @@ impl<'s> Parser<'s> {
}
if has_explicit_file_paths {
bail!("Merged snippets in test `{test_name}` are not allowed in the presence of other files.");
bail!(
"Merged snippets in test `{test_name}` are not allowed in the presence of other files."
);
}
let index = *entry.get();
@ -1788,7 +1798,10 @@ mod tests {
",
);
let err = super::parse("file.md", &source).expect_err("Should fail to parse");
assert_eq!(err.to_string(), "Trailing code-block metadata is not supported. Only the code block language can be specified.");
assert_eq!(
err.to_string(),
"Trailing code-block metadata is not supported. Only the code block language can be specified."
);
}
#[test]