aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2021-11-16 17:05:40 +0000
committerPhilip Herron <philip.herron@embecosm.com>2021-11-17 16:16:20 +0000
commit2547e60d2fca2a323a1b16e04c595aeeec598bc1 (patch)
tree13db0ace4e0315564d028ac4f8c77c31661a2e3e
parent5514d9cec51d5ec7cc30dd6cdbfadfdddbe0aab3 (diff)
downloadgcc-2547e60d2fca2a323a1b16e04c595aeeec598bc1.zip
gcc-2547e60d2fca2a323a1b16e04c595aeeec598bc1.tar.gz
gcc-2547e60d2fca2a323a1b16e04c595aeeec598bc1.tar.bz2
Fix ICE assertion on bad duplicate name
This fixes the ice for TypeNoBounds canonical paths for reference types which was not implemented resulting in empty paths for the canonical path of impl_blocks for example. A Fixme has been added to point out that we should update this interface to only take AST::TypeNoBounds. Fixes #808
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-type.h3
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc18
2 files changed, 21 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h b/gcc/rust/resolve/rust-ast-resolve-type.h
index 838d173..2bcf79d 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -101,6 +101,7 @@ protected:
using Rust::Resolver::ResolverBase::visit;
public:
+ // FIXME this should really only take AST::TypeNoBounds&
static CanonicalPath resolve (AST::Type &type,
bool include_generic_args = true,
bool type_resolve_generic_args = true)
@@ -121,6 +122,8 @@ public:
}
}
+ void visit (AST::ReferenceType &ref) override;
+
void visit (AST::TypePathSegmentGeneric &seg) override;
void visit (AST::TypePathSegment &seg) override;
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 921b77c..45daa02 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -481,6 +481,24 @@ ResolveTypeToCanonicalPath::visit (AST::TypePathSegment &seg)
result = result.append (ident_seg);
}
+void
+ResolveTypeToCanonicalPath::visit (AST::ReferenceType &ref)
+{
+ auto inner_type
+ = ResolveTypeToCanonicalPath::resolve (*ref.get_type_referenced ().get (),
+ include_generic_args_flag,
+ type_resolve_generic_args_flag);
+
+ std::string segment_string ("&");
+ if (ref.get_has_mut ())
+ segment_string += "mut ";
+
+ segment_string += inner_type.get ();
+
+ auto ident_seg = CanonicalPath::new_seg (ref.get_node_id (), segment_string);
+ result = result.append (ident_seg);
+}
+
// rust-ast-resolve-expr.h
void