Skip to content

Commit 24ef905

Browse files
committed
Remove FakeExtCtxt from qquote tests.
Instead create an ExtCtxt structure.
1 parent ea892dc commit 24ef905

File tree

2 files changed

+30
-56
lines changed

2 files changed

+30
-56
lines changed

src/test/compile-fail-fulldeps/qquote.rs

+15-28
Original file line numberDiff line numberDiff line change
@@ -15,38 +15,25 @@
1515
extern crate syntax;
1616

1717
use syntax::ast;
18-
use syntax::codemap;
18+
use syntax::codemap::{self, DUMMY_SP};
1919
use syntax::parse;
2020
use syntax::print::pprust;
2121

22-
trait FakeExtCtxt {
23-
fn call_site(&self) -> codemap::Span;
24-
fn cfg(&self) -> ast::CrateConfig;
25-
fn ident_of(&self, st: &str) -> ast::Ident;
26-
fn name_of(&self, st: &str) -> ast::Name;
27-
fn parse_sess(&self) -> &parse::ParseSess;
28-
}
29-
30-
impl FakeExtCtxt for parse::ParseSess {
31-
fn call_site(&self) -> codemap::Span {
32-
codemap::Span {
33-
lo: codemap::BytePos(0),
34-
hi: codemap::BytePos(0),
35-
expn_id: codemap::NO_EXPANSION,
36-
}
37-
}
38-
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
39-
fn ident_of(&self, st: &str) -> ast::Ident {
40-
parse::token::str_to_ident(st)
41-
}
42-
fn name_of(&self, st: &str) -> ast::Name {
43-
parse::token::intern(st)
44-
}
45-
fn parse_sess(&self) -> &parse::ParseSess { self }
46-
}
47-
4822
fn main() {
49-
let cx = parse::new_parse_sess();
23+
let ps = syntax::parse::new_parse_sess();
24+
let mut cx = syntax::ext::base::ExtCtxt::new(
25+
&ps, vec![],
26+
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()));
27+
cx.bt_push(syntax::codemap::ExpnInfo {
28+
call_site: DUMMY_SP,
29+
callee: syntax::codemap::NameAndSpan {
30+
name: "".to_string(),
31+
format: syntax::codemap::MacroBang,
32+
allow_internal_unstable: false,
33+
span: None,
34+
}
35+
});
36+
let cx = &mut cx;
5037

5138
assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
5239

src/test/run-fail/qquote.rs

+15-28
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,25 @@
1717
extern crate syntax;
1818

1919
use syntax::ast;
20-
use syntax::codemap;
20+
use syntax::codemap::{self, DUMMY_SP};
2121
use syntax::parse;
2222
use syntax::print::pprust;
2323

24-
trait FakeExtCtxt {
25-
fn call_site(&self) -> codemap::Span;
26-
fn cfg(&self) -> ast::CrateConfig;
27-
fn ident_of(&self, st: &str) -> ast::Ident;
28-
fn name_of(&self, st: &str) -> ast::Name;
29-
fn parse_sess(&self) -> &parse::ParseSess;
30-
}
31-
32-
impl FakeExtCtxt for parse::ParseSess {
33-
fn call_site(&self) -> codemap::Span {
34-
codemap::Span {
35-
lo: codemap::BytePos(0),
36-
hi: codemap::BytePos(0),
37-
expn_id: codemap::NO_EXPANSION,
38-
}
39-
}
40-
fn cfg(&self) -> ast::CrateConfig { Vec::new() }
41-
fn ident_of(&self, st: &str) -> ast::Ident {
42-
parse::token::str_to_ident(st)
43-
}
44-
fn name_of(&self, st: &str) -> ast::Name {
45-
parse::token::intern(st)
46-
}
47-
fn parse_sess(&self) -> &parse::ParseSess { self }
48-
}
49-
5024
fn main() {
51-
let cx = parse::new_parse_sess();
25+
let ps = syntax::parse::new_parse_sess();
26+
let mut cx = syntax::ext::base::ExtCtxt::new(
27+
&ps, vec![],
28+
syntax::ext::expand::ExpansionConfig::default("qquote".to_string()));
29+
cx.bt_push(syntax::codemap::ExpnInfo {
30+
call_site: DUMMY_SP,
31+
callee: syntax::codemap::NameAndSpan {
32+
name: "".to_string(),
33+
format: syntax::codemap::MacroBang,
34+
allow_internal_unstable: false,
35+
span: None,
36+
}
37+
});
38+
let cx = &mut cx;
5239

5340
assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
5441

0 commit comments

Comments
 (0)