Skip to content

Commit a760b89

Browse files
author
Paolo Tranquilli
committed
Rust: small tweaks
1 parent 5230b7b commit a760b89

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

rust/extractor/src/rust_analyzer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ pub fn find_project_manifests(
120120
.collect();
121121
let ret = ra_ap_project_model::ProjectManifest::discover_all(&abs_files);
122122
let iter = || ret.iter().map(|m| format!(" {m}"));
123-
const log_limit: usize = 10;
124-
if ret.len() <= log_limit {
123+
const LOG_LIMIT: usize = 10;
124+
if ret.len() <= LOG_LIMIT {
125125
info!("found manifests:\n{}", iter().join("\n"));
126126
} else {
127127
info!(
128128
"found manifests:\n{}\nand {} more",
129-
iter().take(log_limit).join("\n"),
130-
ret.len() - log_limit
129+
iter().take(LOG_LIMIT).join("\n"),
130+
ret.len() - LOG_LIMIT
131131
);
132132
debug!(
133133
"rest of the manifests found:\n{}",
134-
iter().dropping(log_limit).join("\n")
134+
iter().dropping(LOG_LIMIT).join("\n")
135135
);
136136
}
137137
Ok(ret)

rust/extractor/src/translate/base.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ impl<'a> Translator<'a> {
169169
pub fn emit_diagnostic(
170170
&mut self,
171171
severity: DiagnosticSeverity,
172-
error_tag: String,
173-
error_message: String,
174-
full_error_message: String,
172+
tag: String,
173+
message: String,
174+
full_message: String,
175175
location: (LineCol, LineCol),
176176
) {
177177
let (start, end) = location;
@@ -187,17 +187,12 @@ impl<'a> Translator<'a> {
187187
self.path,
188188
start.line + 1,
189189
start.col + 1,
190-
&error_message
190+
&message
191191
);
192-
if severity != DiagnosticSeverity::Debug {
192+
if severity > DiagnosticSeverity::Debug {
193193
let location = self.trap.emit_location_label(self.label, start, end);
194-
self.trap.emit_diagnostic(
195-
severity,
196-
error_tag,
197-
error_message,
198-
full_error_message,
199-
location,
200-
);
194+
self.trap
195+
.emit_diagnostic(severity, tag, message, full_message, location);
201196
}
202197
}
203198
pub fn emit_parse_error(&mut self, owner: &impl ast::AstNode, err: &SyntaxError) {

rust/extractor/src/trap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ pub struct TrapFile {
128128
compression: Compression,
129129
}
130130

131-
#[derive(Copy, Clone, PartialEq, Eq)]
131+
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
132132
pub enum DiagnosticSeverity {
133133
Debug = 10,
134134
Info = 20,

0 commit comments

Comments
 (0)