mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
Code review feedback.
This commit is contained in:
parent
b5c194f3f7
commit
b3a7953cae
1 changed files with 16 additions and 15 deletions
|
@ -319,13 +319,13 @@ impl CargoActor {
|
|||
|
||||
read_at_least_one_message = true;
|
||||
|
||||
// Try to deserialize a message from Cargo.
|
||||
{
|
||||
// Try to deserialize a message from Cargo or Rustc.
|
||||
let mut deserializer = serde_json::Deserializer::from_str(&message);
|
||||
deserializer.disable_recursion_limit();
|
||||
if let Ok(message) = cargo_metadata::Message::deserialize(&mut deserializer) {
|
||||
// Skip certain kinds of messages to only spend time on what's useful
|
||||
if let Ok(message) = JsonMessage::deserialize(&mut deserializer) {
|
||||
match message {
|
||||
// Skip certain kinds of messages to only spend time on what's useful
|
||||
JsonMessage::Cargo(message) => match message {
|
||||
cargo_metadata::Message::CompilerArtifact(artifact) if !artifact.fresh => {
|
||||
self.sender.send(CargoMessage::CompilerArtifact(artifact)).unwrap()
|
||||
}
|
||||
|
@ -338,19 +338,13 @@ impl CargoActor {
|
|||
| cargo_metadata::Message::BuildFinished(_)
|
||||
| cargo_metadata::Message::TextLine(_)
|
||||
| _ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try to deserialize a Diagnostic directly from Rustc.
|
||||
{
|
||||
let mut deserializer = serde_json::Deserializer::from_str(&message);
|
||||
deserializer.disable_recursion_limit();
|
||||
if let Ok(message) = Diagnostic::deserialize(&mut deserializer) {
|
||||
},
|
||||
JsonMessage::Rustc(message) => {
|
||||
self.sender.send(CargoMessage::Diagnostic(message)).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(read_at_least_one_message)
|
||||
}
|
||||
}
|
||||
|
@ -359,3 +353,10 @@ enum CargoMessage {
|
|||
CompilerArtifact(cargo_metadata::Artifact),
|
||||
Diagnostic(Diagnostic),
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(untagged)]
|
||||
enum JsonMessage {
|
||||
Cargo(cargo_metadata::Message),
|
||||
Rustc(Diagnostic),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue