-
Notifications
You must be signed in to change notification settings - Fork 207
gccrs: avoid ICE on generic const expressions in path resolution #4341
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
base: master
Are you sure you want to change the base?
gccrs: avoid ICE on generic const expressions in path resolution #4341
Conversation
896d6ad to
1b1c341
Compare
CohenArthur
left a comment
There was a problem hiding this 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!
e9afc67 to
3d52076
Compare
|
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. |
546caf5 to
56a7611
Compare
|
@P-E-P please review . thankyou |
philberty
left a comment
There was a problem hiding this 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.
|
okay , i will look into that . thanks for pointing this out . |
c363e86 to
ce25686
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
95b67f1 to
5535d11
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
5535d11 to
dda5f8d
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
dda5f8d to
37fcefc
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
37fcefc to
e7deae3
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
e7deae3 to
d9c6908
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
d9c6908 to
a34162f
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
a34162f to
8ea1187
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
8ea1187 to
58e3abf
Compare
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.
Signed-off-by: Jayant Chauhan <[email protected]>
58e3abf to
e848f80
Compare
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/comppile/const_generics_12.rs: Update expected error messages to
match <const_expr> representation.
Signed-off-by: Jayant Chauhan <[email protected]>
e848f80 to
f38160a
Compare
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/comppile/const_generics_12.rs: Update expected error messages to
match <const_expr> representation.
Signed-off-by: Jayant Chauhan <[email protected]>
f38160a to
f641e6a
Compare
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/comppile/const_generics_12.rs: Update expected error messages to
match <const_expr> representation.
Signed-off-by: Jayant Chauhan <[email protected]>
f641e6a to
59f9c96
Compare
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/comppile/const_generics_12.rs: Update expected error messages to
match <const_expr> representation.
Signed-off-by: Jayant Chauhan <[email protected]>
59f9c96 to
ed3d5db
Compare
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 <[email protected]>
ed3d5db to
1b8bbbb
Compare
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 <[email protected]>
1b8bbbb to
91c9be0
Compare
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.
make check-rustpasses locallyclang-formatgcc/testsuite/rust/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.