[gcc r14-7339] gccrs: Cleanup and Assertion

Arthur Cohen cohenarthur@gcc.gnu.org
Tue Jan 16 17:23:37 GMT 2024


https://gcc.gnu.org/g:e9e0f8bf8bc76bfd5369e0d3f8a74d3ffc9e1669

commit r14-7339-ge9e0f8bf8bc76bfd5369e0d3f8a74d3ffc9e1669
Author: Parthib <parthibdutta02@gmail.com>
Date:   Mon Mar 6 07:34:43 2023 +0530

    gccrs: Cleanup and Assertion
    
    gcc/rust/ChangLog:
    
            * rust-object-export.cc: Modified
            * hir/rust-ast-lower-type.cc (rust_fatal_error): Removed
                    (rust_assert): Added
    
    Signed-off-by: Parthib <parthibdutta02@gmail.com>

Diff:
---
 gcc/rust/hir/rust-ast-lower-type.cc | 22 ++++++----------------
 gcc/rust/rust-object-export.cc      |  3 +--
 2 files changed, 7 insertions(+), 18 deletions(-)

diff --git a/gcc/rust/hir/rust-ast-lower-type.cc b/gcc/rust/hir/rust-ast-lower-type.cc
index 472e4c550e4..480e078a4e1 100644
--- a/gcc/rust/hir/rust-ast-lower-type.cc
+++ b/gcc/rust/hir/rust-ast-lower-type.cc
@@ -108,11 +108,8 @@ ASTLowerTypePath::visit (AST::TypePath &path)
     {
       translated_segment = nullptr;
       seg->accept_vis (*this);
-      if (translated_segment == nullptr)
-	{
-	  rust_fatal_error (seg->get_locus (),
-			    "failed to translate AST TypePathSegment");
-	}
+      rust_assert (translated_segment != nullptr);
+
       translated_segments.push_back (
 	std::unique_ptr<HIR::TypePathSegment> (translated_segment));
     }
@@ -158,12 +155,8 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path)
 
   translated_segment = nullptr;
   path.get_associated_segment ()->accept_vis (*this);
-  if (translated_segment == nullptr)
-    {
-      rust_fatal_error (path.get_associated_segment ()->get_locus (),
-			"failed to translate AST TypePathSegment");
-      return;
-    }
+  rust_assert (translated_segment != nullptr);
+
   std::unique_ptr<HIR::TypePathSegment> associated_segment (translated_segment);
 
   std::vector<std::unique_ptr<HIR::TypePathSegment>> translated_segments;
@@ -171,11 +164,8 @@ ASTLowerQualifiedPathInType::visit (AST::QualifiedPathInType &path)
     {
       translated_segment = nullptr;
       seg->accept_vis (*this);
-      if (translated_segment == nullptr)
-	{
-	  rust_fatal_error (seg->get_locus (),
-			    "failed to translte AST TypePathSegment");
-	}
+      rust_assert (translated_segment != nullptr);
+
       translated_segments.push_back (
 	std::unique_ptr<HIR::TypePathSegment> (translated_segment));
     }
diff --git a/gcc/rust/rust-object-export.cc b/gcc/rust/rust-object-export.cc
index 6f4a9b7e8eb..21f66a3ebac 100644
--- a/gcc/rust/rust-object-export.cc
+++ b/gcc/rust/rust-object-export.cc
@@ -1,5 +1,4 @@
-/* rust-backend.c -- Rust frontend interface to gcc backend.
-   Copyright (C) 2010-2024 Free Software Foundation, Inc.
+/* Copyright (C) 2010-2024 Free Software Foundation, Inc.
 
    This file is part of GCC.


More information about the Gcc-cvs mailing list