Skip to content

Commit

Permalink
Revert "Upgrade to Rust 1.82 toolchain" (#13810)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Oct 18, 2024
1 parent ff72055 commit 6d7da7b
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ jobs:
run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
cache: "npm"
cache-dependency-path: playground/package-lock.json
- uses: jetli/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-playground.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
run: rustup target add wasm32-unknown-unknown
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
cache: "npm"
cache-dependency-path: playground/package-lock.json
- uses: jetli/[email protected]
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-wasm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
- run: cp LICENSE crates/ruff_wasm/pkg # wasm-pack does not put the LICENSE file in the pkg
- uses: actions/setup-node@v4
with:
node-version: 20
node-version: 18
registry-url: "https://registry.npmjs.org"
- name: "Publish (dry-run)"
if: ${{ inputs.plan == '' || fromJson(inputs.plan).announcement_tag_is_implicit }}
Expand Down
2 changes: 0 additions & 2 deletions crates/red_knot_server/src/server.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//! Scheduling, I/O, and API endpoints.
use std::num::NonZeroUsize;
#[allow(deprecated)]
use std::panic::PanicInfo;

use lsp_server::Message;
Expand Down Expand Up @@ -120,7 +119,6 @@ impl Server {
}

pub(crate) fn run(self) -> crate::Result<()> {
#[allow(deprecated)]
type PanicHook = Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>;
struct RestorePanicHook {
hook: Option<PanicHook>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,35 +235,38 @@ fn clean_params_dictionary(right: &Expr, locator: &Locator, stylist: &Stylist) -
let mut seen: Vec<&str> = vec![];
let mut indent = None;
for ast::DictItem { key, value } in items {
if let Some(key) = key {
if let Expr::StringLiteral(ast::ExprStringLiteral {
value: key_string, ..
}) = key
{
// If the dictionary key is not a valid variable name, abort.
if !is_identifier(key_string.to_str()) {
return None;
}
// If there are multiple entries of the same key, abort.
if seen.contains(&key_string.to_str()) {
return None;
}
seen.push(key_string.to_str());
if is_multi_line {
if indent.is_none() {
indent = indentation(locator, key);
match key {
Some(key) => {
if let Expr::StringLiteral(ast::ExprStringLiteral {
value: key_string, ..
}) = key
{
// If the dictionary key is not a valid variable name, abort.
if !is_identifier(key_string.to_str()) {
return None;
}
// If there are multiple entries of the same key, abort.
if seen.contains(&key_string.to_str()) {
return None;
}
seen.push(key_string.to_str());
if is_multi_line {
if indent.is_none() {
indent = indentation(locator, key);
}
}
}

let value_string = locator.slice(value);
arguments.push(format!("{key_string}={value_string}"));
} else {
// If there are any non-string keys, abort.
return None;
}
}
None => {
let value_string = locator.slice(value);
arguments.push(format!("{key_string}={value_string}"));
} else {
// If there are any non-string keys, abort.
return None;
arguments.push(format!("**{value_string}"));
}
} else {
let value_string = locator.slice(value);
arguments.push(format!("**{value_string}"));
}
}
// If we couldn't parse out key values, abort.
Expand Down
11 changes: 6 additions & 5 deletions crates/ruff_macros/src/cache_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,12 @@ pub(crate) fn derive_cache_key(item: &DeriveInput) -> syn::Result<TokenStream> {
}
}

let field_attr = if let Some(ident) = &field.ident {
quote!(self.#ident)
} else {
let index = syn::Index::from(i);
quote!(self.#index)
let field_attr = match &field.ident {
Some(ident) => quote!(self.#ident),
None => {
let index = syn::Index::from(i);
quote!(self.#index)
}
};

fields.push(quote!(#field_attr.cache_key(key);));
Expand Down
14 changes: 6 additions & 8 deletions crates/ruff_macros/src/map_codes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,9 @@ pub(crate) fn map_codes(func: &ItemFn) -> syn::Result<TokenStream> {
for (prefix, rules) in &rules_by_prefix {
let prefix_ident = get_prefix_ident(prefix);
let attrs = intersection_all(rules.iter().map(|(.., attrs)| attrs.as_slice()));
let attrs = if attrs.is_empty() {
quote!()
} else {
quote!(#(#attrs)*)
let attrs = match attrs.as_slice() {
[] => quote!(),
[..] => quote!(#(#attrs)*),
};
all_codes.push(quote! {
#attrs Self::#linter(#linter::#prefix_ident)
Expand All @@ -162,10 +161,9 @@ pub(crate) fn map_codes(func: &ItemFn) -> syn::Result<TokenStream> {
});
let prefix_ident = get_prefix_ident(&prefix);
let attrs = intersection_all(rules.iter().map(|(.., attrs)| attrs.as_slice()));
let attrs = if attrs.is_empty() {
quote!()
} else {
quote!(#(#attrs)*)
let attrs = match attrs.as_slice() {
[] => quote!(),
[..] => quote!(#(#attrs)*),
};
prefix_into_iter_match_arms.extend(quote! {
#attrs #linter::#prefix_ident => vec![#(#rule_paths,)*].into_iter(),
Expand Down
7 changes: 3 additions & 4 deletions crates/ruff_macros/src/rule_code_prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,9 @@ fn attributes_for_prefix(
attributes: &BTreeMap<String, &[Attribute]>,
) -> proc_macro2::TokenStream {
let attrs = intersection_all(codes.iter().map(|code| attributes[code]));
if attrs.is_empty() {
quote!()
} else {
quote!(#(#attrs)*)
match attrs.as_slice() {
[] => quote!(),
[..] => quote!(#(#attrs)*),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ impl FormatNodeRule<PatternMatchStar> for FormatPatternMatchStar {

write!(f, [token("*"), dangling_comments(dangling)])?;

if let Some(name) = name {
write!(f, [name.format()])
} else {
write!(f, [token("_")])
match name {
Some(name) => write!(f, [name.format()]),
None => write!(f, [token("_")]),
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions crates/ruff_server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use lsp_types::InitializeParams;
use lsp_types::WorkspaceFolder;
use std::num::NonZeroUsize;
use std::ops::Deref;
#[allow(deprecated)]
use std::panic::PanicInfo;
use std::str::FromStr;
use thiserror::Error;
Expand Down Expand Up @@ -126,7 +125,6 @@ impl Server {
}

pub fn run(self) -> crate::Result<()> {
#[allow(deprecated)]
type PanicHook = Box<dyn Fn(&PanicInfo<'_>) + 'static + Sync + Send>;
struct RestorePanicHook {
hook: Option<PanicHook>,
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel = "1.82"
channel = "1.81"

0 comments on commit 6d7da7b

Please sign in to comment.