Skip to content

Commit 35fc6fb

Browse files
tausbnCopilot
andcommitted
Rust: update toolchain to 1.91 and apply lint fixes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ce360c4 commit 35fc6fb

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
# reflected by `MODULE.bazel` in this repository).
66

77
[toolchain]
8-
channel = "1.88"
8+
channel = "1.91"
99
profile = "minimal"
1010
components = [ "clippy", "rustfmt" ]

rust/ast-generator/src/main.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,14 +308,13 @@ fn write_schema(
308308
fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
309309
let mut result = Vec::new();
310310
for field in &node.fields {
311-
if let Field::Token { token, .. } = field {
312-
if should_predicate_be_extracted(token) {
311+
if let Field::Token { token, .. } = field
312+
&& should_predicate_be_extracted(token) {
313313
result.push(FieldInfo {
314314
name: format!("is_{token}"),
315315
ty: FieldType::Predicate,
316316
});
317317
}
318-
}
319318
}
320319

321320
result.extend(get_additional_fields(&node.name));

rust/extractor/src/config.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use ra_ap_ide_db::FxHashMap;
1414
use ra_ap_intern::Symbol;
1515
use ra_ap_load_cargo::{LoadCargoConfig, ProcMacroServerChoice};
1616
use ra_ap_paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
17-
use ra_ap_project_model::{CargoConfig, CargoFeatures, CfgOverrides, RustLibSource, Sysroot, TargetDirectoryConfig};
17+
use ra_ap_project_model::{
18+
CargoConfig, CargoFeatures, CfgOverrides, RustLibSource, Sysroot, TargetDirectoryConfig,
19+
};
1820
use rust_extractor_macros::extractor_cli_config;
1921
use serde::{Deserialize, Serialize};
2022
use std::collections::HashSet;
@@ -176,7 +178,10 @@ impl Config {
176178
.clone()
177179
.unwrap_or_else(|| self.scratch_dir.join("target")),
178180
)
179-
.map_or(TargetDirectoryConfig::None, TargetDirectoryConfig::Directory),
181+
.map_or(
182+
TargetDirectoryConfig::None,
183+
TargetDirectoryConfig::Directory,
184+
),
180185
features: self.cargo_features(),
181186
target: self.cargo_target.clone(),
182187
cfg_overrides: to_cfg_overrides(&self.cargo_cfg_overrides),

rust/extractor/src/main.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ impl<'a> Extractor<'a> {
8080
translator.emit_parse_error(&ast, &err);
8181
}
8282
let no_location = (LineCol { line: 0, col: 0 }, LineCol { line: 0, col: 0 });
83-
if let Err(RustAnalyzerNoSemantics { severity, reason }) = semantics_info {
84-
if !reason.is_empty() {
83+
if let Err(RustAnalyzerNoSemantics { severity, reason }) = semantics_info
84+
&& !reason.is_empty() {
8585
let message = format!("semantic analyzer unavailable ({reason})");
8686
let full_message = format!("{message}: macro expansion will be skipped.");
8787
translator.emit_diagnostic(
@@ -92,7 +92,6 @@ impl<'a> Extractor<'a> {
9292
no_location,
9393
);
9494
}
95-
}
9695
translator.emit_source_file(&ast);
9796
translator.emit_truncated_diagnostics_message();
9897
translator.trap.commit().unwrap_or_else(|err| {
@@ -300,8 +299,8 @@ fn main() -> anyhow::Result<()> {
300299
};
301300
}
302301
for (file_id, file) in vfs.iter() {
303-
if let Some(file) = file.as_path().map(<_ as AsRef<Path>>::as_ref) {
304-
if file.extension().is_some_and(|ext| ext == "rs")
302+
if let Some(file) = file.as_path().map(<_ as AsRef<Path>>::as_ref)
303+
&& file.extension().is_some_and(|ext| ext == "rs")
305304
&& processed_files.insert(file.to_owned())
306305
&& db
307306
.source_root(db.file_source_root(file_id).source_root_id(db))
@@ -311,7 +310,6 @@ fn main() -> anyhow::Result<()> {
311310
extractor.extract_with_semantics(file, &semantics, vfs, library_mode);
312311
extractor.archiver.archive(file);
313312
}
314-
}
315313
}
316314
} else {
317315
for file in files {

rust/extractor/src/translate/base.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,13 @@ impl<'a> Translator<'a> {
215215
) {
216216
let parent_range = parent.syntax().text_range();
217217
let token_range = token.text_range();
218-
if let Some(clipped_range) = token_range.intersect(parent_range) {
219-
if let Some(parent_range2) = self.text_range_for_node(parent) {
218+
if let Some(clipped_range) = token_range.intersect(parent_range)
219+
&& let Some(parent_range2) = self.text_range_for_node(parent) {
220220
let token_range = clipped_range + parent_range2.start() - parent_range.start();
221221
if let Some((start, end)) = self.location(token_range) {
222222
self.trap.emit_location(self.label, label, start, end)
223223
}
224224
}
225-
}
226225
}
227226
pub fn emit_diagnostic(
228227
&mut self,
@@ -332,16 +331,15 @@ impl<'a> Translator<'a> {
332331
children: SyntaxElementChildren,
333332
) {
334333
for child in children {
335-
if let NodeOrToken::Token(token) = child {
336-
if token.kind() == SyntaxKind::COMMENT {
334+
if let NodeOrToken::Token(token) = child
335+
&& token.kind() == SyntaxKind::COMMENT {
337336
let label = self.trap.emit(generated::Comment {
338337
id: TrapId::Star,
339338
parent: parent_label,
340339
text: token.text().to_owned(),
341340
});
342341
self.emit_location_token(label.into(), parent_node, &token);
343342
}
344-
}
345343
}
346344
}
347345
fn emit_macro_expansion_parse_errors(
@@ -479,9 +477,10 @@ impl<'a> Translator<'a> {
479477
};
480478
let cfg_expr = ra_ap_cfg::CfgExpr::parse_from_ast(cfg_predicate);
481479
let file_id = sema.hir_file_for(item.syntax());
482-
let krate = match file_id.file_id().and_then(|fid| {
483-
sema.file_to_module_defs(fid.file_id(sema.db)).next()
484-
}) {
480+
let krate = match file_id
481+
.file_id()
482+
.and_then(|fid| sema.file_to_module_defs(fid.file_id(sema.db)).next())
483+
{
485484
Some(module) => module.krate(sema.db),
486485
None => return false,
487486
};

0 commit comments

Comments
 (0)