Skip to content

Commit b361f6c

Browse files
ericktgraydon
authored andcommitted
Fix json no-implicit-copy warnings
1 parent 2cc0a0e commit b361f6c

File tree

2 files changed

+139
-126
lines changed

2 files changed

+139
-126
lines changed

src/cargo/cargo.rs

+21-21
Original file line numberDiff line numberDiff line change
@@ -400,25 +400,25 @@ fn parse_source(name: str, j: json::json) -> source {
400400
json::dict(j) {
401401
let mut url = alt j.find("url") {
402402
some(json::string(u)) {
403-
u
403+
*u
404404
}
405405
_ { fail "needed 'url' field in source"; }
406406
};
407407
let method = alt j.find("method") {
408408
some(json::string(u)) {
409-
u
409+
*u
410410
}
411411
_ { assume_source_method(url) }
412412
};
413413
let key = alt j.find("key") {
414414
some(json::string(u)) {
415-
some(u)
415+
some(*u)
416416
}
417417
_ { none }
418418
};
419419
let keyfp = alt j.find("keyfp") {
420420
some(json::string(u)) {
421-
some(u)
421+
some(*u)
422422
}
423423
_ { none }
424424
};
@@ -455,13 +455,13 @@ fn try_parse_sources(filename: str, sources: map::hashmap<str, source>) {
455455
fn load_one_source_package(src: source, p: map::hashmap<str, json::json>) {
456456
let name = alt p.find("name") {
457457
some(json::string(n)) {
458-
if !valid_pkg_name(n) {
459-
warn("malformed source json: " + src.name + ", '" + n + "'"+
458+
if !valid_pkg_name(*n) {
459+
warn("malformed source json: " + src.name + ", '" + *n + "'"+
460460
" is an invalid name (alphanumeric, underscores and" +
461461
" dashes only)");
462462
ret;
463463
}
464-
n
464+
*n
465465
}
466466
_ {
467467
warn("malformed source json: " + src.name + " (missing name)");
@@ -471,12 +471,12 @@ fn load_one_source_package(src: source, p: map::hashmap<str, json::json>) {
471471

472472
let uuid = alt p.find("uuid") {
473473
some(json::string(n)) {
474-
if !is_uuid(n) {
475-
warn("malformed source json: " + src.name + ", '" + n + "'"+
474+
if !is_uuid(*n) {
475+
warn("malformed source json: " + src.name + ", '" + *n + "'"+
476476
" is an invalid uuid");
477477
ret;
478478
}
479-
n
479+
*n
480480
}
481481
_ {
482482
warn("malformed source json: " + src.name + " (missing uuid)");
@@ -485,32 +485,32 @@ fn load_one_source_package(src: source, p: map::hashmap<str, json::json>) {
485485
};
486486

487487
let url = alt p.find("url") {
488-
some(json::string(n)) { n }
488+
some(json::string(n)) { *n }
489489
_ {
490490
warn("malformed source json: " + src.name + " (missing url)");
491491
ret;
492492
}
493493
};
494494

495495
let method = alt p.find("method") {
496-
some(json::string(n)) { n }
496+
some(json::string(n)) { *n }
497497
_ {
498498
warn("malformed source json: " + src.name + " (missing method)");
499499
ret;
500500
}
501501
};
502502

503503
let ref = alt p.find("ref") {
504-
some(json::string(n)) { some(n) }
504+
some(json::string(n)) { some(*n) }
505505
_ { none }
506506
};
507507

508508
let mut tags = [];
509509
alt p.find("tags") {
510510
some(json::list(js)) {
511-
for js.each {|j|
511+
for (*js).each {|j|
512512
alt j {
513-
json::string(j) { vec::grow(tags, 1u, j); }
513+
json::string(j) { vec::grow(tags, 1u, *j); }
514514
_ { }
515515
}
516516
}
@@ -519,7 +519,7 @@ fn load_one_source_package(src: source, p: map::hashmap<str, json::json>) {
519519
}
520520

521521
let description = alt p.find("description") {
522-
some(json::string(n)) { n }
522+
some(json::string(n)) { *n }
523523
_ {
524524
warn("malformed source json: " + src.name
525525
+ " (missing description)");
@@ -580,7 +580,7 @@ fn load_source_packages(c: cargo, src: source) {
580580
let pkgstr = io::read_whole_file_str(pkgfile);
581581
alt json::from_str(result::get(pkgstr)) {
582582
ok(json::list(js)) {
583-
for js.each {|j|
583+
for (*js).each {|j|
584584
alt j {
585585
json::dict(p) {
586586
load_one_source_package(src, p);
@@ -1576,18 +1576,18 @@ fn dump_sources(c: cargo) {
15761576
let chash = map::str_hash();
15771577
let child = json::dict(chash);
15781578

1579-
chash.insert("url", json::string(v.url));
1580-
chash.insert("method", json::string(v.method));
1579+
chash.insert("url", json::string(@v.url));
1580+
chash.insert("method", json::string(@v.method));
15811581

15821582
alt copy v.key {
15831583
some(key) {
1584-
chash.insert("key", json::string(key));
1584+
chash.insert("key", json::string(@key));
15851585
}
15861586
_ {}
15871587
}
15881588
alt copy v.keyfp {
15891589
some(keyfp) {
1590-
chash.insert("keyfp", json::string(keyfp));
1590+
chash.insert("keyfp", json::string(@keyfp));
15911591
}
15921592
_ {}
15931593
}

0 commit comments

Comments
 (0)