Simplify printf and shell format suggestions
This commit is contained in:
parent
30f168ef81
commit
2458ccd1f9
2 changed files with 11 additions and 9 deletions
|
@ -711,11 +711,9 @@ fn report_missing_placeholders(
|
||||||
};
|
};
|
||||||
|
|
||||||
let pos = sub.position();
|
let pos = sub.position();
|
||||||
let sub = String::from(sub.as_str());
|
if !explained.insert(sub.to_string()) {
|
||||||
if explained.contains(&sub) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
explained.insert(sub);
|
|
||||||
|
|
||||||
if !found_foreign {
|
if !found_foreign {
|
||||||
found_foreign = true;
|
found_foreign = true;
|
||||||
|
|
|
@ -12,14 +12,16 @@ pub(crate) mod printf {
|
||||||
Escape((usize, usize)),
|
Escape((usize, usize)),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Substitution<'a> {
|
impl ToString for Substitution<'_> {
|
||||||
pub(crate) fn as_str(&self) -> &str {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.span,
|
Substitution::Format(fmt) => fmt.span.into(),
|
||||||
Substitution::Escape(_) => "%%",
|
Substitution::Escape(_) => "%%".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Substitution<'_> {
|
||||||
pub(crate) fn position(&self) -> InnerSpan {
|
pub(crate) fn position(&self) -> InnerSpan {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Format(fmt) => fmt.position,
|
Substitution::Format(fmt) => fmt.position,
|
||||||
|
@ -627,15 +629,17 @@ pub(crate) mod shell {
|
||||||
Escape((usize, usize)),
|
Escape((usize, usize)),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Substitution<'_> {
|
impl ToString for Substitution<'_> {
|
||||||
pub(crate) fn as_str(&self) -> String {
|
fn to_string(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Substitution::Ordinal(n, _) => format!("${n}"),
|
Substitution::Ordinal(n, _) => format!("${n}"),
|
||||||
Substitution::Name(n, _) => format!("${n}"),
|
Substitution::Name(n, _) => format!("${n}"),
|
||||||
Substitution::Escape(_) => "$$".into(),
|
Substitution::Escape(_) => "$$".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Substitution<'_> {
|
||||||
pub(crate) fn position(&self) -> InnerSpan {
|
pub(crate) fn position(&self) -> InnerSpan {
|
||||||
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
|
||||||
InnerSpan::new(pos.0, pos.1)
|
InnerSpan::new(pos.0, pos.1)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue