@@ -28,6 +28,7 @@ fn syntax_expander_table() -> hashmap[str, syntax_extension] {
28
28
}
29
29
30
30
type span_msg_fn = fn ( span , str ) -> ! ;
31
+ type msg_fn = fn ( str ) -> ! ;
31
32
32
33
type next_id_fn = fn ( ) -> ast:: node_id ;
33
34
@@ -38,6 +39,8 @@ type ext_ctxt =
38
39
rec ( str crate_file_name_hack ,
39
40
span_msg_fn span_fatal,
40
41
span_msg_fn span_unimpl,
42
+ span_msg_fn span_bug,
43
+ msg_fn bug,
41
44
next_id_fn next_id) ;
42
45
43
46
fn mk_ctxt ( & session sess) -> ext_ctxt {
@@ -50,6 +53,18 @@ fn mk_ctxt(&session sess) -> ext_ctxt {
50
53
sess. span_err ( sp, "unimplemented " + msg) ;
51
54
fail;
52
55
}
56
+ auto ext_span_unimpl = bind ext_span_unimpl_ ( sess, _, _) ;
57
+ fn ext_span_bug_ ( & session sess, span sp, str msg) -> ! {
58
+ sess. span_bug ( sp, msg) ;
59
+ fail;
60
+ }
61
+ auto ext_span_bug = bind ext_span_bug_ ( sess, _, _) ;
62
+ fn ext_bug_ ( & session sess, str msg) -> ! {
63
+ sess. bug ( msg) ;
64
+ fail;
65
+ }
66
+ auto ext_bug = bind ext_bug_ ( sess, _) ;
67
+
53
68
54
69
// FIXME: Some extensions work by building ASTs with paths to functions
55
70
// they need to call at runtime. As those functions live in the std crate,
@@ -59,14 +74,16 @@ fn mk_ctxt(&session sess) -> ext_ctxt {
59
74
// use it to guess whether paths should be prepended with "std::". This is
60
75
// super-ugly and needs a better solution.
61
76
auto crate_file_name_hack = sess. get_codemap ( ) . files . ( 0 ) . name ;
62
- auto ext_span_unimpl = bind ext_span_unimpl_ ( sess , _ , _ ) ;
77
+
63
78
fn ext_next_id_ ( & session sess) -> ast:: node_id {
64
79
ret sess. next_node_id ( ) ; // temporary, until bind works better
65
80
}
66
81
auto ext_next_id = bind ext_next_id_ ( sess) ;
67
82
ret rec( crate_file_name_hack=crate_file_name_hack,
68
83
span_fatal=ext_span_fatal,
69
84
span_unimpl=ext_span_unimpl,
85
+ span_bug=ext_span_bug,
86
+ bug=ext_bug,
70
87
next_id=ext_next_id) ;
71
88
}
72
89
0 commit comments