Skip to content

Commit

Permalink
Update tests and docs for hover_show_adtFieldsOrVariants
Browse files Browse the repository at this point in the history
  • Loading branch information
roife committed Apr 6, 2024
1 parent 281faa9 commit 4b8f51c
Show file tree
Hide file tree
Showing 5 changed files with 235 additions and 59 deletions.
23 changes: 4 additions & 19 deletions crates/hir/src/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,7 @@ impl HirDisplay for Struct {
StructKind::Record => {
let has_where_clause = write_where_clause(def_id, f)?;
if let Some(limit) = f.entity_limit {
display_fields_or_variants(
&self.fields(f.db),
has_where_clause,
limit,
f,
)?;
display_fields_or_variants(&self.fields(f.db), has_where_clause, limit, f)?;
}
}
StructKind::Unit => _ = write_where_clause(def_id, f)?,
Expand All @@ -213,12 +208,7 @@ impl HirDisplay for Enum {

let has_where_clause = write_where_clause(def_id, f)?;
if let Some(limit) = f.entity_limit {
display_fields_or_variants(
&self.variants(f.db),
has_where_clause,
limit,
f,
)?;
display_fields_or_variants(&self.variants(f.db), has_where_clause, limit, f)?;
}

Ok(())
Expand All @@ -235,12 +225,7 @@ impl HirDisplay for Union {

let has_where_clause = write_where_clause(def_id, f)?;
if let Some(limit) = f.entity_limit {
display_fields_or_variants(
&self.fields(f.db),
has_where_clause,
limit,
f,
)?;
display_fields_or_variants(&self.fields(f.db), has_where_clause, limit, f)?;
}
Ok(())
}
Expand All @@ -251,7 +236,7 @@ fn display_fields_or_variants<T: HirDisplay>(
has_where_clause: bool,
limit: usize,
f: &mut HirFormatter<'_>,
)-> Result<(), HirDisplayError> {
) -> Result<(), HirDisplayError> {
let count = fields_or_variants.len().min(limit);
f.write_char(if !has_where_clause { ' ' } else { '\n' })?;
if count == 0 {
Expand Down
Loading

0 comments on commit 4b8f51c

Please sign in to comment.