Skip to content

[dropck] Emit Drop Error Codes#4515

Draft
Islam-Imad wants to merge 1 commit into
Rust-GCC:masterfrom
Islam-Imad:EmitDropErrors
Draft

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

Conversation

@Islam-Imad

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

Copy link
Copy Markdown
Contributor

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

dkm commented May 6, 2026

Copy link
Copy Markdown
Member

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!

@dkm dkm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Changelog needs love ❤️

@Islam-Imad

Copy link
Copy Markdown
Contributor Author

didn't forget you. a little bit busy nowadays
this work needs non-trivial refactor :)
i will update it and ping you again

@CohenArthur

Copy link
Copy Markdown
Member

@Islam-Imad I will put the PR in Draft mode for now, and you can mark it as ready once you are ready for a review again :)

@CohenArthur CohenArthur marked this pull request as draft May 19, 2026 12:57
@CohenArthur CohenArthur added the drop Issue with automatic `Drop::drop` calls insertion, drop ordering, drop rules label Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

drop Issue with automatic `Drop::drop` calls insertion, drop ordering, drop rules

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants