Skip to content

Commit 71b962a

Browse files
committed
Update to rust master
1 parent e888625 commit 71b962a

File tree

17 files changed

+108
-93
lines changed

17 files changed

+108
-93
lines changed

Cargo.lock

Lines changed: 60 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ url = "0.2.0"
5050
postgres = { version = "0.8", features = ["time"] }
5151
r2d2 = "0.5.0"
5252
r2d2_postgres = "0.9"
53-
openssl = "0.5"
53+
openssl = "0.6"
5454
curl = "0.2"
5555
oauth2 = "0.1"
5656
log = "0.3"

RUSTVERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2015-03-26
1+
2015-04-08

src/bin/populate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
// cargo run --bin populate version_id1 version_id2 ...
66

77
#![deny(warnings)]
8-
#![feature(std_misc)]
98

109
extern crate cargo_registry;
1110
extern crate postgres;
1211
extern crate time;
1312
extern crate rand;
1413

1514
use std::env;
16-
use std::time::Duration;
15+
use time::Duration;
1716
use rand::{StdRng, Rng};
1817

1918
fn main() {

src/bin/server.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![feature(convert)]
32

43
extern crate cargo_registry;
54
extern crate conduit_middleware;

src/bin/update-downloads.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![deny(warnings)]
2-
#![feature(std_misc, thread_sleep)]
32

43
extern crate cargo_registry;
54
extern crate postgres;
@@ -8,7 +7,7 @@ extern crate time;
87

98
use std::env;
109
use std::collections::HashMap;
11-
use std::time::Duration;
10+
use time::Duration;
1211

1312
use cargo_registry::{VersionDownload, Version, Model};
1413

@@ -18,14 +17,14 @@ static LIMIT: i64 = 1000;
1817
fn main() {
1918
let daemon = env::args().nth(1).as_ref().map(|s| &s[..])
2019
== Some("daemon");
21-
let sleep = env::args().nth(2).map(|s| s.parse::<i64>().unwrap());
20+
let sleep = env::args().nth(2).map(|s| s.parse::<u32>().unwrap());
2221
loop {
2322
let conn = postgres::Connection::connect(&env("DATABASE_URL")[..],
2423
&postgres::SslMode::None).unwrap();
2524
update(&conn).unwrap();
2625
drop(conn);
2726
if daemon {
28-
std::thread::sleep(Duration::seconds(sleep.unwrap()));
27+
std::thread::sleep_ms(sleep.unwrap() * 1000);
2928
} else {
3029
break
3130
}

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type PooledConnnection<'a> =
1818
r2d2::PooledConnection<'a, PostgresConnectionManager>;
1919

2020
pub fn pool(url: &str, config: r2d2::Config) -> Pool {
21-
let mgr = PostgresConnectionManager::new(url, pg::SslMode::None);
21+
let mgr = PostgresConnectionManager::new(url, pg::SslMode::None).unwrap();
2222
r2d2::Pool::new(config, mgr, Box::new(LoggingErrorHandler)).unwrap()
2323
}
2424

src/dependency.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::num::FromPrimitive;
2-
31
use semver;
42

53
use pg;
@@ -33,11 +31,15 @@ pub struct EncodableDependency {
3331
pub kind: Kind,
3432
}
3533

36-
#[derive(FromPrimitive, Copy, Clone)]
34+
#[derive(Copy, Clone)]
35+
// NB: this order is important, it must be retained! The database stores an
36+
// integer corresponding to each variant.
3737
pub enum Kind {
3838
Normal,
3939
Build,
4040
Dev,
41+
42+
// if you add a kind here, be sure to update `from_row` below.
4143
}
4244

4345
impl Dependency {
@@ -106,7 +108,12 @@ impl Model for Dependency {
106108
features: features.split(',').map(|s| s.to_string())
107109
.collect(),
108110
target: row.get("target"),
109-
kind: FromPrimitive::from_i32(kind.unwrap_or(0)).unwrap(),
111+
kind: match kind.unwrap_or(0) {
112+
0 => Kind::Normal,
113+
1 => Kind::Build,
114+
2 => Kind::Dev,
115+
n => panic!("unknown kind: {}", n),
116+
}
110117
}
111118
}
112119

src/git.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_serialize::json;
1010

1111
use app::App;
1212
use dependency::Kind;
13-
use util::{CargoResult, internal, ChainError};
13+
use util::{CargoResult, internal};
1414

1515
#[derive(RustcEncodable, RustcDecodable)]
1616
pub struct Crate {
@@ -34,7 +34,7 @@ pub struct Dependency {
3434
}
3535

3636
fn index_file(base: &Path, name: &str) -> PathBuf {
37-
let name = name.to_lowercase();
37+
let name = name.chars().flat_map(|c| c.to_lowercase()).collect::<String>();
3838
match name.len() {
3939
1 => base.join("1").join(&name),
4040
2 => base.join("2").join(&name),
@@ -141,9 +141,6 @@ fn commit_and_push<F>(repo: &git2::Repository, mut f: F) -> CargoResult<()>
141141

142142
match push.finish() {
143143
Ok(()) => {
144-
try!(push.statuses().chain_error(|| {
145-
internal("failed to update some remote refspecs")
146-
}));
147144
try!(push.update_tips(None, None));
148145
return Ok(())
149146
}

src/keyword.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl Keyword {
6363

6464
pub fn valid_name(name: &str) -> bool {
6565
if name.len() == 0 { return false }
66-
name.char_at(0).is_alphanumeric() &&
66+
name.chars().next().unwrap().is_alphanumeric() &&
6767
name.chars().all(|c| c.is_alphanumeric() || c == '_' || c == '-') &&
6868
name.chars().all(|c| c.is_ascii())
6969
}

0 commit comments

Comments
 (0)