aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve.cc3
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-path.cc22
-rw-r--r--gcc/testsuite/rust/execute/torture/trait2.rs37
3 files changed, 39 insertions, 23 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve.cc b/gcc/rust/resolve/rust-ast-resolve.cc
index 5b6bb24..9d79b36 100644
--- a/gcc/rust/resolve/rust-ast-resolve.cc
+++ b/gcc/rust/resolve/rust-ast-resolve.cc
@@ -225,9 +225,6 @@ Resolver::lookup_definition (NodeId id, Definition *def)
void
Resolver::insert_resolved_name (NodeId refId, NodeId defId)
{
- auto it = resolved_names.find (refId);
- rust_assert (it == resolved_names.end ());
-
resolved_names[refId] = defId;
get_name_scope ().append_reference_for_def (refId, defId);
}
diff --git a/gcc/rust/typecheck/rust-hir-type-check-path.cc b/gcc/rust/typecheck/rust-hir-type-check-path.cc
index df45e66..7b0e8ae 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-path.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-path.cc
@@ -118,26 +118,8 @@ TypeCheckExpr::visit (HIR::QualifiedPathInExpression &expr)
if (fully_resolved)
{
- // lookup if the name resolver was able to canonically resolve this or
- // not
- NodeId path_resolved_id = UNKNOWN_NODEID;
- if (resolver->lookup_resolved_name (expr.get_mappings ().get_nodeid (),
- &path_resolved_id))
- {
- rust_assert (path_resolved_id == root_resolved_node_id);
- }
- // check the type scope
- else if (resolver->lookup_resolved_type (
- expr.get_mappings ().get_nodeid (), &path_resolved_id))
- {
- rust_assert (path_resolved_id == root_resolved_node_id);
- }
- else
- {
- resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
- root_resolved_node_id);
- }
-
+ resolver->insert_resolved_name (expr.get_mappings ().get_nodeid (),
+ root_resolved_node_id);
context->insert_receiver (expr.get_mappings ().get_hirid (), root);
return;
}
diff --git a/gcc/testsuite/rust/execute/torture/trait2.rs b/gcc/testsuite/rust/execute/torture/trait2.rs
new file mode 100644
index 0000000..c96615f
--- /dev/null
+++ b/gcc/testsuite/rust/execute/torture/trait2.rs
@@ -0,0 +1,37 @@
+/* { dg-output "Bar::A = 456\n<Foo as Bar>::A = 456\n" } */
+extern "C" {
+ fn printf(s: *const i8, ...);
+}
+
+trait Foo {
+ const A: i32 = 123;
+}
+
+struct Bar;
+impl Foo for Bar {
+ const A: i32 = 456;
+}
+
+fn main() -> i32 {
+ let a;
+ a = Bar::A;
+
+ unsafe {
+ let _a = "Bar::A = %i\n\0";
+ let _b = _a as *const str;
+ let _c = _b as *const i8;
+ printf(_c, a);
+ }
+
+ let b;
+ b = <Bar as Foo>::A;
+
+ unsafe {
+ let _a = "<Foo as Bar>::A = %i\n\0";
+ let _b = _a as *const str;
+ let _c = _b as *const i8;
+ printf(_c, b);
+ }
+
+ 0
+}