Add range_inclusive_new#4704
Open
nsvke wants to merge 2 commits into
Open
Conversation
This patch introduces the 'range_inclusive_new' lang item to the compiler. When the compiler encounters an inclusive range expression, it now correctly desugars the operation into a function call targeting this lang item instead of lowering it directly into a static struct. gcc/rust/ChangeLog: * hir/rust-ast-lower-expr.cc (ASTLoweringExpr::visit): Add desugaring for range_inclusive_new lang item. * util/rust-lang-item.cc (Rust::LangItem::lang_items): Add range_inclusive_new to the BiMap. * util/rust-lang-item.h (class LangItem): Add RANGE_INCLUSIVE_NEW to the Kind enum. gcc/testsuite/ChangeLog: * rust/compile/torture/range-lang-item1.rs: Update test to use the new lang item. Signed-off-by: Enes Cevik <enes@nsvke.com>
This patch removes the unnecessary HIR::RangeFromToInclExpr class and its associated visitors across the compiler. Since inclusive ranges are now directly desugared into a CallExpr targeting the 'range_inclusive_new' lang item during AST-to-HIR lowering, this HIR node and its codegen/typecheck implementations are dead code. gcc/rust/ChangeLog: * backend/rust-compile-block.h: Remove RangeFromToInclExpr visit. * backend/rust-compile-expr.cc (CompileExpr::visit): Likewise. * backend/rust-compile-expr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.cc (ExprStmtBuilder::visit): Likewise. * checks/errors/borrowck/rust-bir-builder-expr-stmt.h: Likewise. * checks/errors/borrowck/rust-bir-builder-lazyboolexpr.h: Likewise. * checks/errors/borrowck/rust-bir-builder-struct.h: Likewise. * checks/errors/borrowck/rust-function-collector.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-hir-pattern-analysis.cc (PatternChecker::visit): Likewise. * checks/errors/rust-hir-pattern-analysis.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-expr.cc (RangeFromToInclExpr::RangeFromToInclExpr): Likewise. (RangeFromToInclExpr::operator=): Likewise. * hir/tree/rust-hir-expr.h (class RangeFromToInclExpr): Remove class. * hir/tree/rust-hir-full-decls.h (class RangeFromToInclExpr): Remove forward declaration. * hir/tree/rust-hir-visitor.cc (DefaultHIRVisitor::walk): Remove RangeFromToInclExpr visit. * hir/tree/rust-hir-visitor.h: Likewise. * hir/tree/rust-hir.cc (RangeFromToInclExpr::to_string): Remove. (RangeFromToInclExpr::accept_vis): Remove. * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): Remove. * typecheck/rust-hir-type-check-expr.h: Remove RangeFromToInclExpr visit. Signed-off-by: Enes Cevik <enes@nsvke.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch introduces the 'range_inclusive_new' lang item to the compiler.
When the compiler encounters an inclusive range expression, it now
correctly desugars the operation into a function call targeting this
lang item instead of lowering it directly into a static struct.
gcc/rust/ChangeLog:
gcc/testsuite/ChangeLog:
This patch removes the unnecessary HIR::RangeFromToInclExpr class and its
associated visitors across the compiler. Since inclusive ranges are now
directly desugared into a CallExpr targeting the 'range_inclusive_new'
lang item during AST-to-HIR lowering, this HIR node and its
codegen/typecheck implementations are dead code.
gcc/rust/ChangeLog: