Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir/src/display.rs')
-rw-r--r--crates/hir/src/display.rs33
1 files changed, 22 insertions, 11 deletions
diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs
index c5d44c11f2..23c6b078b9 100644
--- a/crates/hir/src/display.rs
+++ b/crates/hir/src/display.rs
@@ -186,18 +186,29 @@ impl HirDisplay for Struct {
}
StructKind::Record => {
let has_where_clause = write_where_clause(def_id, f)?;
- let fields = self.fields(f.db);
- f.write_char(if !has_where_clause { ' ' } else { '\n' })?;
- if fields.is_empty() {
- f.write_str("{}")?;
- } else {
- f.write_str("{\n")?;
- for field in self.fields(f.db) {
- f.write_str(" ")?;
- field.hir_fmt(f)?;
- f.write_str(",\n")?;
+ if let Some(limit) = f.entity_limit {
+ let fields = self.fields(f.db);
+ let count = fields.len().min(limit);
+ f.write_char(if !has_where_clause { ' ' } else { '\n' })?;
+ if count == 0 {
+ if fields.is_empty() {
+ f.write_str("{}")?;
+ } else {
+ f.write_str("{ /* … */ }")?;
+ }
+ } else {
+ f.write_str(" {\n")?;
+ for field in &fields[..count] {
+ f.write_str(" ")?;
+ field.hir_fmt(f)?;
+ f.write_str(",\n")?;
+ }
+
+ if fields.len() > count {
+ f.write_str(" /* … */\n")?;
+ }
+ f.write_str("}")?;
}
- f.write_str("}")?;
}
}
StructKind::Unit => _ = write_where_clause(def_id, f)?,