20
20
#[allow(vecs_implicitly_copyable,
21
21
non_implicitly_copyable_typarams)];
22
22
23
+ #[legacy_records];
24
+
23
25
extern mod core(vers = "0.6");
24
26
extern mod std(vers = "0.6");
25
27
extern mod rustc(vers = "0.6");
@@ -29,10 +31,11 @@ use core::*;
29
31
use io::{ReaderUtil, WriterUtil};
30
32
use std::{json, semver, getopts};
31
33
use std::net::url;
32
- use send_map ::linear::LinearMap;
34
+ use hashmap ::linear::LinearMap;
33
35
use rustc::metadata::filesearch;
34
36
use rustc::driver::{driver, session};
35
37
use syntax::{ast, attr, codemap, diagnostic, parse, visit};
38
+ use syntax::codemap::spanned;
36
39
37
40
mod usage;
38
41
mod util;
@@ -83,7 +86,7 @@ impl PackageScript {
83
86
84
87
for mis.each |a| {
85
88
match a.node {
86
- ast::meta_name_value(v, ast:: spanned {
89
+ ast::meta_name_value(v, spanned {
87
90
node: ast::lit_str(s),
88
91
span: _}) => {
89
92
match v {
@@ -106,7 +109,7 @@ impl PackageScript {
106
109
107
110
for mis.each |a| {
108
111
match a.node {
109
- ast::meta_name_value(v, ast:: spanned {
112
+ ast::meta_name_value(v, spanned {
110
113
node: ast::lit_str(s),
111
114
span: _}) => {
112
115
match v {
@@ -127,7 +130,7 @@ impl PackageScript {
127
130
128
131
for mis.each |a| {
129
132
match a.node {
130
- ast::meta_name_value(v, ast:: spanned {
133
+ ast::meta_name_value(v, spanned {
131
134
node: ast::lit_str(s),
132
135
span: _}) => {
133
136
match v {
@@ -156,7 +159,7 @@ impl PackageScript {
156
159
let (u, t) = load_pkg_dep_attr(mis);
157
160
158
161
if u.is_none() {
159
- fail ~"pkg_dep attr without a url value";
162
+ fail!( ~"pkg_dep attr without a url value") ;
160
163
}
161
164
162
165
deps.push((u.get(), t));
@@ -165,7 +168,7 @@ impl PackageScript {
165
168
let f = load_pkg_crate_attr(mis);
166
169
167
170
if f.is_none() {
168
- fail ~"pkg_file attr without a file value";
171
+ fail!( ~"pkg_file attr without a file value") ;
169
172
}
170
173
171
174
crates.push(f.get());
@@ -222,7 +225,7 @@ impl PackageScript {
222
225
223
226
// Build the bootstrap and run a command
224
227
// FIXME (#4432): Use workcache to only compile the script when changed
225
- fn run(cmd: ~str, test: bool) -> int {
228
+ fn run(&self, cmd: ~str, test: bool) -> int {
226
229
let work_dir = self.work_dir();
227
230
let input = self.input;
228
231
let sess = self.sess;
@@ -238,12 +241,12 @@ impl PackageScript {
238
241
run::run_program(exe.to_str(), ~[root.to_str(), cmd, test.to_str()])
239
242
}
240
243
241
- fn hash() -> ~str {
244
+ fn hash(&self ) -> ~str {
242
245
fmt!("%s-%s-%s", self.name, util::hash(self.id + self.vers.to_str()),
243
246
self.vers.to_str())
244
247
}
245
248
246
- fn work_dir() -> Path {
249
+ fn work_dir(&self ) -> Path {
247
250
util::root().push(~"work").push(self.hash())
248
251
}
249
252
}
@@ -255,7 +258,7 @@ struct Ctx {
255
258
}
256
259
257
260
impl Ctx {
258
- fn run(cmd: ~str, args: ~[~str]) {
261
+ fn run(&self, cmd: ~str, args: ~[~str]) {
259
262
let root = util::root();
260
263
261
264
util::need_dir(&root);
@@ -333,11 +336,11 @@ impl Ctx {
333
336
334
337
self.unprefer(name.get(), vers);
335
338
}
336
- _ => fail ~"reached an unhandled command"
339
+ _ => fail!( ~"reached an unhandled command")
337
340
}
338
341
}
339
342
340
- fn do_cmd(cmd: ~str) -> bool {
343
+ fn do_cmd(&self, cmd: ~str) -> bool {
341
344
match cmd {
342
345
~"build" | ~"test" => {
343
346
util::error(~"that command cannot be manually called");
@@ -367,7 +370,7 @@ impl Ctx {
367
370
status == 0
368
371
}
369
372
370
- fn build(dir: &Path, verbose: bool, opt: bool,
373
+ fn build(&self, dir: &Path, verbose: bool, opt: bool,
371
374
test: bool) -> Option<PackageScript> {
372
375
let cwd = &os::getcwd();
373
376
let script = match PackageScript::parse(dir) {
@@ -450,12 +453,12 @@ impl Ctx {
450
453
Some(script)
451
454
}
452
455
453
- fn compile(crate: &Path, dir: &Path, flags: ~[~str],
456
+ fn compile(&self, crate: &Path, dir: &Path, flags: ~[~str],
454
457
cfgs: ~[~str], opt: bool, test: bool) -> bool {
455
458
util::compile_crate(None, crate, dir, flags, cfgs, opt, test)
456
459
}
457
460
458
- fn clean() -> bool {
461
+ fn clean(&self ) -> bool {
459
462
let script = match PackageScript::parse(&os::getcwd()) {
460
463
result::Ok(script) => script,
461
464
result::Err(err) => {
@@ -480,23 +483,24 @@ impl Ctx {
480
483
true
481
484
}
482
485
483
- fn info() {
486
+ fn info(&self ) {
484
487
if self.json {
485
488
match PackageScript::parse(&os::getcwd()) {
486
489
result::Ok(script) => {
487
- let mut map = ~LinearMap();
490
+ let mut map = ~LinearMap::new ();
488
491
489
492
map.insert(~"id", json::String(script.id));
490
493
map.insert(~"name", json::String(script.name));
491
494
map.insert(~"vers", json::String(script.vers.to_str()));
492
495
map.insert(~"deps", json::List(do script.deps.map |&dep| {
493
496
let (url, target) = dep;
494
- let mut inner = ~LinearMap();
497
+ let mut inner = ~LinearMap::new ();
495
498
496
499
inner.insert(~"url", json::String(url));
497
500
498
501
if !target.is_none() {
499
- inner.insert(~"target", json::String(target.get()));
502
+ inner.insert(~"target",
503
+ json::String(target.get()));
500
504
}
501
505
502
506
json::Object(inner)
@@ -519,7 +523,12 @@ impl Ctx {
519
523
util::note(fmt!("id: %s", script.id));
520
524
util::note(fmt!("name: %s", script.name));
521
525
util::note(fmt!("vers: %s", script.vers.to_str()));
522
- util::note(fmt!("deps: %s", if script.deps.len() > 0 { ~"" } else { ~"none" }));
526
+ util::note(fmt!("deps: %s",
527
+ if script.deps.len() > 0 {
528
+ ~""
529
+ } else {
530
+ ~"none"
531
+ }));
523
532
524
533
for script.deps.each |&dep| {
525
534
let (url, target) = dep;
@@ -532,7 +541,8 @@ impl Ctx {
532
541
}
533
542
}
534
543
535
- fn install(url: Option<~str>, target: Option<~str>, cache: bool) -> bool {
544
+ fn install(&self, url: Option<~str>,
545
+ target: Option<~str>, cache: bool) -> bool {
536
546
let mut success;
537
547
let mut dir;
538
548
@@ -608,7 +618,7 @@ impl Ctx {
608
618
true
609
619
}
610
620
611
- fn fetch(dir: &Path, url: ~str, target: Option<~str>) -> bool {
621
+ fn fetch(&self, dir: &Path, url: ~str, target: Option<~str>) -> bool {
612
622
let url = if str::find_str(url, "://").is_none() {
613
623
~"http://" + url }
614
624
else { url };
@@ -641,7 +651,7 @@ impl Ctx {
641
651
}
642
652
}
643
653
644
- fn fetch_curl(dir: &Path, url: ~str) -> bool {
654
+ fn fetch_curl(&self, dir: &Path, url: ~str) -> bool {
645
655
util::note(fmt!("fetching from %s using curl", url));
646
656
647
657
let tar = dir.dir_path().push(&dir.file_path().to_str() + ~".tar");
@@ -666,7 +676,7 @@ impl Ctx {
666
676
true
667
677
}
668
678
669
- fn fetch_git(dir: &Path, url: ~str, target: Option<~str>) -> bool {
679
+ fn fetch_git(&self, dir: &Path, url: ~str, target: Option<~str>) -> bool {
670
680
util::note(fmt!("fetching from %s using git", url));
671
681
672
682
// Git can't clone into a non-empty directory
@@ -698,7 +708,7 @@ impl Ctx {
698
708
true
699
709
}
700
710
701
- fn prefer(id: ~str, vers: Option<~str>) -> bool {
711
+ fn prefer(&self, id: ~str, vers: Option<~str>) -> bool {
702
712
let package = match util::get_pkg(id, vers) {
703
713
result::Ok(package) => package,
704
714
result::Err(err) => {
@@ -735,7 +745,7 @@ impl Ctx {
735
745
true
736
746
}
737
747
738
- fn test() -> bool {
748
+ fn test(&self ) -> bool {
739
749
let script = match self.build(&os::getcwd(), false, false, true) {
740
750
Some(script) => script,
741
751
None => {
@@ -773,7 +783,7 @@ impl Ctx {
773
783
true
774
784
}
775
785
776
- fn uninstall(id: ~str, vers: Option<~str>) -> bool {
786
+ fn uninstall(&self, id: ~str, vers: Option<~str>) -> bool {
777
787
let package = match util::get_pkg(id, vers) {
778
788
result::Ok(package) => package,
779
789
result::Err(err) => {
@@ -812,7 +822,7 @@ impl Ctx {
812
822
true
813
823
}
814
824
815
- fn unprefer(id: ~str, vers: Option<~str>) -> bool {
825
+ fn unprefer(&self, id: ~str, vers: Option<~str>) -> bool {
816
826
let package = match util::get_pkg(id, vers) {
817
827
result::Ok(package) => package,
818
828
result::Err(err) => {
@@ -904,7 +914,7 @@ pub fn main() {
904
914
Ctx {
905
915
cfgs: cfgs,
906
916
json: json,
907
- mut dep_cache: LinearMap()
917
+ mut dep_cache: LinearMap::new ()
908
918
}.run(cmd, args);
909
919
}
910
920
@@ -942,31 +952,31 @@ pub fn run(listeners: ~[Listener]) {
942
952
}
943
953
944
954
pub impl Crate {
945
- pub fn flag(flag: ~str) -> Crate {
955
+ pub fn flag(&self, flag: ~str) -> Crate {
946
956
Crate {
947
957
flags: vec::append(copy self.flags, ~[flag]),
948
- .. copy self
958
+ .. copy * self
949
959
}
950
960
}
951
961
952
- pub fn flags(flags: ~[~str]) -> Crate {
962
+ pub fn flags(&self, flags: ~[~str]) -> Crate {
953
963
Crate {
954
964
flags: vec::append(copy self.flags, flags),
955
- .. copy self
965
+ .. copy * self
956
966
}
957
967
}
958
968
959
- pub fn cfg(cfg: ~str) -> Crate {
969
+ pub fn cfg(&self, cfg: ~str) -> Crate {
960
970
Crate {
961
971
cfgs: vec::append(copy self.cfgs, ~[cfg]),
962
- .. copy self
972
+ .. copy * self
963
973
}
964
974
}
965
975
966
- pub fn cfgs(cfgs: ~[~str]) -> Crate {
976
+ pub fn cfgs(&self, cfgs: ~[~str]) -> Crate {
967
977
Crate {
968
978
cfgs: vec::append(copy self.cfgs, cfgs),
969
- .. copy self
979
+ .. copy * self
970
980
}
971
981
}
972
982
}
0 commit comments