Skip to content

Commit

Permalink
remove vecs_implicitly_copyable from libstd/libcore
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed May 9, 2013
1 parent d82d987 commit 2bc1263
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 106 deletions.
1 change: 0 additions & 1 deletion src/libcore/core.rc
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ they contained the following prologue:
// Don't link to core. We are core.
#[no_core];

#[warn(vecs_implicitly_copyable)];
#[deny(non_camel_case_types)];
#[allow(deprecated_mutable_fields)];

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ mod tests {

let arc_v = p.recv();

let v = *arc::get::<~[int]>(&arc_v);
let v = copy *arc::get::<~[int]>(&arc_v);
assert!(v[3] == 4);
};

Expand Down
4 changes: 2 additions & 2 deletions src/libstd/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ mod test {
#[test]
fn test_sendable_future() {
let expected = ~"schlorf";
let f = Cell(do spawn { copy expected });
let expected = "schlorf";
let f = Cell(do spawn { expected });
do task::spawn {
let mut f = f.take();
let actual = f.get();
Expand Down
71 changes: 38 additions & 33 deletions src/libstd/getopts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
let l = args.len();
let mut i = 0;
while i < l {
let cur = args[i];
let cur = copy args[i];
let curlen = cur.len();
if !is_arg(cur) {
free.push(cur);
} else if cur == ~"--" {
let mut j = i + 1;
while j < l { free.push(args[j]); j += 1; }
while j < l { free.push(copy args[j]); j += 1; }
break;
} else {
let mut names;
Expand All @@ -248,8 +248,8 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
names = ~[Long(tail)];
} else {
names =
~[Long(tail_eq[0])];
i_arg = Some(tail_eq[1]);
~[Long(copy tail_eq[0])];
i_arg = Some(copy tail_eq[1]);
}
} else {
let mut j = 1;
Expand All @@ -266,7 +266,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
interpreted correctly
*/
match find_opt(opts, opt) {
match find_opt(opts, copy opt) {
Some(id) => last_valid_opt_id = Some(id),
None => {
let arg_follows =
Expand All @@ -292,7 +292,7 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
let mut name_pos = 0;
for names.each() |nm| {
name_pos += 1;
let optid = match find_opt(opts, *nm) {
let optid = match find_opt(opts, copy *nm) {
Some(id) => id,
None => return Err(UnrecognizedOption(name_str(nm)))
};
Expand All @@ -305,18 +305,18 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
}
Maybe => {
if !i_arg.is_none() {
vals[optid].push(Val(i_arg.get()));
vals[optid].push(Val((copy i_arg).get()));
} else if name_pos < names.len() ||
i + 1 == l || is_arg(args[i + 1]) {
vals[optid].push(Given);
} else { i += 1; vals[optid].push(Val(args[i])); }
} else { i += 1; vals[optid].push(Val(copy args[i])); }
}
Yes => {
if !i_arg.is_none() {
vals[optid].push(Val(i_arg.get()));
vals[optid].push(Val((copy i_arg).get()));
} else if i + 1 == l {
return Err(ArgumentMissing(name_str(nm)));
} else { i += 1; vals[optid].push(Val(args[i])); }
} else { i += 1; vals[optid].push(Val(copy args[i])); }
}
}
}
Expand Down Expand Up @@ -346,15 +346,15 @@ pub fn getopts(args: &[~str], opts: &[Opt]) -> Result {
fn opt_vals(mm: &Matches, nm: &str) -> ~[Optval] {
return match find_opt(mm.opts, mkname(nm)) {
Some(id) => mm.vals[id],
Some(id) => copy mm.vals[id],
None => {
error!("No option '%s' defined", nm);
fail!()
}
};
}

fn opt_val(mm: &Matches, nm: &str) -> Optval { return opt_vals(mm, nm)[0]; }
fn opt_val(mm: &Matches, nm: &str) -> Optval { copy opt_vals(mm, nm)[0] }

/// Returns true if an option was matched
pub fn opt_present(mm: &Matches, nm: &str) -> bool {
Expand Down Expand Up @@ -547,25 +547,29 @@ pub mod groups {
// translate OptGroup into Opt
// (both short and long names correspond to different Opts)
pub fn long_to_short(lopt: &OptGroup) -> ~[Opt] {
match ((*lopt).short_name.len(),
(*lopt).long_name.len()) {
let OptGroup{short_name: short_name,
long_name: long_name,
hasarg: hasarg,
occur: occur,
_} = copy *lopt;

match (short_name.len(), long_name.len()) {
(0,0) => fail!(~"this long-format option was given no name"),
(0,_) => ~[Opt {name: Long(((*lopt).long_name)),
hasarg: (*lopt).hasarg,
occur: (*lopt).occur}],
(0,_) => ~[Opt {name: Long((long_name)),
hasarg: hasarg,
occur: occur}],
(1,0) => ~[Opt {name: Short(str::char_at((*lopt).short_name, 0)),
hasarg: (*lopt).hasarg,
occur: (*lopt).occur}],
(1,0) => ~[Opt {name: Short(str::char_at(short_name, 0)),
hasarg: hasarg,
occur: occur}],
(1,_) => ~[Opt {name: Short(str::char_at((*lopt).short_name, 0)),
hasarg: (*lopt).hasarg,
occur: (*lopt).occur},
Opt {name: Long(((*lopt).long_name)),
hasarg: (*lopt).hasarg,
occur: (*lopt).occur}],
(1,_) => ~[Opt {name: Short(str::char_at(short_name, 0)),
hasarg: hasarg,
occur: occur},
Opt {name: Long((long_name)),
hasarg: hasarg,
occur: occur}],
(_,_) => fail!(~"something is wrong with the long-form opt")
}
Expand All @@ -586,11 +590,12 @@ pub mod groups {
let desc_sep = ~"\n" + str::repeat(~" ", 24);
let rows = vec::map(opts, |optref| {
let short_name = (*optref).short_name;
let long_name = (*optref).long_name;
let hint = (*optref).hint;
let desc = (*optref).desc;
let hasarg = (*optref).hasarg;
let OptGroup{short_name: short_name,
long_name: long_name,
hint: hint,
desc: desc,
hasarg: hasarg,
_} = copy *optref;
let mut row = str::repeat(~" ", 4);
Expand Down Expand Up @@ -620,7 +625,7 @@ pub mod groups {
row += if rowlen < 24 {
str::repeat(~" ", 24 - rowlen)
} else {
desc_sep
copy desc_sep
};
// Normalize desc to contain words seperated by one space character
Expand Down Expand Up @@ -892,7 +897,7 @@ mod tests {
let rs = getopts(args, opts);
match rs {
Err(copy f) => {
error!(fail_str(f));
error!(fail_str(copy f));
check_fail_type(f, UnexpectedArgument_);
}
_ => fail!()
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/net_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ pub mod v4 {
pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(addr) => addr,
result::Err(ref err_data) => fail!(err_data.err_msg)
result::Err(ref err_data) => fail!(copy err_data.err_msg)
}
}
// the simple, old style numberic representation of
Expand Down Expand Up @@ -272,7 +272,7 @@ pub mod v6 {
pub fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(addr) => addr,
result::Err(copy err_data) => fail!(err_data.err_msg)
result::Err(copy err_data) => fail!(copy err_data.err_msg)
}
}
pub fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
Expand Down
Loading

5 comments on commit 2bc1263

@bors
Copy link
Contributor

@bors bors commented on 2bc1263 May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2bc1263 May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging thestinger/rust/explicit_copy = 2bc1263 into auto

@bors
Copy link
Contributor

@bors bors commented on 2bc1263 May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thestinger/rust/explicit_copy = 2bc1263 merged ok, testing candidate = ce9c022

@bors
Copy link
Contributor

@bors bors commented on 2bc1263 May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2bc1263 May 9, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding incoming to auto = ce9c022

Please sign in to comment.