Skip to content

Commit ac83e34

Browse files
committed
rustc: Report unimplemented #fmt features with spans
1 parent dd58851 commit ac83e34

File tree

1 file changed

+22
-26
lines changed

1 file changed

+22
-26
lines changed

src/comp/front/extfmt.rs

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,8 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
149149

150150
// Produces an AST expression that represents a RT::conv record,
151151
// which tells the RT::conv* functions how to perform the conversion
152-
fn make_rt_conv_expr(parser p, common::span sp, &conv cnv) -> @ast::expr {
152+
fn make_rt_conv_expr(&ext_ctxt cx,
153+
parser p, common::span sp, &conv cnv) -> @ast::expr {
153154

154155
fn make_flags(parser p, common::span sp, vec[flag] flags)
155156
-> @ast::expr {
@@ -186,7 +187,8 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
186187
ret make_vec_expr(p, sp, flagexprs);
187188
}
188189

189-
fn make_count(parser p, common::span sp, &count cnt) -> @ast::expr {
190+
fn make_count(&ext_ctxt cx,
191+
parser p, common::span sp, &count cnt) -> @ast::expr {
190192
alt (cnt) {
191193
case (count_implied) {
192194
ret make_rt_path_expr(p, sp, "count_implied");
@@ -198,8 +200,7 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
198200
ret make_call(p, sp, count_is_path, count_is_args);
199201
}
200202
case (_) {
201-
log_err "not implemented";
202-
fail;
203+
cx.span_unimpl(sp, "unimplemented #fmt conversion");
203204
}
204205
}
205206
}
@@ -244,8 +245,8 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
244245
}
245246

246247
auto rt_conv_flags = make_flags(p, sp, cnv.flags);
247-
auto rt_conv_width = make_count(p, sp, cnv.width);
248-
auto rt_conv_precision = make_count(p, sp, cnv.precision);
248+
auto rt_conv_width = make_count(cx, p, sp, cnv.width);
249+
auto rt_conv_precision = make_count(cx, p, sp, cnv.precision);
249250
auto rt_conv_ty = make_ty(p, sp, cnv.ty);
250251
ret make_conv_rec(p,
251252
sp,
@@ -255,11 +256,11 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
255256
rt_conv_ty);
256257
}
257258

258-
fn make_conv_call(parser p, common::span sp, str conv_type,
259+
fn make_conv_call(&ext_ctxt cx, parser p, common::span sp, str conv_type,
259260
&conv cnv, @ast::expr arg) -> @ast::expr {
260261
auto fname = "conv_" + conv_type;
261262
auto path = make_path_vec(fname);
262-
auto cnv_expr = make_rt_conv_expr(p, sp, cnv);
263+
auto cnv_expr = make_rt_conv_expr(cx, p, sp, cnv);
263264
auto args = [cnv_expr, arg];
264265
ret make_call(p, arg.span, path, args);
265266
}
@@ -292,8 +293,7 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
292293
case (option::none) {
293294
}
294295
case (_) {
295-
log_err unsupported;
296-
fail;
296+
cx.span_unimpl(sp, unsupported);
297297
}
298298
}
299299

@@ -316,8 +316,7 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
316316
case (flag_left_zero_pad) {
317317
}
318318
case (_) {
319-
log_err unsupported;
320-
fail;
319+
cx.span_unimpl(sp, unsupported);
321320
}
322321
}
323322
}
@@ -328,8 +327,7 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
328327
case (count_is(_)) {
329328
}
330329
case (_) {
331-
log_err unsupported;
332-
fail;
330+
cx.span_unimpl(sp, unsupported);
333331
}
334332
}
335333

@@ -339,43 +337,41 @@ fn pieces_to_expr(&ext_ctxt cx, parser p, common::span sp,
339337
case (count_is(_)) {
340338
}
341339
case (_) {
342-
log_err unsupported;
343-
fail;
340+
cx.span_unimpl(sp, unsupported);
344341
}
345342
}
346343

347344
alt (cnv.ty) {
348345
case (ty_str) {
349-
ret make_conv_call(p, arg.span, "str", cnv, arg);
346+
ret make_conv_call(cx, p, arg.span, "str", cnv, arg);
350347
}
351348
case (ty_int(?sign)) {
352349
alt (sign) {
353350
case (signed) {
354-
ret make_conv_call(p, arg.span, "int", cnv, arg);
351+
ret make_conv_call(cx, p, arg.span, "int", cnv, arg);
355352
}
356353
case (unsigned) {
357-
ret make_conv_call(p, arg.span, "uint", cnv, arg);
354+
ret make_conv_call(cx, p, arg.span, "uint", cnv, arg);
358355
}
359356
}
360357
}
361358
case (ty_bool) {
362-
ret make_conv_call(p, arg.span, "bool", cnv, arg);
359+
ret make_conv_call(cx, p, arg.span, "bool", cnv, arg);
363360
}
364361
case (ty_char) {
365-
ret make_conv_call(p, arg.span, "char", cnv, arg);
362+
ret make_conv_call(cx, p, arg.span, "char", cnv, arg);
366363
}
367364
case (ty_hex(_)) {
368-
ret make_conv_call(p, arg.span, "uint", cnv, arg);
365+
ret make_conv_call(cx, p, arg.span, "uint", cnv, arg);
369366
}
370367
case (ty_bits) {
371-
ret make_conv_call(p, arg.span, "uint", cnv, arg);
368+
ret make_conv_call(cx, p, arg.span, "uint", cnv, arg);
372369
}
373370
case (ty_octal) {
374-
ret make_conv_call(p, arg.span, "uint", cnv, arg);
371+
ret make_conv_call(cx, p, arg.span, "uint", cnv, arg);
375372
}
376373
case (_) {
377-
log_err unsupported;
378-
fail;
374+
cx.span_unimpl(sp, unsupported);
379375
}
380376
}
381377
}

0 commit comments

Comments
 (0)