File tree Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Expand file tree Collapse file tree 2 files changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -626,6 +626,8 @@ impl TypedAstContext {
626
626
627
627
/// Pessimistically try to check if an expression is `const`.
628
628
/// If it's not, or we can't tell if it is, return `false`.
629
+ ///
630
+ /// This should be a top-down, complete, pessimistic analysis.
629
631
pub fn is_const_expr ( & self , expr : CExprId ) -> bool {
630
632
let is_const = |expr| self . is_const_expr ( expr) ;
631
633
Original file line number Diff line number Diff line change @@ -2128,6 +2128,13 @@ impl<'c> Translation<'c> {
2128
2128
TranslateMacros :: Conservative => {
2129
2129
// TODO We still allow `CExprKind::ExplicitCast`s
2130
2130
// even though they're broken (see #853).
2131
+
2132
+ // This is a top-down, complete, pessimistic/conservative analysis.
2133
+ // This is somewhat duplicative of `fn convert_expr` simply checking
2134
+ // `ExprContext::is_const` and returning errors where the expr is not `const`,
2135
+ // which is an incomplete analysis scattered across all of the `fn expr_*`s.
2136
+ // That's what's done for `TranslateMacros::Experimental`,
2137
+ // as opposed to the conservative analysis done here for `TranslateMacros::Conservative`.
2131
2138
if !self . ast_context . is_const_expr ( expr_id) {
2132
2139
Err ( format_err ! ( "non-const expr {expr_id:?}" ) ) ?;
2133
2140
}
You can’t perform that action at this time.
0 commit comments