diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-08-10 12:39:01 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-08-10 12:46:26 +0100 |
commit | 226f2e4f13414e702b31f89ddf8176a9c916fee8 (patch) | |
tree | 3e1214d1140498353e483a2bbc182e669ecdd803 /gcc/rust/resolve/rust-ast-resolve.cc | |
parent | 5e723d0b7a85d109f01196b264a25823e77496e1 (diff) | |
download | gcc-226f2e4f13414e702b31f89ddf8176a9c916fee8.zip gcc-226f2e4f13414e702b31f89ddf8176a9c916fee8.tar.gz gcc-226f2e4f13414e702b31f89ddf8176a9c916fee8.tar.bz2 |
Make insert_new_definition permissive of the same mapping.
Definition provide child-parent relation ships within the name scope. This
was used for let stmts such that the let stmt pattern can reference its
parent during type-resolution/code-generation such that we can lookup
the parent mappings for typing etc.
It should be permissive to allow overriding definition mappings when the
definition items are equal. This is important during module name resolution
since it should be able to run the toplevel scan to gather the relevant
names into the top of the scope as well as the relative paths which contain
the same ids within the uppermost scope.
Diffstat (limited to 'gcc/rust/resolve/rust-ast-resolve.cc')
-rw-r--r-- | gcc/rust/resolve/rust-ast-resolve.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc index 06a341a..1b77ae2 100644 --- a/gcc/rust/resolve/rust-ast-resolve.cc +++ b/gcc/rust/resolve/rust-ast-resolve.cc @@ -203,8 +203,11 @@ void Resolver::insert_new_definition (NodeId id, Definition def) { auto it = name_definitions.find (id); - rust_assert (it == name_definitions.end ()); - + if (it != name_definitions.end ()) + { + rust_assert (it->second.is_equal (def)); + return; + } name_definitions[id] = def; } |