Skip to content

Commit 1144fdd

Browse files
committed
librustpkg: De-mut librustdoc and librustpkg. rs=demuting
1 parent ce70736 commit 1144fdd

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/librustdoc/path_pass.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ pub fn mk_pass() -> Pass {
3131

3232
struct Ctxt {
3333
srv: astsrv::Srv,
34-
mut path: ~[~str]
34+
path: @mut ~[~str]
3535
}
3636

3737
impl Clone for Ctxt {
3838
fn clone(&self) -> Ctxt {
3939
Ctxt {
4040
srv: self.srv.clone(),
41-
path: copy self.path
41+
path: @mut copy *self.path
4242
}
4343
}
4444
}
@@ -47,7 +47,7 @@ impl Clone for Ctxt {
4747
fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
4848
let ctxt = Ctxt {
4949
srv: srv,
50-
mut path: ~[]
50+
path: @mut ~[]
5151
};
5252
let fold = Fold {
5353
ctxt: ctxt.clone(),
@@ -61,7 +61,7 @@ fn run(srv: astsrv::Srv, doc: doc::Doc) -> doc::Doc {
6161

6262
fn fold_item(fold: &fold::Fold<Ctxt>, doc: doc::ItemDoc) -> doc::ItemDoc {
6363
doc::ItemDoc {
64-
path: copy fold.ctxt.path,
64+
path: copy *fold.ctxt.path,
6565
.. doc
6666
}
6767
}

src/librustpkg/rustpkg.rc

+2-2
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ impl PackageScript {
252252
struct Ctx {
253253
cfgs: ~[~str],
254254
json: bool,
255-
mut dep_cache: LinearMap<~str, bool>
255+
dep_cache: @mut LinearMap<~str, bool>
256256
}
257257

258258
impl Ctx {
@@ -912,7 +912,7 @@ pub fn main() {
912912
Ctx {
913913
cfgs: cfgs,
914914
json: json,
915-
mut dep_cache: LinearMap::new()
915+
dep_cache: @mut LinearMap::new()
916916
}.run(cmd, args);
917917
}
918918

src/librustpkg/util.rs

+16-15
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ struct ReadyCtx {
7272
sess: session::Session,
7373
crate: @ast::crate,
7474
ext_cx: ext_ctxt,
75-
mut path: ~[ast::ident],
76-
mut fns: ~[ListenerFn]
75+
path: ~[ast::ident],
76+
fns: ~[ListenerFn]
7777
}
7878

79-
fn fold_mod(_ctx: @ReadyCtx, m: ast::_mod,
79+
fn fold_mod(_ctx: @mut ReadyCtx, m: ast::_mod,
8080
fold: fold::ast_fold) -> ast::_mod {
8181
fn strip_main(item: @ast::item) -> @ast::item {
8282
@ast::item {
@@ -95,7 +95,7 @@ fn fold_mod(_ctx: @ReadyCtx, m: ast::_mod,
9595
}, fold)
9696
}
9797

98-
fn fold_item(ctx: @ReadyCtx, item: @ast::item,
98+
fn fold_item(ctx: @mut ReadyCtx, item: @ast::item,
9999
fold: fold::ast_fold) -> Option<@ast::item> {
100100

101101
ctx.path.push(item.ident);
@@ -133,7 +133,7 @@ fn fold_item(ctx: @ReadyCtx, item: @ast::item,
133133
res
134134
}
135135

136-
fn add_pkg_module(ctx: @ReadyCtx, m: ast::_mod) -> ast::_mod {
136+
fn add_pkg_module(ctx: @mut ReadyCtx, m: ast::_mod) -> ast::_mod {
137137
let listeners = mk_listener_vec(ctx);
138138
let ext_cx = ctx.ext_cx;
139139
let item = quote_item! (
@@ -152,24 +152,25 @@ fn add_pkg_module(ctx: @ReadyCtx, m: ast::_mod) -> ast::_mod {
152152
}
153153
}
154154

155-
fn mk_listener_vec(ctx: @ReadyCtx) -> @ast::expr {
155+
fn mk_listener_vec(ctx: @mut ReadyCtx) -> @ast::expr {
156156
let fns = ctx.fns;
157157
let descs = do fns.map |listener| {
158158
mk_listener_rec(ctx, *listener)
159159
};
160-
build::mk_slice_vec_e(ctx.ext_cx, dummy_sp(), descs)
160+
let ext_cx = ctx.ext_cx;
161+
build::mk_slice_vec_e(ext_cx, dummy_sp(), descs)
161162
}
162163

163-
fn mk_listener_rec(ctx: @ReadyCtx, listener: ListenerFn) -> @ast::expr {
164-
164+
fn mk_listener_rec(ctx: @mut ReadyCtx, listener: ListenerFn) -> @ast::expr {
165165
let span = listener.span;
166166
let cmds = do listener.cmds.map |&cmd| {
167-
build::mk_base_str(ctx.ext_cx, span, cmd)
167+
let ext_cx = ctx.ext_cx;
168+
build::mk_base_str(ext_cx, span, cmd)
168169
};
169170

170-
let cmds_expr = build::mk_slice_vec_e(ctx.ext_cx, span, cmds);
171-
let cb_expr = build::mk_path(ctx.ext_cx, span, copy listener.path);
172171
let ext_cx = ctx.ext_cx;
172+
let cmds_expr = build::mk_slice_vec_e(ext_cx, span, cmds);
173+
let cb_expr = build::mk_path(ext_cx, span, copy listener.path);
173174

174175
quote_expr!(
175176
Listener {
@@ -182,12 +183,12 @@ fn mk_listener_rec(ctx: @ReadyCtx, listener: ListenerFn) -> @ast::expr {
182183
/// Generate/filter main function, add the list of commands, etc.
183184
pub fn ready_crate(sess: session::Session,
184185
crate: @ast::crate) -> @ast::crate {
185-
let ctx = @ReadyCtx {
186+
let ctx = @mut ReadyCtx {
186187
sess: sess,
187188
crate: crate,
188189
ext_cx: mk_ctxt(sess.parse_sess, copy sess.opts.cfg),
189-
mut path: ~[],
190-
mut fns: ~[]
190+
path: ~[],
191+
fns: ~[]
191192
};
192193
let precursor = @fold::AstFoldFns {
193194
// fold_crate: fold::wrap(|a, b| fold_crate(ctx, a, b)),

0 commit comments

Comments
 (0)