Repository: rust-lang/rust-analyzer (rust)

Issue:
Panic on hovering over type name with lifetime argument
When hovering over the name of a type with a lifetime parameter, a panic occurs and [this error](https://github.com/rust-lang/rust-analyzer/files/14781790/stderr.txt) is printed to stderr. VS Code shows a popup with a "Request textDocument/hover failed." message.

**rust-analyzer version**: 0.4.1899-standalone (4b33850c3 2024-03-26)

**rustc version**: rustc 1.79.0-nightly (47ecded35 2024-03-26)

**code snippet to reproduce**:
Create a new empty project, then paste the following snippet:
```rust
fn main() {
    println!("Hello, world!");
}

struct Pedro<'a> {
    hola: &'a str
}
```
Now hover your mouse over the word `Pedro` and the panic will occur.

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_ASSIGN_START -->

<!-- TRIAGEBOT_ASSIGN_DATA_START$${"user":"dfireBird"}$$TRIAGEBOT_ASSIGN_DATA_END -->

<!-- TRIAGEBOT_ASSIGN_END -->
<!-- TRIAGEBOT_END -->

Pull request description:
fix: ADT hover considering only type or const len not lifetimes
I feel like test doesn't do much. Please suggest if I should improve it?

Fixes #16963 

Patch:
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index b4388ad965..cf6297c037 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -1418,7 +1418,8 @@ impl Adt {
     }
 
     pub fn layout(self, db: &dyn HirDatabase) -> Result<Layout, LayoutError> {
-        if db.generic_params(self.into()).iter().count() != 0 {
+        let generic_params = &db.generic_params(self.into());
+        if generic_params.iter().next().is_some() || generic_params.iter_lt().next().is_some() {
             return Err(LayoutError::HasPlaceholder);
         }
         let krate = self.krate(db).id;


Test patch:
diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs
index 192f6c0272..08925fcdff 100644
--- a/crates/ide/src/hover/tests.rs
+++ b/crates/ide/src/hover/tests.rs
@@ -7856,3 +7856,25 @@ impl Iterator for S {
         "#]],
     );
 }
+
+#[test]
+fn hover_lifetime_regression_16963() {
+    check(
+        r#"
+struct Pedro$0<'a> {
+    hola: &'a str
+}
+"#,
+        expect![[r#"
+            *Pedro*
+
+            ```rust
+            test
+            ```
+
+            ```rust
+            struct Pedro<'a>
+            ```
+        "#]],
+    )
+}