-
Notifications
You must be signed in to change notification settings - Fork 185
Get rid of TyTy::BaseType can_eq interface #4118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
philberty
wants to merge
11
commits into
master
Choose a base branch
from
phil/can-eq-dev
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This interface is not respecting the coercion api commit is always false, we need to ensure this is respected via the try flag like the rest of the coercion logic. gcc/rust/ChangeLog: * typecheck/rust-coercion.cc (TypeCoercionRules::select): respect try flag Signed-off-by: Philip Herron <[email protected]>
I needed to remove som usage of const so we can get rid of can_eq in type bounds probe. This means we can use the types_compatable interface instead. Which is much better. gcc/rust/ChangeLog: * backend/rust-compile-base.h: remove const * backend/rust-compile-expr.cc: likewise * backend/rust-compile.cc (HIRCompileBase::coerce_to_dyn_object): likewise * typecheck/rust-hir-type-bounds.h: likewise * typecheck/rust-type-util.cc (lookup_associated_impl_block): likewise * typecheck/rust-type-util.h (lookup_associated_impl_block): likewise * typecheck/rust-tyty-bounds.cc (TypeBoundsProbe::TypeBoundsProbe): likewise (TypeBoundsProbe::Probe): likewise * typecheck/rust-tyty-cmp.h: likewise * typecheck/rust-tyty-subst.cc (SubstitutionRef::monomorphize): likewise * typecheck/rust-tyty.cc (BaseType::satisfies_bound): likewise (BaseType::bounds_compatible): likewise (VariantDef::clone): likewise (VariantDef::monomorphized_clone): likewise (OpaqueType::is_equal): likewise (DynamicObjectType::is_equal): likewise * typecheck/rust-tyty.h: likewise Signed-off-by: Philip Herron <[email protected]>
We use the types compatable interface for unify here and so if we dont respect the commit flag the interface can have unintended side effects with infer type hints throwing things off down the line. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::expect_inference_variable): dont commit (UnifyRules::expect_adt): likewise (UnifyRules::expect_bool): likewise (UnifyRules::expect_char): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise (UnifyRules::expect_isize): likewise (UnifyRules::expect_usize): likewise Signed-off-by: Philip Herron <[email protected]>
Getting close to getting rid of can_eq and tyty-cmp soon. gcc/rust/ChangeLog: * typecheck/rust-hir-path-probe.cc (PathProbeType::process_impl_item_candidate): refactor to types_compatable Signed-off-by: Philip Herron <[email protected]>
We need to make the type bounds check a flag because it can turn into a recursive type bounds check. This allows us to remove another can_eq usage gcc/rust/ChangeLog: * typecheck/rust-type-util.cc (types_compatable): add check bounds flag (unify_site_and): likewise * typecheck/rust-type-util.h (types_compatable): likewise (unify_site_and): likewise * typecheck/rust-tyty-bounds.cc: likewise * typecheck/rust-unify.cc (UnifyRules::UnifyRules): likewise (UnifyRules::Resolve): likewise (UnifyRules::resolve_subtype): likewise (UnifyRules::go): likewise * typecheck/rust-unify.h: likewise Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (BaseType::satisfies_bound): use types_compatable instead gcc/testsuite/ChangeLog: * rust/compile/issue-1725-2.rs: remove bad error message Signed-off-by: Philip Herron <[email protected]>
We should only clone when we commit and it was successful. With no cloning there is a regression in min specialization 2. Probably because it needs to know the unify site hirid and ensure we have it set there. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (UnifyRules::Resolve): check for success (UnifyRules::expect_inference_variable): dont clone (UnifyRules::expect_adt): likewise (UnifyRules::expect_str): likewise (UnifyRules::expect_reference): likewise (UnifyRules::expect_pointer): likewise (UnifyRules::expect_param): likewise (UnifyRules::expect_array): likewise (UnifyRules::expect_slice): likewise (UnifyRules::expect_fndef): likewise (UnifyRules::expect_fnptr): likewise (UnifyRules::expect_tuple): likewise (UnifyRules::expect_bool): likewise (UnifyRules::expect_char): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise (UnifyRules::expect_isize): likewise (UnifyRules::expect_usize): likewise (UnifyRules::expect_never): likewise (UnifyRules::expect_placeholder): likewise (UnifyRules::expect_projection): likewise (UnifyRules::expect_dyn): likewise (UnifyRules::expect_closure): likewise Signed-off-by: Philip Herron <[email protected]>
During unification we denote failures using a new error mark node. This keeps a static one and reuses it instead. gcc/rust/ChangeLog: * typecheck/rust-unify.cc (unify_error_type_node): new static node (UnifyRules::go): likewise (UnifyRules::expect_inference_variable): likewise (UnifyRules::expect_adt): likewise (UnifyRules::expect_str): likewise (UnifyRules::expect_reference): likewise (UnifyRules::expect_pointer): likewise (UnifyRules::expect_param): likewise (UnifyRules::expect_array): likewise (UnifyRules::expect_slice): likewise (UnifyRules::expect_fndef): likewise (UnifyRules::expect_fnptr): likewise (UnifyRules::expect_tuple): likewise (UnifyRules::expect_bool): likewise (UnifyRules::expect_char): likewise (UnifyRules::expect_int): likewise (UnifyRules::expect_uint): likewise (UnifyRules::expect_float): likewise (UnifyRules::expect_isize): likewise (UnifyRules::expect_usize): likewise (UnifyRules::expect_never): likewise (UnifyRules::expect_placeholder): likewise (UnifyRules::expect_projection): likewise (UnifyRules::expect_dyn): likewise (UnifyRules::expect_closure): likewise (UnifyRules::expect_opaque): likewise (UnifyRules::expect_const): likewise Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (ParamType::is_equal): uses types_compatable Signed-off-by: Philip Herron <[email protected]>
This was an initial helper from back in the day which was not maintained but was a nice const simple way to check if types are compatable. But reusing our unify code is much much more acurate and single source of truth on the type system. gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (InferType::can_eq): remove (ErrorType::can_eq): likewise (ADTType::can_eq): likewise (TupleType::can_eq): likewise (FnType::can_eq): likewise (FnPtr::can_eq): likewise (ClosureType::can_eq): likewise (ArrayType::can_eq): likewise (SliceType::can_eq): likewise (BoolType::can_eq): likewise (IntType::can_eq): likewise (UintType::can_eq): likewise (FloatType::can_eq): likewise (USizeType::can_eq): likewise (ISizeType::can_eq): likewise (CharType::can_eq): likewise (ReferenceType::can_eq): likewise (PointerType::can_eq): likewise (ParamType::can_eq): likewise (ConstType::can_eq): likewise (OpaqueType::can_eq): likewise (StrType::can_eq): likewise (NeverType::can_eq): likewise (PlaceholderType::can_eq): likewise (ProjectionType::can_eq): likewise (DynamicObjectType::can_eq): likewise * typecheck/rust-tyty.h: remove can_eq * typecheck/rust-tyty-cmp.h: Removed. Signed-off-by: Philip Herron <[email protected]>
gcc/rust/ChangeLog: * typecheck/rust-tyty.cc (VariantDef::clone): fix formatting (VariantDef::monomorphized_clone): likewise * typecheck/rust-tyty.h: likewise Signed-off-by: Philip Herron <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a patch set to rid of this old interface. Its been a mess hiding issues in our
unify code and type system in general.