Skip to content

Commit 90cbe0c

Browse files
committed
De-@ ParseSess uses.
1 parent 555a239 commit 90cbe0c

File tree

16 files changed

+90
-109
lines changed

16 files changed

+90
-109
lines changed

src/librustc/driver/driver.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,10 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
146146
fn parse_cfgspecs(cfgspecs: Vec<~str> )
147147
-> ast::CrateConfig {
148148
cfgspecs.move_iter().map(|s| {
149-
let sess = parse::new_parse_sess();
150149
parse::parse_meta_from_source_str("cfgspec".to_str(),
151150
s,
152151
Vec::new(),
153-
sess)
152+
&parse::new_parse_sess())
154153
}).collect::<ast::CrateConfig>()
155154
}
156155

@@ -175,13 +174,13 @@ pub fn phase_1_parse_input(sess: &Session, cfg: ast::CrateConfig, input: &Input)
175174
let krate = time(sess.time_passes(), "parsing", (), |_| {
176175
match *input {
177176
FileInput(ref file) => {
178-
parse::parse_crate_from_file(&(*file), cfg.clone(), sess.parse_sess)
177+
parse::parse_crate_from_file(&(*file), cfg.clone(), &sess.parse_sess)
179178
}
180179
StrInput(ref src) => {
181180
parse::parse_crate_from_source_str(anon_src(),
182181
(*src).clone(),
183182
cfg.clone(),
184-
sess.parse_sess)
183+
&sess.parse_sess)
185184
}
186185
}
187186
});
@@ -241,7 +240,7 @@ pub fn phase_2_configure_and_expand(sess: &Session,
241240
deriving_hash_type_parameter: sess.features.default_type_params.get(),
242241
crate_id: crate_id.clone(),
243242
};
244-
syntax::ext::expand::expand_crate(sess.parse_sess,
243+
syntax::ext::expand::expand_crate(&sess.parse_sess,
245244
cfg,
246245
krate)
247246
});

src/librustc/driver/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ pub struct Session {
177177
targ_cfg: @Config,
178178
opts: @Options,
179179
cstore: metadata::cstore::CStore,
180-
parse_sess: @ParseSess,
180+
parse_sess: ParseSess,
181181
codemap: @codemap::CodeMap,
182182
// For a library crate, this is always none
183183
entry_fn: RefCell<Option<(NodeId, codemap::Span)>>,

src/librustc/front/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn generate_test_harness(sess: &Session, krate: ast::Crate)
166166
let loader = &mut Loader::new(sess);
167167
let mut cx: TestCtxt = TestCtxt {
168168
sess: sess,
169-
ext_cx: ExtCtxt::new(sess.parse_sess, sess.opts.cfg.clone(),
169+
ext_cx: ExtCtxt::new(&sess.parse_sess, sess.opts.cfg.clone(),
170170
ExpansionConfig {
171171
loader: loader,
172172
deriving_hash_type_parameter: false,

src/librustc/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,13 @@ fn parse_crate_attrs(sess: &session::Session, input: &d::Input) ->
350350
d::FileInput(ref ifile) => {
351351
parse::parse_crate_attrs_from_file(ifile,
352352
Vec::new(),
353-
sess.parse_sess)
353+
&sess.parse_sess)
354354
}
355355
d::StrInput(ref src) => {
356356
parse::parse_crate_attrs_from_source_str(d::anon_src(),
357357
(*src).clone(),
358358
Vec::new(),
359-
sess.parse_sess)
359+
&sess.parse_sess)
360360
}
361361
};
362362
result.move_iter().collect()

src/librustc/middle/astencode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,17 +1446,17 @@ fn decode_item_ast(par_doc: ebml::Doc) -> @ast::Item {
14461446
#[cfg(test)]
14471447
trait fake_ext_ctxt {
14481448
fn cfg(&self) -> ast::CrateConfig;
1449-
fn parse_sess(&self) -> @parse::ParseSess;
1449+
fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess;
14501450
fn call_site(&self) -> Span;
14511451
fn ident_of(&self, st: &str) -> ast::Ident;
14521452
}
14531453

14541454
#[cfg(test)]
1455-
impl fake_ext_ctxt for @parse::ParseSess {
1455+
impl fake_ext_ctxt for parse::ParseSess {
14561456
fn cfg(&self) -> ast::CrateConfig {
14571457
Vec::new()
14581458
}
1459-
fn parse_sess(&self) -> @parse::ParseSess { *self }
1459+
fn parse_sess<'a>(&'a self) -> &'a parse::ParseSess { self }
14601460
fn call_site(&self) -> Span {
14611461
codemap::Span {
14621462
lo: codemap::BytePos(0),
@@ -1470,7 +1470,7 @@ impl fake_ext_ctxt for @parse::ParseSess {
14701470
}
14711471

14721472
#[cfg(test)]
1473-
fn mk_ctxt() -> @parse::ParseSess {
1473+
fn mk_ctxt() -> parse::ParseSess {
14741474
parse::new_parse_sess()
14751475
}
14761476

src/librustdoc/html/highlight.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ pub fn highlight(src: &str, class: Option<&str>) -> ~str {
3030
let sess = parse::new_parse_sess();
3131
let handler = diagnostic::default_handler();
3232
let span_handler = diagnostic::mk_span_handler(handler, sess.cm);
33-
let fm = parse::string_to_filemap(sess, src.to_owned(), ~"<stdin>");
33+
let fm = parse::string_to_filemap(&sess, src.to_owned(), ~"<stdin>");
3434
3535
let mut out = io::MemWriter::new();
36-
doit(sess,
36+
doit(&sess,
3737
lexer::new_string_reader(span_handler, fm),
3838
class,
3939
&mut out).unwrap();
@@ -47,7 +47,7 @@ pub fn highlight(src: &str, class: Option<&str>) -> ~str {
4747
/// it's used. All source code emission is done as slices from the source map,
4848
/// not from the tokens themselves, in order to stay true to the original
4949
/// source.
50-
fn doit(sess: @parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>,
50+
fn doit(sess: &parse::ParseSess, lexer: lexer::StringReader, class: Option<&str>,
5151
out: &mut Writer) -> io::IoResult<()> {
5252
use syntax::parse::lexer::Reader;
5353

src/libsyntax/ext/base.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ pub trait CrateLoader {
289289
// when a macro expansion occurs, the resulting nodes have the backtrace()
290290
// -> expn_info of their expansion context stored into their span.
291291
pub struct ExtCtxt<'a> {
292-
parse_sess: @parse::ParseSess,
292+
parse_sess: &'a parse::ParseSess,
293293
cfg: ast::CrateConfig,
294294
backtrace: Option<@ExpnInfo>,
295295
ecfg: expand::ExpansionConfig<'a>,
@@ -299,7 +299,7 @@ pub struct ExtCtxt<'a> {
299299
}
300300

301301
impl<'a> ExtCtxt<'a> {
302-
pub fn new<'a>(parse_sess: @parse::ParseSess, cfg: ast::CrateConfig,
302+
pub fn new<'a>(parse_sess: &'a parse::ParseSess, cfg: ast::CrateConfig,
303303
ecfg: expand::ExpansionConfig<'a>) -> ExtCtxt<'a> {
304304
ExtCtxt {
305305
parse_sess: parse_sess,
@@ -327,7 +327,7 @@ impl<'a> ExtCtxt<'a> {
327327
}
328328

329329
pub fn codemap(&self) -> @CodeMap { self.parse_sess.cm }
330-
pub fn parse_sess(&self) -> @parse::ParseSess { self.parse_sess }
330+
pub fn parse_sess(&self) -> &'a parse::ParseSess { self.parse_sess }
331331
pub fn cfg(&self) -> ast::CrateConfig { self.cfg.clone() }
332332
pub fn call_site(&self) -> Span {
333333
match self.backtrace {

src/libsyntax/ext/expand.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -838,12 +838,12 @@ pub fn new_span(cx: &ExtCtxt, sp: Span) -> Span {
838838
}
839839
}
840840

841-
pub struct MacroExpander<'a> {
841+
pub struct MacroExpander<'a, 'b> {
842842
extsbox: SyntaxEnv,
843-
cx: &'a mut ExtCtxt<'a>,
843+
cx: &'a mut ExtCtxt<'b>,
844844
}
845845

846-
impl<'a> Folder for MacroExpander<'a> {
846+
impl<'a, 'b> Folder for MacroExpander<'a, 'b> {
847847
fn fold_expr(&mut self, expr: @ast::Expr) -> @ast::Expr {
848848
expand_expr(expr, self)
849849
}
@@ -875,7 +875,7 @@ pub struct ExpansionConfig<'a> {
875875
crate_id: CrateId,
876876
}
877877

878-
pub fn expand_crate(parse_sess: @parse::ParseSess,
878+
pub fn expand_crate(parse_sess: &parse::ParseSess,
879879
cfg: ExpansionConfig,
880880
c: Crate) -> Crate {
881881
let mut cx = ExtCtxt::new(parse_sess, c.config.clone(), cfg);
@@ -974,7 +974,7 @@ mod test {
974974
use ext::mtwt;
975975
use parse;
976976
use parse::token;
977-
use util::parser_testing::{string_to_crate_and_sess};
977+
use util::parser_testing::{string_to_parser};
978978
use util::parser_testing::{string_to_pat, strs_to_idents};
979979
use visit;
980980
use visit::Visitor;
@@ -1126,15 +1126,16 @@ mod test {
11261126
//}
11271127

11281128
fn expand_crate_str(crate_str: ~str) -> ast::Crate {
1129-
let (crate_ast,ps) = string_to_crate_and_sess(crate_str);
1129+
let ps = parse::new_parse_sess();
1130+
let crate_ast = string_to_parser(&ps, source_str).parse_crate_mod();
11301131
// the cfg argument actually does matter, here...
11311132
let mut loader = ErrLoader;
11321133
let cfg = ::syntax::ext::expand::ExpansionConfig {
11331134
loader: &mut loader,
11341135
deriving_hash_type_parameter: false,
11351136
crate_id: from_str("test").unwrap(),
11361137
};
1137-
expand_crate(ps,cfg,crate_ast)
1138+
expand_crate(&ps,cfg,crate_ast)
11381139
}
11391140

11401141
//fn expand_and_resolve(crate_str: @str) -> ast::crate {

src/libsyntax/ext/format.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ enum Position {
3535
Named(~str),
3636
}
3737

38-
struct Context<'a> {
39-
ecx: &'a mut ExtCtxt<'a>,
38+
struct Context<'a, 'b> {
39+
ecx: &'a mut ExtCtxt<'b>,
4040
fmtsp: Span,
4141

4242
// Parsed argument expressions and the types that we've found so far for
@@ -142,7 +142,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
142142
return (extra, Some((fmtstr, args, order, names)));
143143
}
144144

145-
impl<'a> Context<'a> {
145+
impl<'a, 'b> Context<'a, 'b> {
146146
/// Verifies one piece of a parse string. All errors are not emitted as
147147
/// fatal so we can continue giving errors about this and possibly other
148148
/// format strings.

src/libsyntax/ext/tt/macro_parser.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ pub enum NamedMatch {
170170
MatchedNonterminal(Nonterminal)
171171
}
172172

173-
pub fn nameize(p_s: @ParseSess, ms: &[Matcher], res: &[@NamedMatch])
173+
pub fn nameize(p_s: &ParseSess, ms: &[Matcher], res: &[@NamedMatch])
174174
-> HashMap<Ident, @NamedMatch> {
175-
fn n_rec(p_s: @ParseSess, m: &Matcher, res: &[@NamedMatch],
175+
fn n_rec(p_s: &ParseSess, m: &Matcher, res: &[@NamedMatch],
176176
ret_val: &mut HashMap<Ident, @NamedMatch>) {
177177
match *m {
178178
codemap::Spanned {node: MatchTok(_), .. } => (),
@@ -205,7 +205,7 @@ pub enum ParseResult {
205205
Error(codemap::Span, ~str)
206206
}
207207

208-
pub fn parse_or_else<R: Reader>(sess: @ParseSess,
208+
pub fn parse_or_else<R: Reader>(sess: &ParseSess,
209209
cfg: ast::CrateConfig,
210210
rdr: R,
211211
ms: Vec<Matcher> )
@@ -227,7 +227,7 @@ pub fn token_name_eq(t1 : &Token, t2 : &Token) -> bool {
227227
}
228228
}
229229

230-
pub fn parse<R: Reader>(sess: @ParseSess,
230+
pub fn parse<R: Reader>(sess: &ParseSess,
231231
cfg: ast::CrateConfig,
232232
rdr: R,
233233
ms: &[Matcher])

src/libsyntax/ext/tt/macro_rules.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ use util::small_vector::SmallVector;
3030
use std::cell::RefCell;
3131
use std::vec_ng::Vec;
3232

33-
struct ParserAnyMacro {
34-
parser: RefCell<Parser>,
33+
struct ParserAnyMacro<'a> {
34+
parser: RefCell<Parser<'a>>,
3535
}
3636

37-
impl ParserAnyMacro {
37+
impl<'a> ParserAnyMacro<'a> {
3838
/// Make sure we don't have any tokens left to parse, so we don't
3939
/// silently drop anything. `allow_semi` is so that "optional"
4040
/// semilons at the end of normal expressions aren't complained
@@ -57,7 +57,7 @@ impl ParserAnyMacro {
5757
}
5858
}
5959

60-
impl AnyMacro for ParserAnyMacro {
60+
impl<'a> AnyMacro for ParserAnyMacro<'a> {
6161
fn make_expr(&self) -> @ast::Expr {
6262
let ret = {
6363
let mut parser = self.parser.borrow_mut();

src/libsyntax/parse/attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub trait ParserAttr {
2828
fn parse_optional_meta(&mut self) -> Vec<@ast::MetaItem> ;
2929
}
3030

31-
impl ParserAttr for Parser {
31+
impl<'a> ParserAttr for Parser<'a> {
3232
// Parse attributes that appear before an item
3333
fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
3434
let mut attrs: Vec<ast::Attribute> = Vec::new();

0 commit comments

Comments
 (0)