Skip to content

Mode removal ++ #3362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/libstd/net_ip.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Types/fns concerning Internet Protocol (IP), versions 4 & 6
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

import vec;
import uint;
Expand Down Expand Up @@ -46,8 +48,8 @@ type ParseAddrErr = {
*
* * ip - a `std::net::ip::ip_addr`
*/
fn format_addr(ip: IpAddr) -> ~str {
match ip {
fn format_addr(ip: &IpAddr) -> ~str {
match *ip {
Ipv4(addr) => unsafe {
let result = uv_ip4_name(&addr);
if result == ~"" {
Expand Down Expand Up @@ -84,7 +86,7 @@ enum IpGetAddrErr {
* a vector of `ip_addr` results, in the case of success, or an error
* object in the case of failure
*/
fn get_addr(++node: ~str, iotask: iotask)
fn get_addr(node: &str, iotask: iotask)
-> result::Result<~[IpAddr], IpGetAddrErr> {
do core::comm::listen |output_ch| {
do str::as_buf(node) |node_ptr, len| unsafe {
Expand Down Expand Up @@ -133,7 +135,7 @@ mod v4 {
*
* * an `ip_addr` of the `ipv4` variant
*/
fn parse_addr(ip: ~str) -> IpAddr {
fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(addr) => copy(addr),
result::Err(err_data) => fail err_data.err_msg
Expand All @@ -153,7 +155,7 @@ mod v4 {
*((ptr::addr_of(self)) as *u32)
}
}
fn parse_to_ipv4_rep(ip: ~str) -> result::Result<Ipv4Rep, ~str> {
fn parse_to_ipv4_rep(ip: &str) -> result::Result<Ipv4Rep, ~str> {
let parts = vec::map(str::split_char(ip, '.'), |s| {
match uint::from_str(s) {
Some(n) if n <= 255u => n,
Expand All @@ -171,7 +173,7 @@ mod v4 {
c: parts[2] as u8, d: parts[3] as u8})
}
}
fn try_parse_addr(ip: ~str) -> result::Result<IpAddr,ParseAddrErr> {
fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
unsafe {
let INADDR_NONE = ll::get_INADDR_NONE();
let ip_rep_result = parse_to_ipv4_rep(ip);
Expand All @@ -183,7 +185,7 @@ mod v4 {
let input_is_inaddr_none =
result::get(ip_rep_result).as_u32() == INADDR_NONE;

let new_addr = uv_ip4_addr(ip, 22);
let new_addr = uv_ip4_addr(str::from_slice(ip), 22);
let reformatted_name = uv_ip4_name(&new_addr);
log(debug, fmt!("try_parse_addr: input ip: %s reparsed ip: %s",
ip, reformatted_name));
Expand Down Expand Up @@ -219,22 +221,22 @@ mod v6 {
*
* * an `ip_addr` of the `ipv6` variant
*/
fn parse_addr(ip: ~str) -> IpAddr {
fn parse_addr(ip: &str) -> IpAddr {
match try_parse_addr(ip) {
result::Ok(addr) => copy(addr),
result::Err(err_data) => fail err_data.err_msg
}
}
fn try_parse_addr(ip: ~str) -> result::Result<IpAddr,ParseAddrErr> {
fn try_parse_addr(ip: &str) -> result::Result<IpAddr,ParseAddrErr> {
unsafe {
// need to figure out how to establish a parse failure..
let new_addr = uv_ip6_addr(ip, 22);
let new_addr = uv_ip6_addr(str::from_slice(ip), 22);
let reparsed_name = uv_ip6_name(&new_addr);
log(debug, fmt!("v6::try_parse_addr ip: '%s' reparsed '%s'",
ip, reparsed_name));
// '::' appears to be uv_ip6_name() returns for bogus
// parses..
if ip != ~"::" && reparsed_name == ~"::" {
if ip != &"::" && reparsed_name == ~"::" {
result::Err({err_msg:fmt!("failed to parse '%s'",
ip)})
}
Expand Down Expand Up @@ -313,13 +315,13 @@ mod test {
#[test]
fn test_ip_ipv4_parse_and_format_ip() {
let localhost_str = ~"127.0.0.1";
assert (format_addr(v4::parse_addr(localhost_str))
assert (format_addr(&v4::parse_addr(localhost_str))
== localhost_str)
}
#[test]
fn test_ip_ipv6_parse_and_format_ip() {
let localhost_str = ~"::1";
let format_result = format_addr(v6::parse_addr(localhost_str));
let format_result = format_addr(&v6::parse_addr(localhost_str));
log(debug, fmt!("results: expected: '%s' actual: '%s'",
localhost_str, format_result));
assert format_result == localhost_str;
Expand Down Expand Up @@ -369,7 +371,7 @@ mod test {
Ipv6(_) => ~"IPv6"
};
log(debug, fmt!("test_get_addr: result %s: '%s'",
ipv_prefix, format_addr(r)));
ipv_prefix, format_addr(&r)));
}
// at least one result.. this is going to vary from system
// to system, based on stuff like the contents of /etc/hosts
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/net_tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn connect(-input_ip: ip::IpAddr, port: uint,
log(debug, ~"dealing w/ ipv4 connection..");
let connect_req_ptr =
ptr::addr_of((*socket_data_ptr).connect_req);
let addr_str = ip::format_addr(input_ip);
let addr_str = ip::format_addr(&input_ip);
let connect_result = match input_ip {
ip::Ipv4(addr) => {
// have to "recreate" the sockaddr_in/6
Expand Down Expand Up @@ -610,7 +610,7 @@ fn listen_common(-host_ip: ip::IpAddr, port: uint, backlog: uint,
uv::ll::set_data_for_uv_handle(
server_stream_ptr,
server_data_ptr);
let addr_str = ip::format_addr(loc_ip);
let addr_str = ip::format_addr(&loc_ip);
let bind_result = match loc_ip {
ip::Ipv4(addr) => {
log(debug, fmt!("addr: %?", addr));
Expand Down
53 changes: 28 additions & 25 deletions src/libstd/net_url.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Types/fns concerning URLs (see RFC 3986)
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

import core::cmp::Eq;
import map;
Expand Down Expand Up @@ -31,18 +33,19 @@ type UserInfo = {

type Query = ~[(~str, ~str)];

fn url(-scheme: ~str, -user: Option<UserInfo>, -host: ~str,
-port: Option<~str>, -path: ~str, -query: Query,
-fragment: Option<~str>) -> Url {
{ scheme: scheme, user: user, host: host, port: port,
path: path, query: query, fragment: fragment }
fn url(+scheme: ~str, +user: Option<UserInfo>, +host: ~str,
+port: Option<~str>, +path: ~str, +query: Query,
+fragment: Option<~str>) -> Url {
{ scheme: move scheme, user: move user, host: move host,
port: move port, path: move path, query: move query,
fragment: move fragment }
}

fn userinfo(-user: ~str, -pass: Option<~str>) -> UserInfo {
{user: user, pass: pass}
fn userinfo(+user: ~str, +pass: Option<~str>) -> UserInfo {
{user: move user, pass: move pass}
}

fn encode_inner(s: ~str, full_url: bool) -> ~str {
fn encode_inner(s: &str, full_url: bool) -> ~str {
do io::with_str_reader(s) |rdr| {
let mut out = ~"";

Expand Down Expand Up @@ -87,7 +90,7 @@ fn encode_inner(s: ~str, full_url: bool) -> ~str {
*
* This function is compliant with RFC 3986.
*/
fn encode(s: ~str) -> ~str {
fn encode(s: &str) -> ~str {
encode_inner(s, true)
}

Expand All @@ -97,11 +100,11 @@ fn encode(s: ~str) -> ~str {
*
* This function is compliant with RFC 3986.
*/
fn encode_component(s: ~str) -> ~str {
fn encode_component(s: &str) -> ~str {
encode_inner(s, false)
}

fn decode_inner(s: ~str, full_url: bool) -> ~str {
fn decode_inner(s: &str, full_url: bool) -> ~str {
do io::with_str_reader(s) |rdr| {
let mut out = ~"";

Expand Down Expand Up @@ -144,18 +147,18 @@ fn decode_inner(s: ~str, full_url: bool) -> ~str {
*
* This will only decode escape sequences generated by encode_uri.
*/
fn decode(s: ~str) -> ~str {
fn decode(s: &str) -> ~str {
decode_inner(s, true)
}

/**
* Decode a string encoded with percent encoding.
*/
fn decode_component(s: ~str) -> ~str {
fn decode_component(s: &str) -> ~str {
decode_inner(s, false)
}

fn encode_plus(s: ~str) -> ~str {
fn encode_plus(s: &str) -> ~str {
do io::with_str_reader(s) |rdr| {
let mut out = ~"";

Expand Down Expand Up @@ -266,7 +269,7 @@ fn decode_form_urlencoded(s: ~[u8]) ->
}


fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
fn split_char_first(s: &str, c: char) -> (~str, ~str) {
let len = str::len(s);
let mut index = len;
let mut mat = 0;
Expand All @@ -290,7 +293,7 @@ fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
}
}

fn userinfo_from_str(uinfo: ~str) -> UserInfo {
fn userinfo_from_str(uinfo: &str) -> UserInfo {
let (user, p) = split_char_first(uinfo, ':');
let pass = if str::len(p) == 0 {
option::None
Expand All @@ -300,7 +303,7 @@ fn userinfo_from_str(uinfo: ~str) -> UserInfo {
return userinfo(user, pass);
}

fn userinfo_to_str(-userinfo: UserInfo) -> ~str {
fn userinfo_to_str(+userinfo: UserInfo) -> ~str {
if option::is_some(userinfo.pass) {
return str::concat(~[copy userinfo.user, ~":",
option::unwrap(copy userinfo.pass),
Expand All @@ -316,7 +319,7 @@ impl UserInfo : Eq {
}
}

fn query_from_str(rawquery: ~str) -> Query {
fn query_from_str(rawquery: &str) -> Query {
let mut query: Query = ~[];
if str::len(rawquery) != 0 {
for str::split_char(rawquery, '&').each |p| {
Expand All @@ -327,7 +330,7 @@ fn query_from_str(rawquery: ~str) -> Query {
return query;
}

fn query_to_str(query: Query) -> ~str {
fn query_to_str(+query: Query) -> ~str {
let mut strvec = ~[];
for query.each |kv| {
let (k, v) = copy kv;
Expand All @@ -337,7 +340,7 @@ fn query_to_str(query: Query) -> ~str {
}

// returns the scheme and the rest of the url, or a parsing error
fn get_scheme(rawurl: ~str) -> result::Result<(~str, ~str), @~str> {
fn get_scheme(rawurl: &str) -> result::Result<(~str, ~str), @~str> {
for str::each_chari(rawurl) |i,c| {
match c {
'A' .. 'Z' | 'a' .. 'z' => again,
Expand Down Expand Up @@ -383,7 +386,7 @@ impl Input: Eq {
}

// returns userinfo, host, port, and unparsed part, or an error
fn get_authority(rawurl: ~str) ->
fn get_authority(+rawurl: ~str) ->
result::Result<(Option<UserInfo>, ~str, Option<~str>, ~str), @~str> {
if !str::starts_with(rawurl, ~"//") {
// there is no authority.
Expand Down Expand Up @@ -552,7 +555,7 @@ fn get_authority(rawurl: ~str) ->


// returns the path and unparsed part of url, or an error
fn get_path(rawurl: ~str, authority : bool) ->
fn get_path(rawurl: &str, authority : bool) ->
result::Result<(~str, ~str), @~str> {
let len = str::len(rawurl);
let mut end = len;
Expand Down Expand Up @@ -583,7 +586,7 @@ fn get_path(rawurl: ~str, authority : bool) ->
}

// returns the parsed query and the fragment, if present
fn get_query_fragment(rawurl: ~str) ->
fn get_query_fragment(rawurl: &str) ->
result::Result<(Query, Option<~str>), @~str> {
if !str::starts_with(rawurl, ~"?") {
if str::starts_with(rawurl, ~"#") {
Expand Down Expand Up @@ -615,7 +618,7 @@ fn get_query_fragment(rawurl: ~str) ->
*
*/

fn from_str(rawurl: ~str) -> result::Result<Url, ~str> {
fn from_str(rawurl: &str) -> result::Result<Url, ~str> {
// scheme
let mut schm = get_scheme(rawurl);
if result::is_err(schm) {
Expand Down Expand Up @@ -664,7 +667,7 @@ fn from_str(rawurl: ~str) -> result::Result<Url, ~str> {
* result in just "http://somehost.com".
*
*/
fn to_str(url: Url) -> ~str {
fn to_str(+url: Url) -> ~str {
let user = if option::is_some(url.user) {
userinfo_to_str(option::unwrap(copy url.user))
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/libstd/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
* A simple map based on a vector for small integer keys. Space requirements
* are O(highest integer key).
*/
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

import core::option;
import core::option::{Some, None};
import dvec::DVec;
Expand All @@ -26,7 +29,7 @@ fn mk<T: copy>() -> smallintmap<T> {
* the specified key then the original value is replaced.
*/
#[inline(always)]
fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) {
fn insert<T: copy>(self: smallintmap<T>, key: uint, +val: T) {
//io::println(fmt!("%?", key));
self.v.grow_set_elt(key, None, Some(val));
}
Expand Down
2 changes: 2 additions & 0 deletions src/libstd/term.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//! Simple ANSI color library
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

import core::Option;

Expand Down
8 changes: 5 additions & 3 deletions src/libstd/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* very naive algorithm, but it will probably be updated to be a
* red-black tree or something else.
*/
#[forbid(deprecated_mode)];
#[forbid(deprecated_pattern)];

import core::cmp::{Eq, Ord};
import core::option::{Some, None};
Expand All @@ -30,7 +32,7 @@ enum tree_node<K, V> = {
fn treemap<K, V>() -> treemap<K, V> { @mut None }

/// Insert a value into the map
fn insert<K: copy Eq Ord, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) {
fn insert<K: copy Eq Ord, V: copy>(m: &mut tree_edge<K, V>, +k: K, +v: V) {
match copy *m {
None => {
*m = Some(@tree_node({key: k,
Expand All @@ -52,7 +54,7 @@ fn insert<K: copy Eq Ord, V: copy>(m: &mut tree_edge<K, V>, k: K, v: V) {
}

/// Find a value based on the key
fn find<K: copy Eq Ord, V: copy>(m: &const tree_edge<K, V>, k: K)
fn find<K: copy Eq Ord, V: copy>(m: &const tree_edge<K, V>, +k: K)
-> Option<V> {
match copy *m {
None => None,
Expand Down Expand Up @@ -124,7 +126,7 @@ mod tests {
insert(m, 1, ());

let n = @mut 0;
fn t(n: @mut int, &&k: int, &&_v: ()) {
fn t(n: @mut int, +k: int, +_v: ()) {
assert (*n == k); *n += 1;
}
traverse(m, |x,y| t(n, x, y));
Expand Down