@@ -47,7 +47,7 @@ fn fold_fn(
47
47
48
48
fn get_fn_sig ( srv : astsrv:: srv , fn_id : doc:: ast_id ) -> option < ~str > {
49
49
do astsrv:: exec ( srv) |ctxt| {
50
- match check ctxt. ast_map . get ( fn_id) {
50
+ match ctxt. ast_map . get ( fn_id) {
51
51
ast_map:: node_item( @{
52
52
ident: ident,
53
53
node: ast:: item_fn( decl, tys, _) , _
@@ -58,6 +58,7 @@ fn get_fn_sig(srv: astsrv::srv, fn_id: doc::ast_id) -> option<~str> {
58
58
} , _, _) => {
59
59
some ( pprust:: fun_to_str ( decl, ident, tys, extract:: interner ( ) ) )
60
60
}
61
+ _ => fail ~"get_fn_sig: fn_id not bound to a fn item"
61
62
}
62
63
}
63
64
}
@@ -82,12 +83,13 @@ fn fold_const(
82
83
83
84
{
84
85
sig: some ( do astsrv:: exec ( srv) |ctxt| {
85
- match check ctxt. ast_map . get ( doc. id ( ) ) {
86
+ match ctxt. ast_map . get ( doc. id ( ) ) {
86
87
ast_map:: node_item( @{
87
88
node: ast:: item_const( ty, _) , _
88
89
} , _) => {
89
90
pprust:: ty_to_str ( ty, extract:: interner ( ) )
90
91
}
92
+ _ => fail ~"fold_const: id not bound to a const item"
91
93
}
92
94
} )
93
95
with doc
@@ -110,7 +112,7 @@ fn fold_enum(
110
112
{
111
113
variants: do par:: map ( doc. variants ) |variant| {
112
114
let sig = do astsrv:: exec ( srv) |ctxt| {
113
- match check ctxt. ast_map . get ( doc_id) {
115
+ match ctxt. ast_map . get ( doc_id) {
114
116
ast_map:: node_item( @{
115
117
node: ast:: item_enum( enum_definition, _) , _
116
118
} , _) => {
@@ -121,6 +123,7 @@ fn fold_enum(
121
123
122
124
pprust:: variant_to_str ( ast_variant, extract:: interner ( ) )
123
125
}
126
+ _ => fail ~"enum variant not bound to an enum item"
124
127
}
125
128
} ;
126
129
@@ -168,11 +171,11 @@ fn get_method_sig(
168
171
method_name : ~str
169
172
) -> option < ~str > {
170
173
do astsrv:: exec ( srv) |ctxt| {
171
- match check ctxt. ast_map . get ( item_id) {
174
+ match ctxt. ast_map . get ( item_id) {
172
175
ast_map:: node_item( @{
173
176
node: ast:: item_trait( _, _, methods) , _
174
177
} , _) => {
175
- match check vec:: find ( methods, |method| {
178
+ match vec:: find ( methods, |method| {
176
179
match method {
177
180
ast:: required( ty_m) => to_str ( ty_m. ident ) == method_name,
178
181
ast:: provided( m) => to_str ( m. ident ) == method_name,
@@ -198,12 +201,13 @@ fn get_method_sig(
198
201
}
199
202
}
200
203
}
204
+ _ => fail ~"method not found"
201
205
}
202
206
}
203
207
ast_map:: node_item( @{
204
208
node: ast:: item_impl( _, _, _, methods) , _
205
209
} , _) => {
206
- match check vec:: find ( methods, |method| {
210
+ match vec:: find ( methods, |method| {
207
211
to_str ( method. ident ) == method_name
208
212
} ) {
209
213
some( method) => {
@@ -214,8 +218,10 @@ fn get_method_sig(
214
218
extract:: interner ( )
215
219
) )
216
220
}
221
+ none => fail ~"method not found"
217
222
}
218
223
}
224
+ _ => fail ~"get_method_sig: item ID not bound to trait or impl"
219
225
}
220
226
}
221
227
}
0 commit comments