mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
Replace write! with direct calls
This commit is contained in:
parent
b594f9c441
commit
1a37b17162
13 changed files with 59 additions and 49 deletions
|
@ -43,7 +43,7 @@ impl CfgAtom {
|
|||
impl fmt::Display for CfgAtom {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
CfgAtom::Flag(name) => write!(f, "{}", name),
|
||||
CfgAtom::Flag(name) => name.fmt(f),
|
||||
CfgAtom::KeyValue { key, value } => write!(f, "{} = {:?}", key, value),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
//!
|
||||
//! This is currently both messy and inefficient. Feel free to improve, there are unit tests.
|
||||
|
||||
use std::fmt;
|
||||
use std::fmt::{self, Write};
|
||||
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
|
@ -125,17 +125,17 @@ impl DnfExpr {
|
|||
impl fmt::Display for DnfExpr {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.conjunctions.len() != 1 {
|
||||
write!(f, "any(")?;
|
||||
f.write_str("any(")?;
|
||||
}
|
||||
for (i, conj) in self.conjunctions.iter().enumerate() {
|
||||
if i != 0 {
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
|
||||
write!(f, "{}", conj)?;
|
||||
conj.fmt(f)?;
|
||||
}
|
||||
if self.conjunctions.len() != 1 {
|
||||
write!(f, ")")?;
|
||||
f.write_char(')')?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -165,17 +165,17 @@ impl Conjunction {
|
|||
impl fmt::Display for Conjunction {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if self.literals.len() != 1 {
|
||||
write!(f, "all(")?;
|
||||
f.write_str("all(")?;
|
||||
}
|
||||
for (i, lit) in self.literals.iter().enumerate() {
|
||||
if i != 0 {
|
||||
f.write_str(", ")?;
|
||||
}
|
||||
|
||||
write!(f, "{}", lit)?;
|
||||
lit.fmt(f)?;
|
||||
}
|
||||
if self.literals.len() != 1 {
|
||||
write!(f, ")")?;
|
||||
f.write_str(")")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -204,12 +204,12 @@ impl fmt::Display for Literal {
|
|||
}
|
||||
|
||||
match &self.var {
|
||||
Some(var) => write!(f, "{}", var)?,
|
||||
Some(var) => var.fmt(f)?,
|
||||
None => f.write_str("<invalid>")?,
|
||||
}
|
||||
|
||||
if self.negate {
|
||||
write!(f, ")")?;
|
||||
f.write_char(')')?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -128,7 +128,7 @@ impl fmt::Display for CfgDiff {
|
|||
};
|
||||
f.write_str(sep)?;
|
||||
|
||||
write!(f, "{}", atom)?;
|
||||
atom.fmt(f)?;
|
||||
}
|
||||
|
||||
if !self.disable.is_empty() {
|
||||
|
@ -146,7 +146,7 @@ impl fmt::Display for CfgDiff {
|
|||
};
|
||||
f.write_str(sep)?;
|
||||
|
||||
write!(f, "{}", atom)?;
|
||||
atom.fmt(f)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ impl fmt::Display for InactiveReason {
|
|||
};
|
||||
f.write_str(sep)?;
|
||||
|
||||
write!(f, "{}", atom)?;
|
||||
atom.fmt(f)?;
|
||||
}
|
||||
let is_are = if self.enabled.len() == 1 { "is" } else { "are" };
|
||||
write!(f, " {} enabled", is_are)?;
|
||||
|
@ -189,7 +189,7 @@ impl fmt::Display for InactiveReason {
|
|||
};
|
||||
f.write_str(sep)?;
|
||||
|
||||
write!(f, "{}", atom)?;
|
||||
atom.fmt(f)?;
|
||||
}
|
||||
let is_are = if self.disabled.len() == 1 { "is" } else { "are" };
|
||||
write!(f, " {} disabled", is_are)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue