]> git.ipfire.org Git - thirdparty/gcc.git/commit
gccrs: Fix bad cast error to bool
authoremanuele-em <micheletti.emanuele@hotmail.com>
Wed, 29 Mar 2023 01:45:01 +0000 (03:45 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:28:38 +0000 (18:28 +0100)
commit41a104fadeae4776f7d8efd4157776910a3edfe7
tree1e4cdfcbbb104d4e7bb4aebdd065a6323f41c8c1
parent79d56acad2eea8af518b28051d28c0996db5874d
gccrs: Fix bad cast error to bool

In rust is not allowed to cast from int to bool. This patch handles the case when we cast a integer to bool with 'as bool'

Fixes #2026

gcc/rust/ChangeLog:

* typecheck/rust-casts.cc (TypeCastRules::cast_rules): BOOL removed from switch cases

gcc/testsuite/ChangeLog:

* rust/compile/cast4.rs: New test.

Signed-off-by: Emanuele Micheletti <micheletti.emanuele@hotmail.com>
gcc/rust/typecheck/rust-casts.cc
gcc/testsuite/rust/compile/cast4.rs [new file with mode: 0644]