]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Fix ICE when resolving lifetimes without name
authorPhilip Herron <herron.philip@googlemail.com>
Mon, 31 Mar 2025 16:33:59 +0000 (17:33 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 8 Apr 2025 08:17:12 +0000 (10:17 +0200)
We dont need to assert here the lifetime code already supports this case.

Fixes Rust-GCC#3657

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-base.cc: remove assertion

gcc/testsuite/ChangeLog:

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

Signed-off-by: Philip Herron <herron.philip@googlemail.com>
gcc/rust/typecheck/rust-hir-type-check-base.cc
gcc/testsuite/rust/compile/issue-3657.rs [new file with mode: 0644]

index 34a726cc6650dd745190b6143590a14f36dd7470..d3d688217348f96b66740eb678b61675c00111ec 100644 (file)
@@ -397,8 +397,6 @@ TypeCheckBase::resolve_generic_params (
            auto lifetime_param
              = static_cast<HIR::LifetimeParam &> (*generic_param);
            auto lifetime = lifetime_param.get_lifetime ();
-           rust_assert (lifetime.get_lifetime_type ()
-                        == AST::Lifetime::LifetimeType::NAMED);
            context->get_lifetime_resolver ().insert_mapping (
              context->intern_lifetime (lifetime));
          }
diff --git a/gcc/testsuite/rust/compile/issue-3657.rs b/gcc/testsuite/rust/compile/issue-3657.rs
new file mode 100644 (file)
index 0000000..978f3ce
--- /dev/null
@@ -0,0 +1,8 @@
+struct Foo<'_>(&'_ u8);
+
+impl Foo<'a> {
+    // { dg-error "unresolved lifetime" "" { target *-*-* } .-1 }
+    fn x() {}
+}
+
+fn x() {}