aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2024-09-20 17:13:38 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-19 15:32:11 +0100
commit0581e0d9a8b1e47d43f8a6477b0536392532b6d3 (patch)
tree063141e3b51b24c3f22e0efeed2ebd2fc44fdae0 /gcc/rust/hir
parentd007ce87451f75134ccf38a3d760cbdc6720e608 (diff)
downloadgcc-0581e0d9a8b1e47d43f8a6477b0536392532b6d3.zip
gcc-0581e0d9a8b1e47d43f8a6477b0536392532b6d3.tar.gz
gcc-0581e0d9a8b1e47d43f8a6477b0536392532b6d3.tar.bz2
gccrs: rust fix ICE when hir lowering qualified path expressions without an as
Qualified path expressions usually are <X as Y>::... but the as is optional this adds the extra checking in hir lowering to not hit that nullptr. Fixes #3082 gcc/rust/ChangeLog: * hir/rust-ast-lower-type.cc (ASTLowerQualifiedPathInType::visit): check for valid as segment gcc/testsuite/ChangeLog: * rust/compile/nr2/exclude: nr2 cant handle this * rust/compile/issue-3082.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-ast-lower-type.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc
index 883af4a..7d6ac5d 100644
--- a/gcc/rust/hir/rust-ast-lower-type.cc
+++ b/gcc/rust/hir/rust-ast-lower-type.cc
@@ -145,8 +145,15 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path)
HIR::Type *qual_type
= ASTLoweringType::translate (path.get_qualified_path_type ().get_type ());
- HIR::TypePath *qual_trait = ASTLowerTypePath::translate (
- path.get_qualified_path_type ().get_as_type_path ());
+
+ HIR::TypePath *qual_trait = nullptr;
+ if (!path.get_qualified_path_type ().is_error ())
+ {
+ AST::QualifiedPathType &qualifier = path.get_qualified_path_type ();
+ if (qualifier.has_as_clause ())
+ qual_trait
+ = ASTLowerTypePath::translate (qualifier.get_as_type_path ());
+ }
HIR::QualifiedPathType qual_path_type (
qual_mappings, std::unique_ptr<HIR::Type> (qual_type),