Skip to content

gccrs: Remove more calls to the old TyTy::BaseType::can_eq interface#4034

Merged
philberty merged 1 commit into
masterfrom
phil/can-eq-remove-1
Aug 1, 2025
Merged

gccrs: Remove more calls to the old TyTy::BaseType::can_eq interface#4034
philberty merged 1 commit into
masterfrom
phil/can-eq-remove-1

Conversation

@philberty

Copy link
Copy Markdown
Member

This old can_eq interface was an old method to try and check if types can match up by taking into account generics but its not maintained properly and we already have a new wrapper Resolver::types_compatable (type, type, locus, emit_errors) which just calls unify_site_and infer with commit false. There are only a few places left to update.

One minor downside is that i need to remove const in some places because the unify interface is non const. Ideally we would want to avoid writing a seperate const unify anyway so i think this is not ideal but fine for us.

gcc/rust/ChangeLog:

* typecheck/rust-autoderef.cc: remove useless assertion
* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): refactor (TypeCoercionRules::coerce_borrowed_pointer): remove FIXME this is fine
* typecheck/rust-hir-inherent-impl-overlap.h: use types_compatable
* typecheck/rust-hir-path-probe.cc (PathProbeType::PathProbeType): remove const (PathProbeType::Probe): likewise (PathProbeImplTrait::PathProbeImplTrait): likewise (PathProbeImplTrait::Probe): likewise
* typecheck/rust-hir-path-probe.h: likewise
* typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): likewise
* typecheck/rust-hir-type-check-base.h: likewise
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): use types_compatable
* typecheck/rust-hir-type-check.h: remove const
* typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_associated_impl_mapping): likewise (TypeCheckContext::lookup_associated_impl_mapping_for_self): remove can_Eq
* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::is_equal): likewise
* typecheck/rust-tyty-subst.cc (SubstitutionArg::get_tyty): remove const version
* typecheck/rust-tyty-subst.h: likewise
* typecheck/rust-tyty.cc (BaseType::get_root): likewise
* typecheck/rust-tyty.h: likewise

gcc/testsuite/ChangeLog:

* rust/compile/generics8.rs: extra error message

This old can_eq interface was an old method to try and check if types can match up
by taking into account generics but its not maintained properly and we already have
a new wrapper Resolver::types_compatable (type, type, locus, emit_errors) which
just calls unify_site_and infer with commit false. There are only a few places left
to update.

One minor downside is that i need to remove const in some places because the unify
interface is non const. Ideally we would want to avoid writing a seperate const unify
anyway so i think this is not ideal but fine for us.

gcc/rust/ChangeLog:

	* typecheck/rust-autoderef.cc: remove useless assertion
	* typecheck/rust-coercion.cc (TypeCoercionRules::coerce_unsafe_ptr): refactor
	(TypeCoercionRules::coerce_borrowed_pointer): remove FIXME this is fine
	* typecheck/rust-hir-inherent-impl-overlap.h: use types_compatable
	* typecheck/rust-hir-path-probe.cc (PathProbeType::PathProbeType): remove const
	(PathProbeType::Probe): likewise
	(PathProbeImplTrait::PathProbeImplTrait): likewise
	(PathProbeImplTrait::Probe): likewise
	* typecheck/rust-hir-path-probe.h: likewise
	* typecheck/rust-hir-type-check-base.cc (walk_types_to_constrain): likewise
	* typecheck/rust-hir-type-check-base.h: likewise
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): use types_compatable
	* typecheck/rust-hir-type-check.h: remove const
	* typecheck/rust-typecheck-context.cc (TypeCheckContext::insert_associated_impl_mapping):
	likewise
	(TypeCheckContext::lookup_associated_impl_mapping_for_self): remove can_Eq
	* typecheck/rust-tyty-bounds.cc (TypeBoundPredicate::is_equal): likewise
	* typecheck/rust-tyty-subst.cc (SubstitutionArg::get_tyty): remove const version
	* typecheck/rust-tyty-subst.h: likewise
	* typecheck/rust-tyty.cc (BaseType::get_root): likewise
	* typecheck/rust-tyty.h: likewise

gcc/testsuite/ChangeLog:

	* rust/compile/generics8.rs: extra error message

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
@philberty philberty added this pull request to the merge queue Aug 1, 2025
Merged via the queue into master with commit 41dcb21 Aug 1, 2025
13 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in libcore 1.49 Aug 1, 2025
@philberty philberty deleted the phil/can-eq-remove-1 branch August 1, 2025 19:30
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.

1 participant