Skip to content

gccrs: avoid ICE on generic const expressions in path resolution#4341

Closed
Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Pasta-coder:fix-const-generic-ice-4302-v2
Closed

gccrs: avoid ICE on generic const expressions in path resolution#4341
Pasta-coder wants to merge 1 commit intoRust-GCC:masterfrom
Pasta-coder:fix-const-generic-ice-4302-v2

Conversation

@Pasta-coder
Copy link
Contributor

@Pasta-coder Pasta-coder commented Dec 27, 2025

Fixes #4302

ResolvePathRef::resolve_with_node_id assumed CONST types were always concrete values and asserted otherwise. Generic const expressions such as { N + 1 } are symbolic and cannot be evaluated prior to monomorphization, leading to an internal compiler error.

Reject non-value const kinds gracefully and emit a diagnostic instead of aborting.

gcc/testsuite:
* rust/compile/const-generic-ice-4302.rs: New test.

Thank you for making Rust GCC better!

If your PR fixes an issue, you can add "Fixes #issue_number" into this
PR description and the git commit message. This way the issue will be
automatically closed when your PR is merged. If your change addresses
an issue but does not fully fix it please mark it as "Addresses #issue_number"
in the git commit message.

Here is a checklist to help you with your PR.

Note that you can skip the above if you are just opening a WIP PR in
order to get feedback.

*Please write a comment explaining your change. This is the message
that will be part of the merge commit.

@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 896d6ad to 1b1c341 Compare December 27, 2025 16:54
Copy link
Member

@CohenArthur CohenArthur left a comment

Choose a reason for hiding this comment

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

The change looks great, only a few issues but nothing bad. Once this is fixed I'm happy to merge your PR. Thanks for your contribution!

@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch 5 times, most recently from e9afc67 to 3d52076 Compare January 3, 2026 23:44
@Pasta-coder
Copy link
Contributor Author

All checks are now passing and the PR is ready for merge.

@CohenArthur Thanks a lot for the review and helpful feedback — it clarified the expected coding style and workflow. I’ll keep future PRs focused with a clean commit history.

Please let me know if there’s anything else I should adjust.

@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 546caf5 to 56a7611 Compare January 6, 2026 07:28
@Pasta-coder
Copy link
Contributor Author

@P-E-P please review .

thankyou

Copy link
Member

@philberty philberty left a comment

Choose a reason for hiding this comment

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

Hmmm... i am not 100% sure this is the correct place to handle this because at this case is where it should be lazy evaluated and monomophized so i think this will cause false positives for other cases.

This should be handled in the typecheck pass when we resolve generic arguments instead where case cannot do N + 1 because N is not defined at this case.

@Pasta-coder
Copy link
Contributor Author

okay , i will look into that .

thanks for pointing this out .

@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch 16 times, most recently from c363e86 to ce25686 Compare January 10, 2026 01:56
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from f55981c to 87e8a7f Compare January 15, 2026 04:13
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 87e8a7f to e029ed9 Compare January 15, 2026 04:52
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from e029ed9 to 7b5672f Compare January 15, 2026 05:41
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 7b5672f to 385f43b Compare January 15, 2026 06:16
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 385f43b to 94e986d Compare January 15, 2026 06:24
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 94e986d to dd8b3ad Compare January 15, 2026 08:48
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from dd8b3ad to 1c72456 Compare January 15, 2026 09:09
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 1c72456 to 0ddabcf Compare January 15, 2026 09:25
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 0ddabcf to c30c9a3 Compare January 15, 2026 09:59
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from c30c9a3 to 78e425c Compare January 15, 2026 10:15
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 78e425c to 08efa26 Compare January 15, 2026 12:28
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 08efa26 to d4ba309 Compare January 15, 2026 12:44
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from d4ba309 to f816f7c Compare January 15, 2026 13:08
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from f816f7c to 89056db Compare January 15, 2026 17:47
Pasta-coder added a commit to Pasta-coder/gccrs that referenced this pull request Jan 15, 2026
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Relaxing backend assertions to return `error_mark_node` for symbolic types.
4. Implementing identity-based unification for symbolic expressions.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Relax assertion to return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Add handler for
	ConstExprType to prevent ICE.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/issue-4302.rs: New test.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
@Pasta-coder Pasta-coder force-pushed the fix-const-generic-ice-4302-v2 branch from 89056db to cbc657a Compare January 15, 2026 17:49
Generic const expressions such as `{ N + 1 }` are symbolic and cannot be
evaluated to a concrete value immediately during type checking. Previously,
the compiler lacked a representation for these symbolic expressions in the
type system, causing it to treat them as concrete values. This led to
assertion failures and Internal Compiler Errors (ICE) in the backend and
path resolution logic when the compiler attempted to access the raw value.

This patch introduces `TyTy::ConstExprType`, a new type variant designed
to hold symbolic expressions that have not yet been evaluated. It updates
the core type system, substitution mapper, unification rules, call checkers,
and backend compilation visitors to handle this new type gracefully.

Key changes include:
1. Validating const generic arguments in path resolution to detect dependency
   using the name resolver.
2. Bridging the substitution mapper to clone symbolic expressions.
3. Updating backend type compilation (`TyTyResolveCompile`) to compile the
   underlying expression tree for symbolic types instead of crashing.
4. Handling non-value constants in path resolution by emitting a specific
   diagnostic ("cannot evaluate constant expression") before returning failure.
5. Updating existing tests to match the new `<const_expr>` string representation.

Fixes Rust-GCC#4341

gcc/rust/ChangeLog:

	* backend/rust-compile-resolve-path.cc (ResolvePathRef::resolve_with_node_id):
	Emit diagnostic and return error_mark_node for non-value constants.
	* backend/rust-compile-type.cc (TyTyResolveCompile::visit): Compile the
	underlying expression for ConstExprType.
	* backend/rust-compile-type.h: Declare visit method.
	* typecheck/rust-hir-type-check-path.cc (is_const_dependent): New helper.
	(TypeCheckExpr::resolve_root_path): Skip immediate resolution for
	dependent const arguments.
	(TypeCheckExpr::resolve_segments): Likewise.
	* typecheck/rust-hir-type-check-pattern.cc (TypeCheckPattern::visit):
	Handle ConstKind::Expr in switch to prevent fallthrough.
	* typecheck/rust-substitution-mapper.cc (SubstMapperInternal::visit):
	Implement cloning for ConstExprType.
	* typecheck/rust-substitution-mapper.h: Add visit declarations.
	* typecheck/rust-tyty-call.cc (TypeCheckCallExpr::visit): Implement stub
	for ConstExprType.
	* typecheck/rust-tyty-call.h: Declare visit method.
	* typecheck/rust-tyty-variance-analysis-private.h (VisitorBase::visit):
	Add stub implementation.
	* typecheck/rust-tyty-visitor.h: Add virtual visit methods.
	* typecheck/rust-tyty.cc (ConstExprType::const_kind): Implement.
	(ConstExprType::accept_vis): Implement.
	(ConstExprType::as_string): Implement.
	(ConstExprType::clone): Implement.
	(ConstExprType::is_equal): Implement.
	(ConstExprType::get_expr): Implement.
	* typecheck/rust-tyty.h (enum ConstKind): Add Expr variant.
	(class ConstExprType): New class definition.
	* typecheck/rust-unify.cc (UnifyRules::expect_const): Add unification
	logic for ConstExprType.

gcc/testsuite/ChangeLog:

	* rust/compile/const_generics_10.rs: Update expected error messages to
	match <const_expr> representation.
	* rust/compile/issue-4302.rs: New test.
	* rust/compile/const_generics_12.rs: Update expected error messages to
	match <const_expr> representation.

Signed-off-by: Jayant Chauhan <0001jayant@gmail.com>
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.

ICE in resolve_with_node_id, at rust/backend/rust-compile-resolve-path.cc GCEs

3 participants