gccrs icon indicating copy to clipboard operation
gccrs copied to clipboard

Refactored to use implicit insert and remove insert_type method from context object #3395

Open mostafa630 opened this issue 9 months ago • 14 comments

This solution resolves issue #3395 by refactoring the code to use implicit_insert_type instead of insert_type, improving clarity and eliminating the insert_type method from the context object. Changed files: * typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_type): Remove. * typecheck/rust-hir-type-check.h: Remove declaration of insert_type method. * typecheck/rust-tyty-subst.cc: Replace all insert_type with insert_implicit_type. * typecheck/rust-tyty-util.cc: Likewise. * typecheck/rust-tyty.cc: Likewise. * typecheck/rust-substitution-mapper.cc: Likewise. * typecheck/rust-hir-trait-resolve.cc: Likewise. * typecheck/rust-hir-type-check-base.cc: Likewise. * typecheck/rust-hir-type-check-enumitem.cc: Likewise. * typecheck/rust-hir-type-check-expr.cc: use Likewise. * typecheck/rust-hir-type-check-implitem.cc: Likewise. * typecheck/rust-hir-type-check-item.cc: use Likewise. * typecheck/rust-hir-type-check-pattern.cc: Likewise. * typecheck/rust-hir-type-check-stmt.cc: Likewise. * typecheck/rust-hir-type-check-struct.cc: Likewise. * typecheck/rust-hir-type-check-type.cc: Likewise. * typecheck/rust-hir-type-check.cc: Likewise. * typecheck/rust-unify.cc: Likewise.

mostafa630 avatar Mar 06 '25 00:03 mostafa630

You don't have to keep recreating the PR, you can just force-push

powerboat9 avatar Mar 06 '25 01:03 powerboat9

Looks good, just missing the removal of a few insert_type calls

powerboat9 avatar Mar 06 '25 01:03 powerboat9

Looks good, just missing the removal of a few insert_type calls

Should I only remove the remaining ones, or should I replace them with insert_implicit_type?

mostafa630 avatar Mar 06 '25 01:03 mostafa630

Replace them with insert_implicit_type

powerboat9 avatar Mar 06 '25 01:03 powerboat9

FYI, changelog is not really correct. You should have things like:

   * typecheck/rust-substitution-mapper.cc (SubstMapperInternal::Resolve): use insert_implicit_type.
   * typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_type): Remove.
   (TypeCheckContext::compute_inference_variables): use insert_implicit_type.

... You're not supposed to only point at the file where you've made changes, but to more precise "item" (function, type definition, etc). Also, instead of repeating the same thing in sequence, you can use the idiomatic "Likewise" (have a look at existing entries in git log). Do not hesitate to ask for help if needed :)

dkm avatar Mar 06 '25 14:03 dkm

@dkm can I use clang-format-13 or I must use version 10 because I have some problems in installing version 10

mostafa630 avatar Mar 07 '25 02:03 mostafa630

I use version 19, which only very rarely disagrees with version 10. You can always try it with version 13 and see if the CI complains

powerboat9 avatar Mar 07 '25 05:03 powerboat9

I use version 19, which only very rarely disagrees with version 10. You can always try it with version 13 and see if the CI complains

@powerboat9 Thanks! I tried it with version 13, and it works well. All tests passed successfully.

mostafa630 avatar Mar 07 '25 11:03 mostafa630

@dkm I wonder if pseudonyms are allowed for sign off

P-E-P avatar Mar 07 '25 17:03 P-E-P

I think you need to fix your sign-off for DCO you are using a pseudonym

https://gcc.gnu.org/dco.html

I changed the sign-off to match the DCO.

mostafa630 avatar Mar 14 '25 21:03 mostafa630

I think you need to fix your sign-off for DCO you are using a pseudonym https://gcc.gnu.org/dco.html

I changed the sign-off to match the DCO.

erm, I thought they were going to relax this rule. At least, it was mentioned during last Cauldron I think.

(please note that my initial comment on changelog section still holds...)

dkm avatar Mar 20 '25 15:03 dkm

I think you need to fix your sign-off for DCO you are using a pseudonym https://gcc.gnu.org/dco.html

I changed the sign-off to match the DCO.

erm, I thought they were going to relax this rule. At least, it was mentioned during last Cauldron I think.

(please note that my initial comment on changelog section still holds...)

sorry , but do you mean that i should make this : * typecheck/rust-hir-type-check.h: Remove declaration of insert_type method. like that : * typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_type): Remove.

or do you mean that i don't mentioned which function exactly i changed it : * typecheck/rust-tyty-subst.cc: Replace all insert_type with insert_implicit_type.

(i don't mentioned functions because there are many of them so the change log will be huge)

mostafa630 avatar Mar 20 '25 16:03 mostafa630

Your git signoff line needs to mention your full name it cant be a username

philberty avatar Mar 23 '25 14:03 philberty

Your git signoff line needs to mention your full name it cant be a username

Okay, I will use that: Mostafa Mahmoud Younis. But is there any further update in the message change log?

mostafa630 avatar Mar 23 '25 15:03 mostafa630