Skip to content

Conversation

@CohenArthur
Copy link
Member

Allow crates to be used as targets for glob imports, like modules and enums.

gcc/rust/ChangeLog:

* ast/rust-ast-full-decls.h (class GlobContainer): New.
* ast/rust-ast.h (class GlobContainer): New.
(struct Crate): Inherit from GlobContainer.
* ast/rust-item.h (class Module): Likewise.
(class Enum): Likewise.
* resolve/rust-finalize-imports-2.0.cc (GlobbingVisitor::go): Handle crates.
(GlobbingVisitor::visit_crate_container): New.
(GlobbingVisitor::visit): Remove privacy check as it is wrong.
* resolve/rust-finalize-imports-2.0.h: Declare new methods.
* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Handle crates.
(TopLevel::visit): Use new insert_glob_container API.
* util/rust-hir-map.cc (Mappings::get_ast_crate_by_node_id_raw): New private method.
(Mappings::get_ast_crate_by_node_id): Use it.
(Mappings::insert_glob_container): New API.
* util/rust-hir-map.h: Likewise.

It's a bit hard to add tests for this, as it requires a bit of a complex file structure that I think we don't handle in the testsuite yet. In any case, it's required for core and it's not destructive changes or anything

Allow crates to be used as targets for glob imports, like modules and enums.

gcc/rust/ChangeLog:

	* ast/rust-ast-full-decls.h (class GlobContainer): New.
	* ast/rust-ast.h (class GlobContainer): New.
	(struct Crate): Inherit from GlobContainer.
	* ast/rust-item.h (class Module): Likewise.
	(class Enum): Likewise.
	* resolve/rust-finalize-imports-2.0.cc (GlobbingVisitor::go): Handle crates.
	(GlobbingVisitor::visit_crate_container): New.
	(GlobbingVisitor::visit): Remove privacy check as it is wrong.
	* resolve/rust-finalize-imports-2.0.h: Declare new methods.
	* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Handle crates.
	(TopLevel::visit): Use new insert_glob_container API.
	* util/rust-hir-map.cc (Mappings::get_ast_crate_by_node_id_raw): New private method.
	(Mappings::get_ast_crate_by_node_id): Use it.
	(Mappings::insert_glob_container): New API.
	* util/rust-hir-map.h: Likewise.
@P-E-P P-E-P added this pull request to the merge queue Jan 6, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants