Skip to content

Commit 41b0568

Browse files
committed
save-analysis: tweak constructors
1 parent e6e6368 commit 41b0568

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/librustc_trans/save/dump_csv.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use session::Session;
3535
use middle::def;
3636
use middle::ty::{self, Ty};
3737

38-
use std::cell::Cell;
3938
use std::fs::File;
4039
use std::path::Path;
4140

@@ -76,14 +75,11 @@ impl <'l, 'tcx> DumpCsvVisitor<'l, 'tcx> {
7675
pub fn new(tcx: &'l ty::ctxt<'tcx>,
7776
analysis: &'l ty::CrateAnalysis,
7877
output_file: Box<File>) -> DumpCsvVisitor<'l, 'tcx> {
79-
let span_utils = SpanUtils {
80-
sess: &tcx.sess,
81-
err_count: Cell::new(0)
82-
};
78+
let span_utils = SpanUtils::new(&tcx.sess);
8379
DumpCsvVisitor {
8480
sess: &tcx.sess,
8581
tcx: tcx,
86-
save_ctxt: SaveContext::new(tcx, span_utils.clone()),
82+
save_ctxt: SaveContext::from_span_utils(tcx, span_utils.clone()),
8783
analysis: analysis,
8884
span: span_utils.clone(),
8985
fmt: FmtStrs::new(box Recorder {

src/librustc_trans/save/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,14 @@ pub struct MethodCallData {
163163

164164

165165
impl<'l, 'tcx: 'l> SaveContext<'l, 'tcx> {
166-
pub fn new(tcx: &'l ty::ctxt<'tcx>,
167-
span_utils: SpanUtils<'l>)
168-
-> SaveContext<'l, 'tcx> {
166+
pub fn new(tcx: &'l ty::ctxt<'tcx>) -> SaveContext <'l, 'tcx> {
167+
let span_utils = SpanUtils::new(&tcx.sess);
168+
SaveContext::from_span_utils(tcx, span_utils)
169+
}
170+
171+
pub fn from_span_utils(tcx: &'l ty::ctxt<'tcx>,
172+
span_utils: SpanUtils<'l>)
173+
-> SaveContext<'l, 'tcx> {
169174
SaveContext {
170175
tcx: tcx,
171176
span_utils: span_utils,

src/librustc_trans/save/span_utils.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ pub struct SpanUtils<'a> {
2828
}
2929

3030
impl<'a> SpanUtils<'a> {
31+
pub fn new(sess: &'a Session) -> SpanUtils<'a> {
32+
SpanUtils {
33+
sess: sess,
34+
err_count: Cell::new(0)
35+
}
36+
}
37+
3138
// Standard string for extents/location.
3239
pub fn extent_str(&self, span: Span) -> String {
3340
let lo_loc = self.sess.codemap().lookup_char_pos(span.lo);

0 commit comments

Comments
 (0)