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 @@ -2140,6 +2140,13 @@ impl<'c> Translation<'c> {
2140
2140
TranslateMacros :: Conservative => {
2141
2141
// TODO We still allow `CExprKind::ExplicitCast`s
2142
2142
// even though they're broken (see #853).
2143
+
2144
+ // This is a top-down, complete, pessimistic/conservative analysis.
2145
+ // This is somewhat duplicative of `fn convert_expr` simply checking
2146
+ // `ExprContext::is_const` and returning errors where the expr is not `const`,
2147
+ // which is an incomplete analysis scattered across all of the `fn expr_*`s.
2148
+ // That's what's done for `TranslateMacros::Experimental`,
2149
+ // as opposed to the conservative analysis done here for `TranslateMacros::Conservative`.
2143
2150
if !self . ast_context . is_const_expr ( expr_id) {
2144
2151
Err ( format_err ! ( "non-const expr {expr_id:?}" ) ) ?;
2145
2152
}
You can’t perform that action at this time.
0 commit comments