Handle macro calls in anon const def creation take 2
This commit is contained in:
parent
1d68e6dd1d
commit
781ec111b7
15 changed files with 210 additions and 28 deletions
|
@ -1187,8 +1187,8 @@ impl Expr {
|
|||
/// `min_const_generics` as more complex expressions are not supported.
|
||||
///
|
||||
/// Does not ensure that the path resolves to a const param, the caller should check this.
|
||||
pub fn is_potential_trivial_const_arg(&self) -> bool {
|
||||
let this = self.maybe_unwrap_block();
|
||||
pub fn is_potential_trivial_const_arg(&self, strip_identity_block: bool) -> bool {
|
||||
let this = if strip_identity_block { self.maybe_unwrap_block().1 } else { self };
|
||||
|
||||
if let ExprKind::Path(None, path) = &this.kind
|
||||
&& path.is_potential_trivial_const_arg()
|
||||
|
@ -1199,14 +1199,15 @@ impl Expr {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn maybe_unwrap_block(&self) -> &Expr {
|
||||
/// Returns an expression with (when possible) *one* outter brace removed
|
||||
pub fn maybe_unwrap_block(&self) -> (bool, &Expr) {
|
||||
if let ExprKind::Block(block, None) = &self.kind
|
||||
&& let [stmt] = block.stmts.as_slice()
|
||||
&& let StmtKind::Expr(expr) = &stmt.kind
|
||||
{
|
||||
expr
|
||||
(true, expr)
|
||||
} else {
|
||||
self
|
||||
(false, self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue