Auto merge of #12785 - Logarithmus:feature/fix-negative-const-generics, r=Veykril

fix: un-inline `ConstScalarOrPath::from_expr_opt`

Sorry, but I missed these from #12778 `@flodiebold`
This commit is contained in:
bors 2022-07-17 17:53:02 +00:00
commit 897a7ec4b8

View File

@ -411,9 +411,7 @@ fn from_expr(expr: ast::Expr) -> Self {
}
ast::Expr::PrefixExpr(prefix_expr) => match prefix_expr.op_kind() {
Some(ast::UnaryOp::Neg) => {
let unsigned = prefix_expr
.expr()
.map_or(Self::Scalar(ConstScalar::Unknown), Self::from_expr);
let unsigned = Self::from_expr_opt(prefix_expr.expr());
// Add sign
match unsigned {
Self::Scalar(ConstScalar::UInt(num)) => {
@ -422,7 +420,7 @@ fn from_expr(expr: ast::Expr) -> Self {
other => other,
}
}
_ => prefix_expr.expr().map_or(Self::Scalar(ConstScalar::Unknown), Self::from_expr),
_ => Self::from_expr_opt(prefix_expr.expr()),
},
ast::Expr::Literal(literal) => Self::Scalar(match literal.kind() {
ast::LiteralKind::IntNumber(num) => {