[gccrs COMMIT 2/2] gccrs: Add missing isize and usize as valid options here

gerris.rs@gmail.com gerris.rs@gmail.com
Tue Sep 8 11:57:12 GMT 2026


From: Philip Herron <herron.philip@googlemail.com>

Fixes Rust-GCC/gccrs#4858

gcc/rust/ChangeLog:

	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): add missing checks

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
---
This change was merged into the gccrs repository and is posted here for
upstream visibility and potential drive-by review, as requested by GCC
release managers.
Each commit email contains a link to its details on github from where you can
find the Pull-Request and associated discussions.


Commit on github: https://github.com/Rust-GCC/gccrs/commit/7a839f9477ac9e4e3e6659ae0ffe6ef587b87dbb

The commit has been mentioned in the following issue(s):
 - Rust-GCC/gccrs#4858: https://github.com/Rust-GCC/gccrs/issues/4858

The commit has been mentioned in the following pull-request(s):
 - https://github.com/Rust-GCC/gccrs/pull/4871

 gcc/rust/typecheck/rust-hir-type-check-expr.cc |  2 ++
 gcc/testsuite/rust/compile/issue-4858.rs       | 10 ++++++++++
 2 files changed, 12 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issue-4858.rs

diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 7f8547f53..a1e4fb5d8 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -612,6 +612,8 @@ TypeCheckExpr::visit (HIR::NegationExpr &expr)
 	  = (negated_expr_ty->get_kind () == TyTy::TypeKind::BOOL)
 	    || (negated_expr_ty->get_kind () == TyTy::TypeKind::INT)
 	    || (negated_expr_ty->get_kind () == TyTy::TypeKind::UINT)
+	    || (negated_expr_ty->get_kind () == TyTy::TypeKind::ISIZE)
+	    || (negated_expr_ty->get_kind () == TyTy::TypeKind::USIZE)
 	    || (negated_expr_ty->get_kind () == TyTy::TypeKind::INFER
 		&& (((TyTy::InferType *) negated_expr_ty)->get_infer_kind ()
 		    == TyTy::InferType::INTEGRAL));
diff --git a/gcc/testsuite/rust/compile/issue-4858.rs b/gcc/testsuite/rust/compile/issue-4858.rs
new file mode 100644
index 000000000..aab574287
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issue-4858.rs
@@ -0,0 +1,10 @@
+#![feature(no_core)]
+#![no_core]
+
+pub fn signed(x: isize) -> isize {
+    !x
+}
+
+pub fn unsigned(x: usize) -> usize {
+    !x
+}
-- 
2.55.0



More information about the Gcc-rust mailing list