Emit simpler code from format_args

This commit is contained in:
David Tolnay 2021-11-28 10:46:06 -08:00
parent ee5d8d37ba
commit abf1d94b1a
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
9 changed files with 112 additions and 92 deletions

View file

@ -39,6 +39,7 @@ use rustc_span::{Span, DUMMY_SP};
use std::cmp::Ordering;
use std::convert::TryFrom;
use std::fmt;
use std::mem;
#[cfg(test)]
mod tests;
@ -1276,6 +1277,19 @@ impl Expr {
ExprKind::Err => ExprPrecedence::Err,
}
}
pub fn take(&mut self) -> Self {
mem::replace(
self,
Expr {
id: DUMMY_NODE_ID,
kind: ExprKind::Err,
span: DUMMY_SP,
attrs: ThinVec::new(),
tokens: None,
},
)
}
}
/// Limit types of a range (inclusive or exclusive)