mirror of
https://github.com/github/codeql.git
synced 2026-05-14 19:29:28 +02:00
Rust: update toolchain to 1.91 and apply lint fixes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,6 @@
|
||||
# reflected by `MODULE.bazel` in this repository).
|
||||
|
||||
[toolchain]
|
||||
channel = "1.88"
|
||||
channel = "1.91"
|
||||
profile = "minimal"
|
||||
components = [ "clippy", "rustfmt" ]
|
||||
|
||||
@@ -308,14 +308,13 @@ fn write_schema(
|
||||
fn get_fields(node: &AstNodeSrc) -> Vec<FieldInfo> {
|
||||
let mut result = Vec::new();
|
||||
for field in &node.fields {
|
||||
if let Field::Token { token, .. } = field {
|
||||
if should_predicate_be_extracted(token) {
|
||||
if let Field::Token { token, .. } = field
|
||||
&& should_predicate_be_extracted(token) {
|
||||
result.push(FieldInfo {
|
||||
name: format!("is_{token}"),
|
||||
ty: FieldType::Predicate,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result.extend(get_additional_fields(&node.name));
|
||||
|
||||
@@ -14,7 +14,9 @@ use ra_ap_ide_db::FxHashMap;
|
||||
use ra_ap_intern::Symbol;
|
||||
use ra_ap_load_cargo::{LoadCargoConfig, ProcMacroServerChoice};
|
||||
use ra_ap_paths::{AbsPath, AbsPathBuf, Utf8PathBuf};
|
||||
use ra_ap_project_model::{CargoConfig, CargoFeatures, CfgOverrides, RustLibSource, Sysroot, TargetDirectoryConfig};
|
||||
use ra_ap_project_model::{
|
||||
CargoConfig, CargoFeatures, CfgOverrides, RustLibSource, Sysroot, TargetDirectoryConfig,
|
||||
};
|
||||
use rust_extractor_macros::extractor_cli_config;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
@@ -176,7 +178,10 @@ impl Config {
|
||||
.clone()
|
||||
.unwrap_or_else(|| self.scratch_dir.join("target")),
|
||||
)
|
||||
.map_or(TargetDirectoryConfig::None, TargetDirectoryConfig::Directory),
|
||||
.map_or(
|
||||
TargetDirectoryConfig::None,
|
||||
TargetDirectoryConfig::Directory,
|
||||
),
|
||||
features: self.cargo_features(),
|
||||
target: self.cargo_target.clone(),
|
||||
cfg_overrides: to_cfg_overrides(&self.cargo_cfg_overrides),
|
||||
|
||||
@@ -80,8 +80,8 @@ impl<'a> Extractor<'a> {
|
||||
translator.emit_parse_error(&ast, &err);
|
||||
}
|
||||
let no_location = (LineCol { line: 0, col: 0 }, LineCol { line: 0, col: 0 });
|
||||
if let Err(RustAnalyzerNoSemantics { severity, reason }) = semantics_info {
|
||||
if !reason.is_empty() {
|
||||
if let Err(RustAnalyzerNoSemantics { severity, reason }) = semantics_info
|
||||
&& !reason.is_empty() {
|
||||
let message = format!("semantic analyzer unavailable ({reason})");
|
||||
let full_message = format!("{message}: macro expansion will be skipped.");
|
||||
translator.emit_diagnostic(
|
||||
@@ -92,7 +92,6 @@ impl<'a> Extractor<'a> {
|
||||
no_location,
|
||||
);
|
||||
}
|
||||
}
|
||||
translator.emit_source_file(&ast);
|
||||
translator.emit_truncated_diagnostics_message();
|
||||
translator.trap.commit().unwrap_or_else(|err| {
|
||||
@@ -300,8 +299,8 @@ fn main() -> anyhow::Result<()> {
|
||||
};
|
||||
}
|
||||
for (file_id, file) in vfs.iter() {
|
||||
if let Some(file) = file.as_path().map(<_ as AsRef<Path>>::as_ref) {
|
||||
if file.extension().is_some_and(|ext| ext == "rs")
|
||||
if let Some(file) = file.as_path().map(<_ as AsRef<Path>>::as_ref)
|
||||
&& file.extension().is_some_and(|ext| ext == "rs")
|
||||
&& processed_files.insert(file.to_owned())
|
||||
&& db
|
||||
.source_root(db.file_source_root(file_id).source_root_id(db))
|
||||
@@ -311,7 +310,6 @@ fn main() -> anyhow::Result<()> {
|
||||
extractor.extract_with_semantics(file, &semantics, vfs, library_mode);
|
||||
extractor.archiver.archive(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for file in files {
|
||||
|
||||
@@ -215,14 +215,13 @@ impl<'a> Translator<'a> {
|
||||
) {
|
||||
let parent_range = parent.syntax().text_range();
|
||||
let token_range = token.text_range();
|
||||
if let Some(clipped_range) = token_range.intersect(parent_range) {
|
||||
if let Some(parent_range2) = self.text_range_for_node(parent) {
|
||||
if let Some(clipped_range) = token_range.intersect(parent_range)
|
||||
&& let Some(parent_range2) = self.text_range_for_node(parent) {
|
||||
let token_range = clipped_range + parent_range2.start() - parent_range.start();
|
||||
if let Some((start, end)) = self.location(token_range) {
|
||||
self.trap.emit_location(self.label, label, start, end)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
pub fn emit_diagnostic(
|
||||
&mut self,
|
||||
@@ -332,8 +331,8 @@ impl<'a> Translator<'a> {
|
||||
children: SyntaxElementChildren,
|
||||
) {
|
||||
for child in children {
|
||||
if let NodeOrToken::Token(token) = child {
|
||||
if token.kind() == SyntaxKind::COMMENT {
|
||||
if let NodeOrToken::Token(token) = child
|
||||
&& token.kind() == SyntaxKind::COMMENT {
|
||||
let label = self.trap.emit(generated::Comment {
|
||||
id: TrapId::Star,
|
||||
parent: parent_label,
|
||||
@@ -341,7 +340,6 @@ impl<'a> Translator<'a> {
|
||||
});
|
||||
self.emit_location_token(label.into(), parent_node, &token);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fn emit_macro_expansion_parse_errors(
|
||||
@@ -479,9 +477,10 @@ impl<'a> Translator<'a> {
|
||||
};
|
||||
let cfg_expr = ra_ap_cfg::CfgExpr::parse_from_ast(cfg_predicate);
|
||||
let file_id = sema.hir_file_for(item.syntax());
|
||||
let krate = match file_id.file_id().and_then(|fid| {
|
||||
sema.file_to_module_defs(fid.file_id(sema.db)).next()
|
||||
}) {
|
||||
let krate = match file_id
|
||||
.file_id()
|
||||
.and_then(|fid| sema.file_to_module_defs(fid.file_id(sema.db)).next())
|
||||
{
|
||||
Some(module) => module.krate(sema.db),
|
||||
None => return false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user