Skip to content

[dropck] Emit Drop Error Codes#4515

Open
Islam-Imad wants to merge 1 commit intoRust-GCC:masterfrom
Islam-Imad:EmitDropErrors
Open

[dropck] Emit Drop Error Codes#4515
Islam-Imad wants to merge 1 commit intoRust-GCC:masterfrom
Islam-Imad:EmitDropErrors

Conversation

@Islam-Imad
Copy link
Copy Markdown
Contributor

@Islam-Imad Islam-Imad commented Apr 4, 2026

emit :

  • [0740] union fields must not need drop.
  • [0184] no type cannot have copy & drop trait.
  • [0040] prevent direct drop call.

added some utilites to catch drop related error codes.

gcc/rust/ChangeLog:

	* Make-lang.in: add rust-drop-check.h
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): drop call error
	* typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): union&trait errors
	* typecheck/rust-hir-type-check.h: peek_trait_impl_map
	* typecheck/rust-typecheck-context.cc
	(TypeCheckContext::insert_associated_impl_mapping): peek_trait_impl_map
	* util/rust-lang-item.cc: add Drop
	* util/rust-lang-item.h: add Drop
	* typecheck/rust-drop-check.cc: handle drop logic.
	* typecheck/rust-drop-check.h: handle drop logic.

gcc/testsuite/ChangeLog:

	* rust/compile/dropck-e0040-direct-drop.rs: New test.
	* rust/compile/dropck-e0184-copy-drop.rs: New test.
	* rust/compile/dropck-e0740-union.rs: New test.

Signed-off-by: Islam-Imad <islamimad404@gmail.com>
@dkm
Copy link
Copy Markdown
Member

dkm commented May 6, 2026

Hi!

while having a look at the changelog, I think it may need some adjustment. For example:

	* typecheck/rust-hir-type-check.h: peek_trait_impl_map
	* typecheck/rust-typecheck-context.cc
	(TypeCheckContext::insert_associated_impl_mapping): peek_trait_impl_map

doesn't really help in knowing what happened in these files. The names are off, I think.
You're adding peek_associated_impl_mapping_for_self in the rust-hir-type-check.h file, and I'm not sure why you mention insert_associated_impl_mapping.

Can you respin the changelog part? I looks like you probably did it during an earlier phase of your dev.
Thanks!

Copy link
Copy Markdown
Member

@dkm dkm left a comment

Choose a reason for hiding this comment

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

Changelog needs love ❤️

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