mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 04:23:25 +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.
|
||||
{
|
||||
let mut deserializer = serde_json::Deserializer::from_str(&message);
|
||||
deserializer.disable_recursion_limit();
|
||||
if let Ok(message) = cargo_metadata::Message::deserialize(&mut deserializer) {
|
||||
// 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) = JsonMessage::deserialize(&mut deserializer) {
|
||||
match message {
|
||||
// Skip certain kinds of messages to only spend time on what's useful
|
||||
match message {
|
||||
JsonMessage::Cargo(message) => match message {
|
||||
cargo_metadata::Message::CompilerArtifact(artifact) if !artifact.fresh => {
|
||||
self.sender.send(CargoMessage::CompilerArtifact(artifact)).unwrap()
|
||||
}
|
||||
|
@ -338,18 +338,12 @@ impl CargoActor {
|
|||
| cargo_metadata::Message::BuildFinished(_)
|
||||
| cargo_metadata::Message::TextLine(_)
|
||||
| _ => (),
|
||||
},
|
||||
JsonMessage::Rustc(message) => {
|
||||
self.sender.send(CargoMessage::Diagnostic(message)).unwrap()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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) {
|
||||
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