Skip to content

Commit 8dc275b

Browse files
committed
lower: Error out when lowering ErrorPropagationExpr
Adapt functions for lowering nodes that should never reach the lowering phase to cause an unreachable, and mark them as final so as it not possible to override them in other visitors. gcc/rust/ChangeLog: * hir/rust-ast-lower-base.cc: Adapt functions for ErrorPropagationExpr and MacroInvocation. * hir/rust-ast-lower-base.h: Mark them as final. * hir/rust-ast-lower-expr.cc: Remove previous definition for those overrides. * hir/rust-ast-lower-expr.h: Likewise.
1 parent 950a193 commit 8dc275b

File tree

4 files changed

+188
-197
lines changed

4 files changed

+188
-197
lines changed

gcc/rust/hir/rust-ast-lower-base.cc

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,29 @@
2323
#include "rust-ast.h"
2424
#include "rust-attribute-values.h"
2525
#include "rust-diagnostics.h"
26+
#include "rust-expr.h"
2627
#include "rust-item.h"
2728
#include "rust-system.h"
2829
#include "rust-attributes.h"
2930

3031
namespace Rust {
3132
namespace HIR {
3233

33-
// We special case lowering macro invocations as that should NEVER happen
3434
void
3535
ASTLoweringBase::visit (AST::MacroInvocation &invoc)
3636
{
3737
rust_fatal_error (invoc.get_locus (), "rogue macro detected during lowering");
3838
rust_unreachable ();
3939
}
4040

41+
void
42+
ASTLoweringBase::visit (AST::ErrorPropagationExpr &expr)
43+
{
44+
rust_fatal_error (expr.get_locus (),
45+
"missing desugar for question mark operator");
46+
rust_unreachable ();
47+
}
48+
4149
void
4250
ASTLoweringBase::visit (AST::Token &)
4351
{}
@@ -116,9 +124,6 @@ void
116124
ASTLoweringBase::visit (AST::DereferenceExpr &)
117125
{}
118126
void
119-
ASTLoweringBase::visit (AST::ErrorPropagationExpr &)
120-
{}
121-
void
122127
ASTLoweringBase::visit (AST::NegationExpr &)
123128
{}
124129
void

0 commit comments

Comments
 (0)