Skip to content

Conversation

P-E-P
Copy link
Member

@P-E-P P-E-P commented Aug 26, 2025

Fixes #3908

@powerboat9
Copy link
Collaborator

What about use {self};?

@powerboat9
Copy link
Collaborator

Or

struct Foo;

use Foo as self;

@P-E-P
Copy link
Member Author

P-E-P commented Aug 26, 2025

What about use {self};?

Let me push it :p

@P-E-P
Copy link
Member Author

P-E-P commented Aug 26, 2025

struct Foo;

use Foo as self;

I haven't looked into this one yet.

gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::visit): Emit an error
	on top level rebind self use declaration.

gcc/testsuite/ChangeLog:

	* rust/compile/use_self_alone.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@P-E-P P-E-P force-pushed the ice_finalize_rebind_imports branch from 2c47a2b to 5ddfd59 Compare August 26, 2025 18:11
@P-E-P
Copy link
Member Author

P-E-P commented Aug 26, 2025

@powerboat9 looks like your last snippet was already handled at the parser level.

@P-E-P P-E-P marked this pull request as ready for review August 26, 2025 18:21
@P-E-P P-E-P requested a review from powerboat9 August 26, 2025 18:21
@powerboat9
Copy link
Collaborator

What about

struct B;

use {B as B2, self};

@P-E-P P-E-P force-pushed the ice_finalize_rebind_imports branch from 5ddfd59 to cec961d Compare August 26, 2025 22:44
gcc/rust/ChangeLog:

	* resolve/rust-early-name-resolver-2.0.cc (Early::finalize_rebind_import):
	Replace assert with early break and remove early return.
	(Early::visit): Check for unsuffixed lower self list.
	* resolve/rust-early-name-resolver-2.0.h: Add visit function prototype.

gcc/testsuite/ChangeLog:

	* rust/compile/use_self_alone_in_list.rs: New test.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
@P-E-P P-E-P force-pushed the ice_finalize_rebind_imports branch from cec961d to 3807aff Compare August 26, 2025 23:16
@P-E-P P-E-P added this pull request to the merge queue Aug 27, 2025
Merged via the queue into Rust-GCC:master with commit 456dbb4 Aug 27, 2025
13 checks passed
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.

ICE in finalize_rebind_import, at rust/resolve/rust-early-name-resolver-2.0.cc:430
2 participants