Translating the AST LifetimeType to the HIR LifetimeType causes a warning:
warning: ‘ltt’ may be used uninitialized

Add a default clause to the switch statement calling gcc_unreachable.
This will suppress the warning and make sure that if the AST lifetime type
is invalid or a new unknown type we immediately know when lowering the AST.
---
 gcc/rust/hir/rust-ast-lower-type.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/rust/hir/rust-ast-lower-type.h 
b/gcc/rust/hir/rust-ast-lower-type.h
index 5e19850e8dd..568a806f98d 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -281,6 +281,8 @@ public:
       case AST::Lifetime::LifetimeType::WILDCARD:
        ltt = HIR::Lifetime::LifetimeType::WILDCARD;
        break;
+      default:
+       gcc_unreachable ();
       }
 
     HIR::Lifetime lt (mapping, ltt, param.get_lifetime ().get_lifetime_name (),
-- 
2.32.0

-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust

Reply via email to