summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_builtin_macros/src/format_foreign.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:25 +0000
commit5363f350887b1e5b5dd21a86f88c8af9d7fea6da (patch)
tree35ca005eb6e0e9a1ba3bb5dbc033209ad445dc17 /compiler/rustc_builtin_macros/src/format_foreign.rs
parentAdding debian version 1.66.0+dfsg1-1. (diff)
downloadrustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.tar.xz
rustc-5363f350887b1e5b5dd21a86f88c8af9d7fea6da.zip
Merging upstream version 1.67.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_builtin_macros/src/format_foreign.rs')
-rw-r--r--compiler/rustc_builtin_macros/src/format_foreign.rs34
1 files changed, 14 insertions, 20 deletions
diff --git a/compiler/rustc_builtin_macros/src/format_foreign.rs b/compiler/rustc_builtin_macros/src/format_foreign.rs
index ecd16736e..6f7fc3a95 100644
--- a/compiler/rustc_builtin_macros/src/format_foreign.rs
+++ b/compiler/rustc_builtin_macros/src/format_foreign.rs
@@ -13,23 +13,23 @@ pub(crate) mod printf {
impl<'a> Substitution<'a> {
pub fn as_str(&self) -> &str {
- match *self {
- Substitution::Format(ref fmt) => fmt.span,
+ match self {
+ Substitution::Format(fmt) => fmt.span,
Substitution::Escape(_) => "%%",
}
}
pub fn position(&self) -> Option<InnerSpan> {
- match *self {
- Substitution::Format(ref fmt) => Some(fmt.position),
- Substitution::Escape((start, end)) => Some(InnerSpan::new(start, end)),
+ match self {
+ Substitution::Format(fmt) => Some(fmt.position),
+ &Substitution::Escape((start, end)) => Some(InnerSpan::new(start, end)),
}
}
pub fn set_position(&mut self, start: usize, end: usize) {
match self {
- Substitution::Format(ref mut fmt) => fmt.position = InnerSpan::new(start, end),
- Substitution::Escape(ref mut pos) => *pos = (start, end),
+ Substitution::Format(fmt) => fmt.position = InnerSpan::new(start, end),
+ Substitution::Escape(pos) => *pos = (start, end),
}
}
@@ -38,8 +38,8 @@ pub(crate) mod printf {
/// This ignores cases where the substitution does not have an exact equivalent, or where
/// the substitution would be unnecessary.
pub fn translate(&self) -> Result<String, Option<String>> {
- match *self {
- Substitution::Format(ref fmt) => fmt.translate(),
+ match self {
+ Substitution::Format(fmt) => fmt.translate(),
Substitution::Escape(_) => Err(None),
}
}
@@ -635,23 +635,17 @@ pub mod shell {
}
pub fn position(&self) -> Option<InnerSpan> {
- match self {
- Substitution::Ordinal(_, pos)
- | Substitution::Name(_, pos)
- | Substitution::Escape(pos) => Some(InnerSpan::new(pos.0, pos.1)),
- }
+ let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
+ Some(InnerSpan::new(pos.0, pos.1))
}
pub fn set_position(&mut self, start: usize, end: usize) {
- match self {
- Substitution::Ordinal(_, ref mut pos)
- | Substitution::Name(_, ref mut pos)
- | Substitution::Escape(ref mut pos) => *pos = (start, end),
- }
+ let (Self::Ordinal(_, pos) | Self::Name(_, pos) | Self::Escape(pos)) = self;
+ *pos = (start, end);
}
pub fn translate(&self) -> Result<String, Option<String>> {
- match *self {
+ match self {
Substitution::Ordinal(n, _) => Ok(format!("{{{}}}", n)),
Substitution::Name(n, _) => Ok(format!("{{{}}}", n)),
Substitution::Escape(_) => Err(None),