Upgrade to Rust 1.86 and bump MSRV to 1.84 (#17171)

<!--
Thank you for contributing to Ruff! To help us out with reviewing,
please consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

I decided to disable the new
[`needless_continue`](https://rust-lang.github.io/rust-clippy/master/index.html#needless_continue)
rule because I often found the explicit `continue` more readable over an
empty block or having to invert the condition of an other branch.


## Test Plan

`cargo test`

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Micha Reiser 2025-04-03 17:59:44 +02:00 committed by GitHub
parent fedd982fd5
commit 8a4158c5f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
135 changed files with 285 additions and 255 deletions

View file

@ -2,6 +2,7 @@
#![allow(clippy::print_stdout, clippy::print_stderr)]
use std::collections::HashSet;
use std::fmt::Write as _;
use std::fs;
use std::path::PathBuf;
@ -29,8 +30,7 @@ pub(crate) fn main(args: &Args) -> Result<()> {
if let Some(explanation) = rule.explanation() {
let mut output = String::new();
output.push_str(&format!("# {} ({})", rule.as_ref(), rule.noqa_code()));
output.push('\n');
let _ = writeln!(&mut output, "# {} ({})", rule.as_ref(), rule.noqa_code());
let (linter, _) = Linter::parse_code(&rule.noqa_code().to_string()).unwrap();
if linter.url().is_some() {
@ -49,11 +49,12 @@ pub(crate) fn main(args: &Args) -> Result<()> {
common_prefix.to_lowercase()
);
output.push_str(&format!(
let _ = write!(
output,
"Derived from the **[{}](../rules.md#{})** linter.",
linter.name(),
anchor
));
anchor,
);
output.push('\n');
output.push('\n');
}
@ -155,8 +156,8 @@ fn process_documentation(documentation: &str, out: &mut String, rule_name: &str)
}
let anchor = option.replace('.', "_");
out.push_str(&format!("- [`{option}`][{option}]\n"));
after.push_str(&format!("[{option}]: ../settings.md#{anchor}\n"));
let _ = writeln!(out, "- [`{option}`][{option}]");
let _ = writeln!(&mut after, "[{option}]: ../settings.md#{anchor}");
referenced_options.insert(option);
continue;
@ -171,7 +172,7 @@ fn process_documentation(documentation: &str, out: &mut String, rule_name: &str)
if let Some(OptionEntry::Field(field)) = Options::metadata().find(option) {
if referenced_options.insert(option) {
let anchor = option.replace('.', "_");
after.push_str(&format!("[{option}]: ../settings.md#{anchor}\n"));
let _ = writeln!(&mut after, "[{option}]: ../settings.md#{anchor}");
}
if field.deprecated.is_some() {
eprintln!("Rule {rule_name} references deprecated option {option}.");

View file

@ -98,17 +98,16 @@ fn emit_field(output: &mut String, name: &str, field: &OptionField, parents: &[S
let parents_anchor = parents.iter().filter_map(|parent| parent.name()).join("_");
if parents_anchor.is_empty() {
output.push_str(&format!(
"{header_level} [`{name}`](#{name}) {{: #{name} }}\n"
));
let _ = writeln!(output, "{header_level} [`{name}`](#{name}) {{: #{name} }}");
} else {
output.push_str(&format!(
"{header_level} [`{name}`](#{parents_anchor}_{name}) {{: #{parents_anchor}_{name} }}\n"
));
let _ =
writeln!(output,
"{header_level} [`{name}`](#{parents_anchor}_{name}) {{: #{parents_anchor}_{name} }}"
);
// the anchor used to just be the name, but now it's the group name
// for backwards compatibility, we need to keep the old anchor
output.push_str(&format!("<span id=\"{name}\"></span>\n"));
let _ = writeln!(output, "<span id=\"{name}\"></span>");
}
output.push('\n');
@ -132,9 +131,9 @@ fn emit_field(output: &mut String, name: &str, field: &OptionField, parents: &[S
output.push_str(field.doc);
output.push_str("\n\n");
output.push_str(&format!("**Default value**: `{}`\n", field.default));
let _ = writeln!(output, "**Default value**: `{}`", field.default);
output.push('\n');
output.push_str(&format!("**Type**: `{}`\n", field.value_type));
let _ = writeln!(output, "**Type**: `{}`", field.value_type);
output.push('\n');
output.push_str("**Example usage**:\n\n");
output.push_str(&format_tab(

View file

@ -5,6 +5,7 @@
use itertools::Itertools;
use ruff_linter::codes::RuleGroup;
use std::borrow::Cow;
use std::fmt::Write;
use strum::IntoEnumIterator;
use ruff_diagnostics::FixAvailability;
@ -78,7 +79,8 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
}
#[allow(clippy::or_fun_call)]
table_out.push_str(&format!(
let _ = write!(
table_out,
"| {ss}{0}{1}{se} {{ #{0}{1} }} | {ss}{2}{se} | {ss}{3}{se} | {ss}{4}{se} |",
linter.common_prefix(),
linter.code_for_rule(rule).unwrap(),
@ -88,7 +90,7 @@ fn generate_table(table_out: &mut String, rules: impl IntoIterator<Item = Rule>,
.unwrap_or(format_args!("{rule_name}")),
message,
tokens,
));
);
table_out.push('\n');
}
table_out.push('\n');
@ -101,29 +103,30 @@ pub(crate) fn generate() -> String {
table_out.push_str("### Legend");
table_out.push('\n');
table_out.push_str(&format!(
let _ = write!(
&mut table_out,
"{SPACER}{STABLE_SYMBOL}{SPACER} The rule is stable."
));
);
table_out.push_str("<br />");
table_out.push_str(&format!(
let _ = write!(&mut table_out,
"{SPACER}{PREVIEW_SYMBOL}{SPACER} The rule is unstable and is in [\"preview\"](faq.md#what-is-preview)."
));
);
table_out.push_str("<br />");
table_out.push_str(&format!(
let _ = write!(&mut table_out,
"{SPACER}{WARNING_SYMBOL}{SPACER} The rule has been deprecated and will be removed in a future release."
));
);
table_out.push_str("<br />");
table_out.push_str(&format!(
let _ = write!(&mut table_out,
"{SPACER}{REMOVED_SYMBOL}{SPACER} The rule has been removed only the documentation is available."
));
);
table_out.push_str("<br />");
table_out.push_str(&format!(
let _ = write!(&mut table_out,
"{SPACER}{FIX_SYMBOL}{SPACER} The rule is automatically fixable by the `--fix` command-line option."
));
);
table_out.push_str("<br />");
table_out.push('\n');
@ -137,7 +140,7 @@ pub(crate) fn generate() -> String {
.join(", "),
prefix => prefix.to_string(),
};
table_out.push_str(&format!("### {} ({codes_csv})", linter.name()));
let _ = write!(&mut table_out, "### {} ({codes_csv})", linter.name());
table_out.push('\n');
table_out.push('\n');
@ -147,7 +150,8 @@ pub(crate) fn generate() -> String {
.split('/')
.next()
.unwrap();
table_out.push_str(&format!(
let _ = write!(
table_out,
"For more, see [{}]({}) on {}.",
linter.name(),
url,
@ -160,17 +164,18 @@ pub(crate) fn generate() -> String {
linter.name()
),
}
));
);
table_out.push('\n');
table_out.push('\n');
}
if Options::metadata().has(&format!("lint.{}", linter.name())) {
table_out.push_str(&format!(
let _ = write!(
table_out,
"For related settings, see [{}](settings.md#lint{}).",
linter.name(),
linter.name(),
));
);
table_out.push('\n');
table_out.push('\n');
}
@ -200,10 +205,10 @@ pub(crate) fn generate() -> String {
let UpstreamCategoryAndPrefix { category, prefix } = opt.unwrap();
match codes_csv.as_str() {
"PL" => {
table_out.push_str(&format!("#### {category} ({codes_csv}{prefix})"));
let _ = write!(table_out, "#### {category} ({codes_csv}{prefix})");
}
_ => {
table_out.push_str(&format!("#### {category} ({prefix})"));
let _ = write!(table_out, "#### {category} ({prefix})");
}
}
}