Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ insta = { version = "1.47", features = ["yaml", "redactions"] }
strip = "debuginfo" # Removes heavy debug data but keeps function names for panic logs
lto = true # Enables Link-Time Optimization for cross-crate improvements
codegen-units = 1 # Maximizes LLVM optimization passes

[lints.clippy]
pedantic = "warn"
3 changes: 2 additions & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ fn main() {
let path = Path::new(path);
assert!(
path.is_absolute(),
"Environment variable FALLBACK_INCLUDE_PATH must be absolute: {path:?}"
"Environment variable FALLBACK_INCLUDE_PATH must be absolute: {}",
path.display()
);
}
}
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl Cli {
///
/// This method collects all values from the `--include-paths` flags (including
/// multiple occurrences and comma-separated values) and converts them into
/// a vector of [std::path::PathBuf]. Returns an empty vector if no paths are provided.
/// a vector of [`std::path::PathBuf`]. Returns an empty vector if no paths are provided.
pub fn get_include_paths(&self) -> Vec<std::path::PathBuf> {
self.include_paths
.as_ref()
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions src/config/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl WorkspaceProtoConfigs {
let p = Path::new(&wpath).join(file);
match std::fs::exists(&p) {
Ok(exists) if exists => return Some(p),
_ => continue,
_ => {}
}
}
None
Expand Down Expand Up @@ -128,7 +128,7 @@ impl WorkspaceProtoConfigs {
}
}

ipath.push(w.to_path_buf());
ipath.push(w.clone());
ipath.extend_from_slice(&self.protoc_include_prefix);
ipath.extend_from_slice(self.fallback_include_path.as_slice());
Some(ipath)
Expand All @@ -145,7 +145,7 @@ impl WorkspaceProtoConfigs {
if let Ok(cdir) = env::current_dir()
&& let Some(drive) = cdir.components().next()
{
d = drive.as_os_str().to_string_lossy().to_string()
d = drive.as_os_str().to_string_lossy().to_string();
}
format!("{d}://")
} else {
Expand Down
21 changes: 10 additions & 11 deletions src/formatter/clang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl Replacement<'_> {
let character = text_after_newline.encode_utf16().count();

Some(Position {
line: line as u32,
character: character as u32,
line: u32::try_from(line).ok()?,
character: u32::try_from(character).ok()?,
})
}

Expand Down Expand Up @@ -104,7 +104,7 @@ impl ClangFormatter {
Some(c)
}

fn output_to_textedit(&self, output: &str, content: &str) -> Option<Vec<TextEdit>> {
fn output_to_textedit(output: &str, content: &str) -> Option<Vec<TextEdit>> {
let r = Replacements::from_str(output).ok()?;
let edits = r
.replacements
Expand All @@ -128,7 +128,7 @@ impl ProtoFormatter for ClangFormatter {
);
return None;
}
self.output_to_textedit(&String::from_utf8_lossy(&output.stdout), content)
Self::output_to_textedit(&String::from_utf8_lossy(&output.stdout), content)
}

fn format_document_range(
Expand All @@ -153,7 +153,7 @@ impl ProtoFormatter for ClangFormatter {
);
return None;
}
self.output_to_textedit(&String::from_utf8_lossy(&output.stdout), content)
Self::output_to_textedit(&String::from_utf8_lossy(&output.stdout), content)
}
}

Expand Down Expand Up @@ -185,7 +185,7 @@ mod test {
for i in pos {
with_settings!({description => c, info => &i}, {
assert_yaml_snapshot!(Replacement::offset_to_position(i, c));
})
});
}
}

Expand All @@ -199,7 +199,7 @@ mod test {
for i in pos {
with_settings!({description => c, info => &i}, {
assert_yaml_snapshot!(Replacement::offset_to_position(i, c));
})
});
}
}

Expand All @@ -220,12 +220,11 @@ mod test {
.find(target)
.expect("Could not find target in content");
let xml_output = format!(
r#"<?xml version='1.0'?>
r"<?xml version='1.0'?>
<replacements xml:space='preserve' incomplete_format='false'>
<replacement offset='{}' length='1'>
<replacement offset='{offset}' length='1'>
// </replacement>
</replacements>"#,
offset
</replacements>"
);

let r = Replacements::from_str(&xml_output).unwrap();
Expand Down
20 changes: 9 additions & 11 deletions src/log.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use async_lsp::lsp_types::{LogMessageParams, MessageType, TraceValue};
use std::fmt::Write;
use tokio::sync::mpsc;
use tracing::{
Level, Subscriber,
Expand Down Expand Up @@ -26,19 +27,17 @@ impl Visit for MessageVisitor {
if field.name() == "message" {
self.message.push_str(value);
} else {
self.fields
.push_str(&format!(" {}={}", field.name(), value));
let _ = write!(self.fields, " {}={value}", field.name());
}
}

fn record_debug(&mut self, field: &Field, value: &dyn std::fmt::Debug) {
if field.name() == "message" {
if self.message.is_empty() {
self.message = format!("{:?}", value);
self.message = format!("{value:?}");
}
} else {
self.fields
.push_str(&format!(" {}={:?}", field.name(), value));
let _ = write!(self.fields, " {}={value:?}", field.name());
}
}
}
Expand Down Expand Up @@ -75,13 +74,12 @@ impl<S: Subscriber> Layer<S> for ClientLogger {
format!("{} | fields:{}", visitor.message, visitor.fields)
};

let message = format!("[{}] {}", target, full_text);
let message = format!("[{target}] {full_text}");

let typ = match *metadata.level() {
tracing::Level::ERROR => MessageType::ERROR,
tracing::Level::WARN => MessageType::WARNING,
tracing::Level::INFO => MessageType::INFO,
tracing::Level::DEBUG => MessageType::LOG,
_ => MessageType::LOG,
};

Expand All @@ -108,7 +106,7 @@ pub fn install(tx: mpsc::Sender<LogMessageParams>) -> (LogReloadHandle, WorkerGu
let lsp_layer = ClientLogger { tx };

let dir = std::env::temp_dir();
eprintln!("file logging at directory: {dir:?}");
eprintln!("file logging at directory: {}", dir.display());
let file_appender = tracing_appender::rolling::daily(dir, "protols.log");
let (non_blocking, guard) = tracing_appender::non_blocking(file_appender);

Expand Down Expand Up @@ -150,7 +148,7 @@ pub fn update_level(handle: &LogReloadHandle, value: TraceValue) {

// Construct directives: "warn" for the whole world, "pkg=level" for us
let global_directive = Level::WARN.into();
let pkg_directive = format!("{}={}", pkg_name, level)
let pkg_directive = format!("{pkg_name}={level}")
.parse::<Directive>()
.expect("Failed to parse log directive");

Expand Down Expand Up @@ -190,10 +188,10 @@ mod tests {

assert!(msg.message.contains(MESSAGE));

let expected_field = format!("{}={}", field_name, field_value);
let expected_field = format!("{field_name}={field_value}");
assert!(msg.message.contains(&expected_field));

assert!(msg.message.contains(&format!("[{}]", TARGET)));
assert!(msg.message.contains(&format!("[{TARGET}]")));
}

#[test]
Expand Down
Loading