From: Philip Herron <[email protected]>

Fixes Rust-GCC/gccrs#4912

gcc/rust/ChangeLog:

        * typecheck/rust-hir-trait-resolve.cc (TraitResolver::resolve_trait): 
add missing

gcc/testsuite/ChangeLog:

        * rust/compile/issues/4912.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
---
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/5b586acf5d775637f4eba56f565b1b9971613a48

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

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

 gcc/rust/typecheck/rust-hir-trait-resolve.cc | 10 ++++++++++
 gcc/testsuite/rust/compile/issues/4912.rs    | 11 +++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 gcc/testsuite/rust/compile/issues/4912.rs

diff --git a/gcc/rust/typecheck/rust-hir-trait-resolve.cc 
b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
index c80899979..b69452153 100644
--- a/gcc/rust/typecheck/rust-hir-trait-resolve.cc
+++ b/gcc/rust/typecheck/rust-hir-trait-resolve.cc
@@ -283,6 +283,8 @@ TraitResolver::resolve_trait (HIR::Trait *trait_reference)
   TyTy::BaseType *self = nullptr;
   std::vector<TyTy::SubstitutionParamMapping> substitutions;
 
+  auto lifetime_pin = context->push_clean_lifetime_resolver ();
+
   // this needs to be special cased for the sized trait to not auto implemented
   // Sized on Self
   for (auto &generic_param : trait_reference->get_generic_params ())
@@ -290,6 +292,14 @@ TraitResolver::resolve_trait (HIR::Trait *trait_reference)
       switch (generic_param.get ()->get_kind ())
        {
        case HIR::GenericParam::GenericKind::LIFETIME:
+         {
+           auto &lifetime_param
+             = static_cast<HIR::LifetimeParam &> (*generic_param);
+           context->intern_and_insert_lifetime (
+             lifetime_param.get_lifetime ());
+         }
+         break;
+
        case HIR::GenericParam::GenericKind::CONST:
          // FIXME: Skipping Lifetime and Const completely until better
          // handling.
diff --git a/gcc/testsuite/rust/compile/issues/4912.rs 
b/gcc/testsuite/rust/compile/issues/4912.rs
new file mode 100644
index 000000000..4c3571331
--- /dev/null
+++ b/gcc/testsuite/rust/compile/issues/4912.rs
@@ -0,0 +1,11 @@
+#![feature(no_core, lang_items)]
+#![no_core]
+
+#[lang = "sized"]
+pub trait Sized {}
+
+pub trait Searcher<'a> {}
+
+pub trait ReverseSearcher<'a>: Searcher<'a> {}
+
+fn main() {}

base-commit: 884c26f09db98cc5ac1477fc92bfaebd7e2a8aab
-- 
2.55.0

Reply via email to