Skip to content

Commit 41fe41a

Browse files
[lean backend] Add HasKind for Ty instead of having a pub field
1 parent 9b57ab3 commit 41fe41a

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

rust-engine/src/ast.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ pub struct Region;
6767

6868
/// A indirection for the representation of types.
6969
#[derive_group_for_ast]
70-
pub struct Ty(pub Box<TyKind>);
70+
pub struct Ty(Box<TyKind>);
7171

7272
/// Describes any Rust type (e.g., `i32`, `Vec<T>`, `fn(i32) -> bool`).
7373
#[derive_group_for_ast]
@@ -1156,7 +1156,7 @@ pub enum AttributeKind {
11561156
Tool {
11571157
/// The path to the tool
11581158
path: String,
1159-
/// The payload
1159+
/// The payload
11601160
tokens: String,
11611161
},
11621162
/// A doc comment
@@ -1540,5 +1540,15 @@ pub mod traits {
15401540
}
15411541
}
15421542
}
1543+
1544+
/// Manual implementation of HasKind as the Ty struct contains a Box<TyKind>
1545+
/// instead of a TyKind directly.
1546+
impl HasKind for Ty {
1547+
type Kind = TyKind;
1548+
1549+
fn kind(&self) -> &Self::Kind {
1550+
&(*self.0)
1551+
}
1552+
}
15431553
}
15441554
pub use traits::*;

rust-engine/src/lean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl<'a, 'b> Pretty<'a, Allocator<Lean>, Span> for &'b ItemKind {
9797

9898
impl<'a, 'b> Pretty<'a, Allocator<Lean>, Span> for &'b Ty {
9999
fn pretty(self, allocator: &'a Allocator<Lean>) -> DocBuilder<'a, Allocator<Lean>, Span> {
100-
self.0.pretty(allocator)
100+
self.kind().pretty(allocator)
101101
}
102102
}
103103

0 commit comments

Comments
 (0)