Skip to content

Commit 9ee0c3a

Browse files
committed
Do not rely on newtype enum dereference
1 parent 451c943 commit 9ee0c3a

File tree

5 files changed

+28
-36
lines changed

5 files changed

+28
-36
lines changed

src/librustc/front/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use front::config;
1717
use std::vec;
1818
use syntax::ast_util::*;
1919
use syntax::attr;
20-
use syntax::codemap::{dummy_sp, span, ExpandedFrom, CallInfo, NameAndSpan};
20+
use syntax::codemap::{dummy_sp, span, ExpnInfo, NameAndSpan};
2121
use syntax::codemap;
2222
use syntax::ext::base::ExtCtxt;
2323
use syntax::fold;
@@ -72,13 +72,13 @@ fn generate_test_harness(sess: session::Session,
7272
};
7373

7474
let ext_cx = cx.ext_cx;
75-
ext_cx.bt_push(ExpandedFrom(CallInfo {
75+
ext_cx.bt_push(ExpnInfo {
7676
call_site: dummy_sp(),
7777
callee: NameAndSpan {
7878
name: @"test",
7979
span: None
8080
}
81-
}));
81+
});
8282

8383
let precursor = @fold::AstFoldFns {
8484
fold_crate: fold::wrap(|a,b| fold_crate(cx, a, b) ),

src/libsyntax/codemap.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -174,18 +174,13 @@ pub struct FileMapAndBytePos {fm: @FileMap, pos: BytePos}
174174
#[deriving(IterBytes)]
175175
pub struct NameAndSpan {name: @str, span: Option<span>}
176176

177+
/// Extra information for tracking macro expansion of spans
177178
#[deriving(IterBytes)]
178-
pub struct CallInfo {
179+
pub struct ExpnInfo {
179180
call_site: span,
180181
callee: NameAndSpan
181182
}
182183

183-
/// Extra information for tracking macro expansion of spans
184-
#[deriving(IterBytes)]
185-
pub enum ExpnInfo {
186-
ExpandedFrom(CallInfo)
187-
}
188-
189184
pub type FileName = @str;
190185

191186
pub struct FileLines

src/libsyntax/ext/base.rs

+7-10
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
use ast;
1212
use ast::Name;
1313
use codemap;
14-
use codemap::{CodeMap, span, ExpnInfo, ExpandedFrom};
15-
use codemap::CallInfo;
14+
use codemap::{CodeMap, span, ExpnInfo};
1615
use diagnostic::span_handler;
1716
use ext;
1817
use parse;
@@ -243,7 +242,7 @@ impl ExtCtxt {
243242
pub fn cfg(&self) -> ast::crate_cfg { copy self.cfg }
244243
pub fn call_site(&self) -> span {
245244
match *self.backtrace {
246-
Some(@ExpandedFrom(CallInfo {call_site: cs, _})) => cs,
245+
Some(@ExpnInfo {call_site: cs, _}) => cs,
247246
None => self.bug("missing top span")
248247
}
249248
}
@@ -254,21 +253,19 @@ impl ExtCtxt {
254253
pub fn mod_path(&self) -> ~[ast::ident] { copy *self.mod_path }
255254
pub fn bt_push(&self, ei: codemap::ExpnInfo) {
256255
match ei {
257-
ExpandedFrom(CallInfo {call_site: cs, callee: ref callee}) => {
256+
ExpnInfo {call_site: cs, callee: ref callee} => {
258257
*self.backtrace =
259-
Some(@ExpandedFrom(CallInfo {
258+
Some(@ExpnInfo {
260259
call_site: span {lo: cs.lo, hi: cs.hi,
261260
expn_info: *self.backtrace},
262-
callee: copy *callee}));
261+
callee: copy *callee});
263262
}
264263
}
265264
}
266265
pub fn bt_pop(&self) {
267266
match *self.backtrace {
268-
Some(@ExpandedFrom(
269-
CallInfo {
270-
call_site: span {expn_info: prev, _}, _
271-
})) => {
267+
Some(@ExpnInfo {
268+
call_site: span {expn_info: prev, _}, _}) => {
272269
*self.backtrace = prev
273270
}
274271
_ => self.bug("tried to pop without a push")

src/libsyntax/ext/expand.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use ast;
1616
use ast_util::{new_rename, new_mark, resolve};
1717
use attr;
1818
use codemap;
19-
use codemap::{span, CallInfo, ExpandedFrom, NameAndSpan, spanned};
19+
use codemap::{span, ExpnInfo, NameAndSpan, spanned};
2020
use ext::base::*;
2121
use fold::*;
2222
use parse;
@@ -60,13 +60,13 @@ pub fn expand_expr(extsbox: @mut SyntaxEnv,
6060
expander: exp,
6161
span: exp_sp
6262
}))) => {
63-
cx.bt_push(ExpandedFrom(CallInfo {
63+
cx.bt_push(ExpnInfo {
6464
call_site: s,
6565
callee: NameAndSpan {
6666
name: extnamestr,
6767
span: exp_sp,
6868
},
69-
}));
69+
});
7070

7171
let expanded = match exp(cx, mac.span, *tts) {
7272
MRExpr(e) => e,
@@ -131,13 +131,13 @@ pub fn expand_mod_items(extsbox: @mut SyntaxEnv,
131131

132132
match (*extsbox).find(&intern(mname)) {
133133
Some(@SE(ItemDecorator(dec_fn))) => {
134-
cx.bt_push(ExpandedFrom(CallInfo {
134+
cx.bt_push(ExpnInfo {
135135
call_site: attr.span,
136136
callee: NameAndSpan {
137137
name: mname,
138138
span: None
139139
}
140-
}));
140+
});
141141
let r = dec_fn(cx, attr.span, attr.node.value, items);
142142
cx.bt_pop();
143143
r
@@ -227,13 +227,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
227227
given '%s'", extnamestr,
228228
ident_to_str(&it.ident)));
229229
}
230-
cx.bt_push(ExpandedFrom(CallInfo {
230+
cx.bt_push(ExpnInfo {
231231
call_site: it.span,
232232
callee: NameAndSpan {
233233
name: extnamestr,
234234
span: expand.span
235235
}
236-
}));
236+
});
237237
((*expand).expander)(cx, it.span, tts)
238238
}
239239
Some(@SE(IdentTT(ref expand))) => {
@@ -242,13 +242,13 @@ pub fn expand_item_mac(extsbox: @mut SyntaxEnv,
242242
fmt!("macro %s! expects an ident argument",
243243
extnamestr));
244244
}
245-
cx.bt_push(ExpandedFrom(CallInfo {
245+
cx.bt_push(ExpnInfo {
246246
call_site: it.span,
247247
callee: NameAndSpan {
248248
name: extnamestr,
249249
span: expand.span
250250
}
251-
}));
251+
});
252252
((*expand).expander)(cx, it.span, it.ident, tts)
253253
}
254254
_ => cx.span_fatal(
@@ -319,10 +319,10 @@ pub fn expand_stmt(extsbox: @mut SyntaxEnv,
319319

320320
Some(@SE(NormalTT(
321321
SyntaxExpanderTT{expander: exp, span: exp_sp}))) => {
322-
cx.bt_push(ExpandedFrom(CallInfo {
322+
cx.bt_push(ExpnInfo {
323323
call_site: sp,
324324
callee: NameAndSpan { name: extnamestr, span: exp_sp }
325-
}));
325+
});
326326
let expanded = match exp(cx, mac.span, tts) {
327327
MRExpr(e) =>
328328
@codemap::spanned { node: stmt_expr(e, cx.next_id()),

src/libsyntax/ext/source_util.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
use ast;
1212
use codemap;
13-
use codemap::{Pos, ExpandedFrom, span};
14-
use codemap::{CallInfo, NameAndSpan};
13+
use codemap::{Pos, span};
14+
use codemap::{ExpnInfo, NameAndSpan};
1515
use ext::base::*;
1616
use ext::base;
1717
use ext::build::AstBuilder;
@@ -117,14 +117,14 @@ pub fn expand_include_bin(cx: @ExtCtxt, sp: span, tts: &[ast::token_tree])
117117
// recur along an ExpnInfo chain to find the original expression
118118
fn topmost_expn_info(expn_info: @codemap::ExpnInfo) -> @codemap::ExpnInfo {
119119
match *expn_info {
120-
ExpandedFrom(CallInfo { call_site: ref call_site, _ }) => {
120+
ExpnInfo { call_site: ref call_site, _ } => {
121121
match call_site.expn_info {
122122
Some(next_expn_info) => {
123123
match *next_expn_info {
124-
ExpandedFrom(CallInfo {
124+
ExpnInfo {
125125
callee: NameAndSpan { name: ref name, _ },
126126
_
127-
}) => {
127+
} => {
128128
// Don't recurse into file using "include!"
129129
if "include" == *name {
130130
expn_info

0 commit comments

Comments
 (0)