diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-09-14 10:23:46 +0200 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2022-09-14 10:27:51 +0200 |
commit | d4da06f721577d3eaf2e21d6c6735d32a69d6ac7 (patch) | |
tree | aeb66d7f6e8c1d182e150ca8e5356a5fb5f144ae /gcc/rust | |
parent | f252b4093666cf1e3d948b22f00fc12bf283a83f (diff) | |
download | gcc-d4da06f721577d3eaf2e21d6c6735d32a69d6ac7.zip gcc-d4da06f721577d3eaf2e21d6c6735d32a69d6ac7.tar.gz gcc-d4da06f721577d3eaf2e21d6c6735d32a69d6ac7.tar.bz2 |
module lowering: Do not append null pointers as items
Some module items do not need to get lowered to HIR such as `macro_rules!` definitions. Hence, module lowering should act the same as crate lowering: Only emplace back the lowered item if it is a valid pointer
Diffstat (limited to 'gcc/rust')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-item.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-item.cc b/gcc/rust/hir/rust-ast-lower-item.cc index fefc938..336be5b 100644 --- a/gcc/rust/hir/rust-ast-lower-item.cc +++ b/gcc/rust/hir/rust-ast-lower-item.cc @@ -59,7 +59,10 @@ ASTLoweringItem::visit (AST::Module &module) for (auto &item : module.get_items ()) { auto transitem = translate (item.get ()); - items.push_back (std::unique_ptr<Item> (transitem)); + // The item may be null if it doesn't need to live in the HIR - for + // example, macro rules definitions + if (transitem) + items.push_back (std::unique_ptr<Item> (transitem)); } // should be lowered/copied from module.get_in/outer_attrs() |