diff options
author | Philip Herron <herron.philip@googlemail.com> | 2025-01-21 17:19:13 +0000 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2025-03-24 13:06:54 +0100 |
commit | aa0255591592df1a94f1956737f30b434962dc99 (patch) | |
tree | 1c36be7b3a37b992b189a0c1a78b33827c262d85 | |
parent | 34ef64d94488c44810b652ed523502b47fb4a46b (diff) | |
download | gcc-aa0255591592df1a94f1956737f30b434962dc99.zip gcc-aa0255591592df1a94f1956737f30b434962dc99.tar.gz gcc-aa0255591592df1a94f1956737f30b434962dc99.tar.bz2 |
gccrs: catch missing guard for optional result
When we lookup here it returns an optional which can lead to a crash
because it needs a guard if it has a value.
gcc/rust/ChangeLog:
* backend/rust-compile-resolve-path.cc (HIRCompileBase::query_compile): add guard
gcc/testsuite/ChangeLog:
* rust/compile/nr2/exclude: these tests now work it seems
Signed-off-by: Philip Herron <herron.philip@googlemail.com>
-rw-r--r-- | gcc/rust/backend/rust-compile-resolve-path.cc | 7 | ||||
-rw-r--r-- | gcc/testsuite/rust/compile/nr2/exclude | 2 |
2 files changed, 2 insertions, 7 deletions
diff --git a/gcc/rust/backend/rust-compile-resolve-path.cc b/gcc/rust/backend/rust-compile-resolve-path.cc index 69599cc..d248ee2 100644 --- a/gcc/rust/backend/rust-compile-resolve-path.cc +++ b/gcc/rust/backend/rust-compile-resolve-path.cc @@ -248,12 +248,9 @@ HIRCompileBase::query_compile (HirId ref, TyTy::BaseType *lookup, return CompileInherentImplItem::Compile (resolved_item->first, ctx, lookup, true, expr_locus); } - else + else if (auto trait_item + = ctx->get_mappings ().lookup_hir_trait_item (ref)) { - // it might be resolved to a trait item - tl::optional<HIR::TraitItem *> trait_item - = ctx->get_mappings ().lookup_hir_trait_item (ref); - HIR::Trait *trait = ctx->get_mappings ().lookup_trait_item_mapping ( trait_item.value ()->get_mappings ().get_hirid ()); diff --git a/gcc/testsuite/rust/compile/nr2/exclude b/gcc/testsuite/rust/compile/nr2/exclude index 5cc7cf7..8bcc8ae 100644 --- a/gcc/testsuite/rust/compile/nr2/exclude +++ b/gcc/testsuite/rust/compile/nr2/exclude @@ -63,7 +63,6 @@ macros/mbe/macro23.rs macros/mbe/macro40.rs macros/mbe/macro43.rs macros/mbe/macro44.rs -macros/mbe/macro50.rs macros/mbe/macro54.rs macros/mbe/macro6.rs macros/mbe/macro_rules_macro_rules.rs @@ -141,7 +140,6 @@ issue-2423.rs issue-266.rs additional-trait-bounds2.rs auto_traits2.rs -auto_traits4.rs issue-3140.rs cmp1.rs derive_clone_enum1.rs |