diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h index 5d32c0022d0..f662d5df507 100644 --- a/gcc/rust/resolve/rust-ast-resolve-item.h +++ b/gcc/rust/resolve/rust-ast-resolve-item.h @@ -955,6 +955,15 @@ public: void visit (AST::ExternalFunctionItem &function) override { + NodeId scope_node_id = function.get_node_id (); + resolver->get_name_scope ().push (scope_node_id); + resolver->get_type_scope ().push (scope_node_id); + resolver->get_label_scope ().push (scope_node_id); + resolver->push_new_name_rib (resolver->get_name_scope ().peek ()); + resolver->push_new_type_rib (resolver->get_type_scope ().peek ()); + resolver->push_new_label_rib (resolver->get_type_scope ().peek ()); + + // resolve the generics if (function.has_generics ()) { for (auto &generic : function.get_generic_params ()) @@ -971,6 +980,11 @@ public: { ResolveType::go (param.get_type ().get (), param.get_node_id ()); } + + // done + resolver->get_name_scope ().pop (); + resolver->get_type_scope ().pop (); + resolver->get_label_scope ().pop (); } void visit (AST::ExternalStaticItem &item) override diff --git a/gcc/testsuite/rust/compile/issue-1131.rs b/gcc/testsuite/rust/compile/issue-1131.rs new file mode 100644 index 00000000000..fd158abc700 --- /dev/null +++ b/gcc/testsuite/rust/compile/issue-1131.rs @@ -0,0 +1,4 @@ +extern "rust-intrinsic" { + fn size_of() -> usize; + fn offset(dst: *const T, offset: isize) -> *const T; +}