2020#[allow(vecs_implicitly_copyable,
2121 non_implicitly_copyable_typarams)];
2222
23+ #[legacy_records];
24+
2325extern mod core(vers = "0.6");
2426extern mod std(vers = "0.6");
2527extern mod rustc(vers = "0.6");
@@ -29,10 +31,11 @@ use core::*;
2931use io::{ReaderUtil, WriterUtil};
3032use std::{json, semver, getopts};
3133use std::net::url;
32- use send_map ::linear::LinearMap;
34+ use hashmap ::linear::LinearMap;
3335use rustc::metadata::filesearch;
3436use rustc::driver::{driver, session};
3537use syntax::{ast, attr, codemap, diagnostic, parse, visit};
38+ use syntax::codemap::spanned;
3639
3740mod usage;
3841mod util;
@@ -83,7 +86,7 @@ impl PackageScript {
8386
8487 for mis.each |a| {
8588 match a.node {
86- ast::meta_name_value(v, ast:: spanned {
89+ ast::meta_name_value(v, spanned {
8790 node: ast::lit_str(s),
8891 span: _}) => {
8992 match v {
@@ -106,7 +109,7 @@ impl PackageScript {
106109
107110 for mis.each |a| {
108111 match a.node {
109- ast::meta_name_value(v, ast:: spanned {
112+ ast::meta_name_value(v, spanned {
110113 node: ast::lit_str(s),
111114 span: _}) => {
112115 match v {
@@ -127,7 +130,7 @@ impl PackageScript {
127130
128131 for mis.each |a| {
129132 match a.node {
130- ast::meta_name_value(v, ast:: spanned {
133+ ast::meta_name_value(v, spanned {
131134 node: ast::lit_str(s),
132135 span: _}) => {
133136 match v {
@@ -156,7 +159,7 @@ impl PackageScript {
156159 let (u, t) = load_pkg_dep_attr(mis);
157160
158161 if u.is_none() {
159- fail ~"pkg_dep attr without a url value";
162+ fail!( ~"pkg_dep attr without a url value") ;
160163 }
161164
162165 deps.push((u.get(), t));
@@ -165,7 +168,7 @@ impl PackageScript {
165168 let f = load_pkg_crate_attr(mis);
166169
167170 if f.is_none() {
168- fail ~"pkg_file attr without a file value";
171+ fail!( ~"pkg_file attr without a file value") ;
169172 }
170173
171174 crates.push(f.get());
@@ -222,7 +225,7 @@ impl PackageScript {
222225
223226 // Build the bootstrap and run a command
224227 // 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 {
226229 let work_dir = self.work_dir();
227230 let input = self.input;
228231 let sess = self.sess;
@@ -238,12 +241,12 @@ impl PackageScript {
238241 run::run_program(exe.to_str(), ~[root.to_str(), cmd, test.to_str()])
239242 }
240243
241- fn hash() -> ~str {
244+ fn hash(&self ) -> ~str {
242245 fmt!("%s-%s-%s", self.name, util::hash(self.id + self.vers.to_str()),
243246 self.vers.to_str())
244247 }
245248
246- fn work_dir() -> Path {
249+ fn work_dir(&self ) -> Path {
247250 util::root().push(~"work").push(self.hash())
248251 }
249252}
@@ -255,7 +258,7 @@ struct Ctx {
255258}
256259
257260impl Ctx {
258- fn run(cmd: ~str, args: ~[~str]) {
261+ fn run(&self, cmd: ~str, args: ~[~str]) {
259262 let root = util::root();
260263
261264 util::need_dir(&root);
@@ -333,11 +336,11 @@ impl Ctx {
333336
334337 self.unprefer(name.get(), vers);
335338 }
336- _ => fail ~"reached an unhandled command"
339+ _ => fail!( ~"reached an unhandled command")
337340 }
338341 }
339342
340- fn do_cmd(cmd: ~str) -> bool {
343+ fn do_cmd(&self, cmd: ~str) -> bool {
341344 match cmd {
342345 ~"build" | ~"test" => {
343346 util::error(~"that command cannot be manually called");
@@ -367,7 +370,7 @@ impl Ctx {
367370 status == 0
368371 }
369372
370- fn build(dir: &Path, verbose: bool, opt: bool,
373+ fn build(&self, dir: &Path, verbose: bool, opt: bool,
371374 test: bool) -> Option<PackageScript> {
372375 let cwd = &os::getcwd();
373376 let script = match PackageScript::parse(dir) {
@@ -450,12 +453,12 @@ impl Ctx {
450453 Some(script)
451454 }
452455
453- fn compile(crate: &Path, dir: &Path, flags: ~[~str],
456+ fn compile(&self, crate: &Path, dir: &Path, flags: ~[~str],
454457 cfgs: ~[~str], opt: bool, test: bool) -> bool {
455458 util::compile_crate(None, crate, dir, flags, cfgs, opt, test)
456459 }
457460
458- fn clean() -> bool {
461+ fn clean(&self ) -> bool {
459462 let script = match PackageScript::parse(&os::getcwd()) {
460463 result::Ok(script) => script,
461464 result::Err(err) => {
@@ -480,23 +483,24 @@ impl Ctx {
480483 true
481484 }
482485
483- fn info() {
486+ fn info(&self ) {
484487 if self.json {
485488 match PackageScript::parse(&os::getcwd()) {
486489 result::Ok(script) => {
487- let mut map = ~LinearMap();
490+ let mut map = ~LinearMap::new ();
488491
489492 map.insert(~"id", json::String(script.id));
490493 map.insert(~"name", json::String(script.name));
491494 map.insert(~"vers", json::String(script.vers.to_str()));
492495 map.insert(~"deps", json::List(do script.deps.map |&dep| {
493496 let (url, target) = dep;
494- let mut inner = ~LinearMap();
497+ let mut inner = ~LinearMap::new ();
495498
496499 inner.insert(~"url", json::String(url));
497500
498501 if !target.is_none() {
499- inner.insert(~"target", json::String(target.get()));
502+ inner.insert(~"target",
503+ json::String(target.get()));
500504 }
501505
502506 json::Object(inner)
@@ -519,7 +523,12 @@ impl Ctx {
519523 util::note(fmt!("id: %s", script.id));
520524 util::note(fmt!("name: %s", script.name));
521525 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+ }));
523532
524533 for script.deps.each |&dep| {
525534 let (url, target) = dep;
@@ -532,7 +541,8 @@ impl Ctx {
532541 }
533542 }
534543
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 {
536546 let mut success;
537547 let mut dir;
538548
@@ -608,7 +618,7 @@ impl Ctx {
608618 true
609619 }
610620
611- fn fetch(dir: &Path, url: ~str, target: Option<~str>) -> bool {
621+ fn fetch(&self, dir: &Path, url: ~str, target: Option<~str>) -> bool {
612622 let url = if str::find_str(url, "://").is_none() {
613623 ~"http://" + url }
614624 else { url };
@@ -641,7 +651,7 @@ impl Ctx {
641651 }
642652 }
643653
644- fn fetch_curl(dir: &Path, url: ~str) -> bool {
654+ fn fetch_curl(&self, dir: &Path, url: ~str) -> bool {
645655 util::note(fmt!("fetching from %s using curl", url));
646656
647657 let tar = dir.dir_path().push(&dir.file_path().to_str() + ~".tar");
@@ -666,7 +676,7 @@ impl Ctx {
666676 true
667677 }
668678
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 {
670680 util::note(fmt!("fetching from %s using git", url));
671681
672682 // Git can't clone into a non-empty directory
@@ -698,7 +708,7 @@ impl Ctx {
698708 true
699709 }
700710
701- fn prefer(id: ~str, vers: Option<~str>) -> bool {
711+ fn prefer(&self, id: ~str, vers: Option<~str>) -> bool {
702712 let package = match util::get_pkg(id, vers) {
703713 result::Ok(package) => package,
704714 result::Err(err) => {
@@ -735,7 +745,7 @@ impl Ctx {
735745 true
736746 }
737747
738- fn test() -> bool {
748+ fn test(&self ) -> bool {
739749 let script = match self.build(&os::getcwd(), false, false, true) {
740750 Some(script) => script,
741751 None => {
@@ -773,7 +783,7 @@ impl Ctx {
773783 true
774784 }
775785
776- fn uninstall(id: ~str, vers: Option<~str>) -> bool {
786+ fn uninstall(&self, id: ~str, vers: Option<~str>) -> bool {
777787 let package = match util::get_pkg(id, vers) {
778788 result::Ok(package) => package,
779789 result::Err(err) => {
@@ -812,7 +822,7 @@ impl Ctx {
812822 true
813823 }
814824
815- fn unprefer(id: ~str, vers: Option<~str>) -> bool {
825+ fn unprefer(&self, id: ~str, vers: Option<~str>) -> bool {
816826 let package = match util::get_pkg(id, vers) {
817827 result::Ok(package) => package,
818828 result::Err(err) => {
@@ -904,7 +914,7 @@ pub fn main() {
904914 Ctx {
905915 cfgs: cfgs,
906916 json: json,
907- mut dep_cache: LinearMap()
917+ mut dep_cache: LinearMap::new ()
908918 }.run(cmd, args);
909919}
910920
@@ -942,31 +952,31 @@ pub fn run(listeners: ~[Listener]) {
942952}
943953
944954pub impl Crate {
945- pub fn flag(flag: ~str) -> Crate {
955+ pub fn flag(&self, flag: ~str) -> Crate {
946956 Crate {
947957 flags: vec::append(copy self.flags, ~[flag]),
948- .. copy self
958+ .. copy * self
949959 }
950960 }
951961
952- pub fn flags(flags: ~[~str]) -> Crate {
962+ pub fn flags(&self, flags: ~[~str]) -> Crate {
953963 Crate {
954964 flags: vec::append(copy self.flags, flags),
955- .. copy self
965+ .. copy * self
956966 }
957967 }
958968
959- pub fn cfg(cfg: ~str) -> Crate {
969+ pub fn cfg(&self, cfg: ~str) -> Crate {
960970 Crate {
961971 cfgs: vec::append(copy self.cfgs, ~[cfg]),
962- .. copy self
972+ .. copy * self
963973 }
964974 }
965975
966- pub fn cfgs(cfgs: ~[~str]) -> Crate {
976+ pub fn cfgs(&self, cfgs: ~[~str]) -> Crate {
967977 Crate {
968978 cfgs: vec::append(copy self.cfgs, cfgs),
969- .. copy self
979+ .. copy * self
970980 }
971981 }
972982}
0 commit comments