Skip to content

Conversation

philberty
Copy link
Member

@philberty philberty commented Mar 20, 2023

Fixes: #850 #855

To enable use statement to export a name to a path such as the prelude
example: use option::Option::{self, None, Some} we need to get the resolved
node id of the self, None and Some in order to export the name of None and
Some to their respective NodeId.

gcc/rust/ChangeLog:

	* resolve/rust-ast-resolve-path.cc (ResolvePath::ResolvePath): return NodeId
	(ResolvePath::go): update signiture
	(ResolvePath::resolve_path): return resolved_node_id
	* resolve/rust-ast-resolve-path.h: update prototypes

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
…espace

This builds upon the previous path resolution fixes so that it returns the
resolved_node_id or UNKNOWN_NODEID on failure to resolve the use-path.
It then exports the name to the current module namespace so it can be used.

Fixes #850 #855

gcc/rust/ChangeLog:

	* ast/rust-ast.h: add const get_final_segment helper
	* hir/rust-ast-lower-enumitem.h: dont add an item mapping for enumitems
	* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): add enum to enum-items mappings
	* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): likewise
	* hir/tree/rust-hir-item.h: add non const helper to get variants
	* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): resolve the use declaration
	* resolve/rust-ast-resolve-path.cc (ResolvePath::resolve_path): handle self
	* resolve/rust-ast-resolve-toplevel.h: add enum item mappings to module mappings
	* typecheck/rust-hir-type-check-path.cc (TypeCheckExpr::resolve_root_path): ensure variant
	(TypeCheckExpr::resolve_segments): likewise
	* typecheck/rust-type-util.cc (query_type): lookup enum's
	* util/rust-hir-map.cc (Mappings::insert_hir_enumitem): enum item mappings
	(Mappings::lookup_hir_enumitem): likewise
	* util/rust-hir-map.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/issue-850.rs: New test.
	* rust/compile/issue-855.rs: New test.

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty changed the title gccrs: Return resolved_node_id when possible Support use declaration to export the type properly Mar 20, 2023
@philberty philberty linked an issue Mar 20, 2023 that may be closed by this pull request
@philberty philberty linked an issue Mar 20, 2023 that may be closed by this pull request
@philberty philberty self-assigned this Mar 20, 2023
@philberty philberty mentioned this pull request Mar 20, 2023
41 tasks
@philberty philberty enabled auto-merge March 20, 2023 21:13
@philberty philberty added this pull request to the merge queue Mar 20, 2023
@philberty philberty merged commit a8662e8 into master Mar 20, 2023
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@philberty philberty deleted the phil/resolve-path branch March 26, 2023 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Rust result type requires lang items Option Type requires lang items
2 participants