File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change @@ -86,7 +86,8 @@ fn default_seq_fold_mod<T>(
86
86
) -> doc:: moddoc {
87
87
~{
88
88
mods: fold. fold_modlist ( fold, doc. mods ) ,
89
- fns: fold. fold_fnlist ( fold, doc. fns )
89
+ fns: fold. fold_fnlist ( fold, doc. fns ) ,
90
+ consts: fold. fold_constlist ( fold, doc. consts )
90
91
with * doc
91
92
}
92
93
}
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ fn run(
16
16
doc : doc:: cratedoc
17
17
) -> doc:: cratedoc {
18
18
let fold = fold:: fold ( {
19
- fold_fn: fold_fn
19
+ fold_fn: fold_fn,
20
+ fold_const: fold_const
20
21
with * fold:: default_seq_fold ( srv)
21
22
} ) ;
22
23
fold. fold_crate ( fold, doc)
@@ -149,4 +150,33 @@ fn should_add_arg_types() {
149
150
let fn_ = doc. topmod . fns [ 0 ] ;
150
151
assert fn_. args [ 0 ] . ty == some ( "int" ) ;
151
152
assert fn_. args [ 1 ] . ty == some ( "bool" ) ;
153
+ }
154
+
155
+ fn fold_const (
156
+ fold : fold:: fold < astsrv:: srv > ,
157
+ doc : doc:: constdoc
158
+ ) -> doc:: constdoc {
159
+ let srv = fold. ctxt ;
160
+
161
+ ~{
162
+ ty: some ( astsrv:: exec ( srv) { |ctxt|
163
+ alt ctxt. map . get ( doc. id ) {
164
+ ast_map:: node_item ( @{
165
+ node: ast:: item_const ( ty, _) , _
166
+ } ) {
167
+ pprust:: ty_to_str ( ty)
168
+ }
169
+ }
170
+ } )
171
+ with * doc
172
+ }
173
+ }
174
+
175
+ #[ test]
176
+ fn should_add_const_types ( ) {
177
+ let source = "const a: bool = true;" ;
178
+ let srv = astsrv:: mk_srv_from_str ( source) ;
179
+ let doc = extract:: from_srv ( srv, "" ) ;
180
+ let doc = run ( srv, doc) ;
181
+ assert doc. topmod . consts [ 0 ] . ty == some ( "bool" ) ;
152
182
}
You can’t perform that action at this time.
0 commit comments