diff options
| author | dfireBird <me@dfirebird.dev> | 2024-03-28 20:31:15 +0530 |
|---|---|---|
| committer | dfireBird <me@dfirebird.dev> | 2024-03-28 21:53:22 +0530 |
| commit | 34a8cd6a7ab58d6d53d9c3af1fed2f4cc18a9e0e (patch) | |
| tree | 95e9227bc8e4a8856349b9dfc95bb7296cffd105 | |
| parent | 899db83128a151359bb1c58f6ede7f663635e2b1 (diff) | |
| download | rust-34a8cd6a7ab58d6d53d9c3af1fed2f4cc18a9e0e.tar.gz rust-34a8cd6a7ab58d6d53d9c3af1fed2f4cc18a9e0e.zip | |
fix ADT hover considering only type or const len not lifetimes
| -rw-r--r-- | crates/hir/src/lib.rs | 3 | ||||
| -rw-r--r-- | crates/ide/src/hover/tests.rs | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index b4388ad9656..cf6297c0370 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; diff --git a/crates/ide/src/hover/tests.rs b/crates/ide/src/hover/tests.rs index 192f6c0272b..08925fcdff5 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> + ``` + "#]], + ) +} |
