Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ADT hover considering only type or const len not lifetimes #16967

Merged
merged 1 commit into from Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/hir/src/lib.rs
Expand Up @@ -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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having a GenericParam::is_empty method would probably be useful here (or given there is more than just params in it, a GenericParam::has_params)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I open a PR with the proposed change of this and the proposed change in another PR?

Feel like a opening a lot of small PRs 😅.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting both into one is fine

return Err(LayoutError::HasPlaceholder);
}
let krate = self.krate(db).id;
Expand Down
22 changes: 22 additions & 0 deletions crates/ide/src/hover/tests.rs
Expand Up @@ -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>
```
"#]],
)
}