Skip to content

Commit 6bb5bc3

Browse files
committed
Update to rust master
1 parent b505685 commit 6bb5bc3

24 files changed

+248
-238
lines changed

Cargo.lock

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

src/bin/server.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ extern crate "conduit-middleware" as conduit_middleware;
33
extern crate civet;
44
extern crate git2;
55

6+
use std::io::{self, fs, File};
67
use std::os;
78
use std::sync::Arc;
8-
use std::io::{mod, fs, File};
9+
use std::sync::mpsc::channel;
910
use civet::Server;
1011

1112
fn main() {
@@ -68,7 +69,7 @@ fn main() {
6869

6970
// TODO: handle a graceful shutdown by just waiting for a SIG{INT,TERM}
7071
let (_tx, rx) = channel::<()>();
71-
rx.recv();
72+
rx.recv().unwrap();
7273
}
7374

7475
fn env(s: &str) -> String {

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#[deriving(Clone)]
1+
#[derive(Clone)]
22
pub struct Config {
33
pub s3_bucket: String,
44
pub s3_region: Option<String>,

src/db.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::sync::Arc;
55

66
use pg;
77
use pg::types::ToSql;
8-
use r2d2::{mod, LoggingErrorHandler};
8+
use r2d2::{self, LoggingErrorHandler};
99
use r2d2_postgres::{PostgresPoolManager, Error};
1010
use conduit::{Request, Response};
1111
use conduit_middleware::Middleware;

src/dependency.rs

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

35
use pg;
@@ -18,7 +20,7 @@ pub struct Dependency {
1820
pub kind: Kind,
1921
}
2022

21-
#[deriving(RustcEncodable, RustcDecodable)]
23+
#[derive(RustcEncodable, RustcDecodable)]
2224
pub struct EncodableDependency {
2325
pub id: i32,
2426
pub version_id: i32,
@@ -31,7 +33,7 @@ pub struct EncodableDependency {
3133
pub kind: Kind,
3234
}
3335

34-
#[deriving(FromPrimitive, Copy)]
36+
#[derive(FromPrimitive, Copy)]
3537
pub enum Kind {
3638
Normal,
3739
Build,

src/download.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct VersionDownload {
1313
pub date: Timespec,
1414
}
1515

16-
#[deriving(RustcEncodable, RustcDecodable)]
16+
#[derive(RustcEncodable, RustcDecodable)]
1717
pub struct EncodableVersionDownload {
1818
pub id: i32,
1919
pub version: i32,

src/git.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use app::{App, RequestApp};
1717
use dependency::Kind;
1818
use util::{CargoResult, internal, ChainError};
1919

20-
#[deriving(RustcEncodable, RustcDecodable)]
20+
#[derive(RustcEncodable, RustcDecodable)]
2121
pub struct Crate {
2222
pub name: String,
2323
pub vers: String,
@@ -27,7 +27,7 @@ pub struct Crate {
2727
pub yanked: Option<bool>,
2828
}
2929

30-
#[deriving(RustcEncodable, RustcDecodable)]
30+
#[derive(RustcEncodable, RustcDecodable)]
3131
pub struct Dependency {
3232
pub name: String,
3333
pub req: String,

src/html/escape.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ impl<'a> fmt::Show for Escape<'a> {
2929
for (i, ch) in s.bytes().enumerate() {
3030
match ch as char {
3131
'<' | '>' | '&' | '\'' | '"' => {
32-
try!(fmt.write(pile_o_bits.slice(last, i).as_bytes()));
32+
try!(fmt.write_str(pile_o_bits.slice(last, i)));
3333
let s = match ch as char {
3434
'>' => "&gt;",
3535
'<' => "&lt;",
@@ -38,15 +38,15 @@ impl<'a> fmt::Show for Escape<'a> {
3838
'"' => "&quot;",
3939
_ => unreachable!()
4040
};
41-
try!(fmt.write(s.as_bytes()));
41+
try!(fmt.write_str(s));
4242
last = i + 1;
4343
}
4444
_ => {}
4545
}
4646
}
4747

4848
if last < s.len() {
49-
try!(fmt.write(pile_o_bits.slice_from(last).as_bytes()));
49+
try!(fmt.write_str(pile_o_bits.slice_from(last)));
5050
}
5151
Ok(())
5252
}

src/keyword.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use db::{Connection, RequestTransaction};
1212
use util::{RequestUtils, CargoResult, Require, internal};
1313
use util::errors::{NotFound, FromError};
1414

15-
#[deriving(Clone)]
15+
#[derive(Clone)]
1616
pub struct Keyword {
1717
pub id: i32,
1818
pub keyword: String,
1919
pub created_at: Timespec,
2020
pub crates_cnt: i32,
2121
}
2222

23-
#[deriving(RustcEncodable, RustcDecodable)]
23+
#[derive(RustcEncodable, RustcDecodable)]
2424
pub struct EncodableKeyword {
2525
pub id: String,
2626
pub keyword: String,
@@ -164,9 +164,9 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
164164
let row = try!(stmt.query(&[])).next().unwrap();
165165
let total = row.get(0u);
166166

167-
#[deriving(RustcEncodable)]
167+
#[derive(RustcEncodable)]
168168
struct R { keywords: Vec<EncodableKeyword>, meta: Meta }
169-
#[deriving(RustcEncodable)]
169+
#[derive(RustcEncodable)]
170170
struct Meta { total: i64 }
171171

172172
Ok(req.json(&R {
@@ -183,7 +183,7 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
183183
None => return Err(FromError::from_error(NotFound)),
184184
};
185185

186-
#[deriving(RustcEncodable)]
186+
#[derive(RustcEncodable)]
187187
struct R { keyword: EncodableKeyword }
188188
Ok(req.json(&R { keyword: kw.encodable() }))
189189
}

src/krate.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use curl::http;
1313
use pg;
1414
use pg::types::ToSql;
1515
use semver;
16-
use url::{mod, Url};
16+
use url::{self, Url};
1717

1818
use {Model, User, Keyword, Version};
1919
use app::{App, RequestApp};
@@ -29,7 +29,7 @@ use util::{LimitErrorReader, HashingReader};
2929
use util::{RequestUtils, CargoResult, Require, internal, ChainError, human};
3030
use version::EncodableVersion;
3131

32-
#[deriving(Clone)]
32+
#[derive(Clone)]
3333
pub struct Crate {
3434
pub id: i32,
3535
pub name: String,
@@ -47,7 +47,7 @@ pub struct Crate {
4747
pub repository: Option<String>,
4848
}
4949

50-
#[deriving(RustcEncodable, RustcDecodable)]
50+
#[derive(RustcEncodable, RustcDecodable)]
5151
pub struct EncodableCrate {
5252
pub id: String,
5353
pub name: String,
@@ -65,7 +65,7 @@ pub struct EncodableCrate {
6565
pub links: CrateLinks,
6666
}
6767

68-
#[deriving(RustcEncodable, RustcDecodable)]
68+
#[derive(RustcEncodable, RustcDecodable)]
6969
pub struct CrateLinks {
7070
pub version_downloads: String,
7171
pub versions: Option<String>,
@@ -513,9 +513,9 @@ pub fn index(req: &mut Request) -> CargoResult<Response> {
513513
let row = try!(stmt.query(args)).next().unwrap();
514514
let total = row.get(0u);
515515

516-
#[deriving(RustcEncodable)]
516+
#[derive(RustcEncodable)]
517517
struct R { crates: Vec<EncodableCrate>, meta: Meta }
518-
#[deriving(RustcEncodable)]
518+
#[derive(RustcEncodable)]
519519
struct Meta { total: i64 }
520520

521521
Ok(req.json(&R {
@@ -553,7 +553,7 @@ pub fn summary(req: &mut Request) -> CargoResult<Response> {
553553
let most_downloaded = try!(tx.prepare("SELECT * FROM crates \
554554
ORDER BY downloads DESC LIMIT 10"));
555555

556-
#[deriving(RustcEncodable)]
556+
#[derive(RustcEncodable)]
557557
struct R {
558558
num_downloads: i64,
559559
num_crates: i64,
@@ -578,7 +578,7 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
578578
let ids = versions.iter().map(|v| v.id).collect();
579579
let kws = try!(krate.keywords(conn));
580580

581-
#[deriving(RustcEncodable)]
581+
#[derive(RustcEncodable)]
582582
struct R {
583583
krate: EncodableCrate,
584584
versions: Vec<EncodableVersion>,
@@ -698,7 +698,7 @@ pub fn new(req: &mut Request) -> CargoResult<Response> {
698698
// Now that we've come this far, we're committed!
699699
bomb.path = None;
700700

701-
#[deriving(RustcEncodable)]
701+
#[derive(RustcEncodable)]
702702
struct R { krate: EncodableCrate }
703703
Ok(req.json(&R { krate: krate.encodable(None) }))
704704
}
@@ -789,7 +789,7 @@ pub fn download(req: &mut Request) -> CargoResult<Response> {
789789
crate_name, crate_name, version);
790790

791791
if req.wants_json() {
792-
#[deriving(RustcEncodable)]
792+
#[derive(RustcEncodable)]
793793
struct R { url: String }
794794
Ok(req.json(&R{ url: redirect_url }))
795795
} else {
@@ -820,7 +820,7 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
820820
downloads.push(download.encodable());
821821
}
822822

823-
#[deriving(RustcEncodable)]
823+
#[derive(RustcEncodable)]
824824
struct R { version_downloads: Vec<EncodableVersionDownload> }
825825
Ok(req.json(&R{ version_downloads: downloads }))
826826
}
@@ -843,7 +843,7 @@ pub fn follow(req: &mut Request) -> CargoResult<Response> {
843843
try!(tx.execute("INSERT INTO follows (user_id, crate_id)
844844
VALUES ($1, $2)", &[&user.id, &krate.id]));
845845
}
846-
#[deriving(RustcEncodable)]
846+
#[derive(RustcEncodable)]
847847
struct R { ok: bool }
848848
Ok(req.json(&R { ok: true }))
849849
}
@@ -854,7 +854,7 @@ pub fn unfollow(req: &mut Request) -> CargoResult<Response> {
854854
try!(tx.execute("DELETE FROM follows
855855
WHERE user_id = $1 AND crate_id = $2",
856856
&[&user.id, &krate.id]));
857-
#[deriving(RustcEncodable)]
857+
#[derive(RustcEncodable)]
858858
struct R { ok: bool }
859859
Ok(req.json(&R { ok: true }))
860860
}
@@ -865,7 +865,7 @@ pub fn following(req: &mut Request) -> CargoResult<Response> {
865865
let stmt = try!(tx.prepare("SELECT 1 FROM follows
866866
WHERE user_id = $1 AND crate_id = $2"));
867867
let mut rows = try!(stmt.query(&[&user.id, &krate.id]));
868-
#[deriving(RustcEncodable)]
868+
#[derive(RustcEncodable)]
869869
struct R { following: bool }
870870
Ok(req.json(&R { following: rows.next().is_some() }))
871871
}
@@ -878,7 +878,7 @@ pub fn versions(req: &mut Request) -> CargoResult<Response> {
878878
let versions = versions.into_iter().map(|v| v.encodable(crate_name))
879879
.collect();
880880

881-
#[deriving(RustcEncodable)]
881+
#[derive(RustcEncodable)]
882882
struct R { versions: Vec<EncodableVersion> }
883883
Ok(req.json(&R{ versions: versions }))
884884
}
@@ -890,7 +890,7 @@ pub fn owners(req: &mut Request) -> CargoResult<Response> {
890890
let owners = try!(krate.owners(tx));
891891
let owners = owners.into_iter().map(|u| u.encodable()).collect();
892892

893-
#[deriving(RustcEncodable)]
893+
#[derive(RustcEncodable)]
894894
struct R { users: Vec<EncodableUser> }
895895
Ok(req.json(&R{ users: owners }))
896896
}
@@ -912,7 +912,7 @@ fn modify_owners(req: &mut Request, add: bool) -> CargoResult<Response> {
912912
return Err(human("must already be an owner to modify owners"))
913913
}
914914

915-
#[deriving(RustcDecodable)] struct Request { users: Vec<String> }
915+
#[derive(RustcDecodable)] struct Request { users: Vec<String> }
916916
let request: Request = try!(json::decode(body.as_slice()).map_err(|_| {
917917
human("invalid json request")
918918
}));
@@ -928,7 +928,7 @@ fn modify_owners(req: &mut Request, add: bool) -> CargoResult<Response> {
928928
}
929929
}
930930

931-
#[deriving(RustcEncodable)]
931+
#[derive(RustcEncodable)]
932932
struct R { ok: bool }
933933
Ok(req.json(&R{ ok: true }))
934934
}
@@ -944,9 +944,9 @@ pub fn reverse_dependencies(req: &mut Request) -> CargoResult<Response> {
944944
dep.encodable(crate_name.as_slice())
945945
}).collect();
946946

947-
#[deriving(RustcEncodable)]
947+
#[derive(RustcEncodable)]
948948
struct R { dependencies: Vec<EncodableDependency>, meta: Meta }
949-
#[deriving(RustcEncodable)]
949+
#[derive(RustcEncodable)]
950950
struct Meta { total: i64 }
951951
Ok(req.json(&R{ dependencies: rev_deps, meta: Meta { total: total } }))
952952
}

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#![feature(macro_rules, phase, slicing_syntax)]
1+
#![feature(macro_rules, phase, slicing_syntax, associated_types)]
2+
#![feature(old_orphan_check)]
23
#![allow(missing_copy_implementations)]
34

45
extern crate "rustc-serialize" as rustc_serialize;
@@ -62,7 +63,7 @@ pub mod util;
6263
pub mod version;
6364
mod licenses;
6465

65-
#[deriving(PartialEq, Eq, Clone, Copy)]
66+
#[derive(PartialEq, Eq, Clone, Copy)]
6667
pub enum Env {
6768
Development,
6869
Test,

src/model.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use db::Connection;
33
use util::{CargoResult, Require};
44
use util::errors::NotFound;
55

6-
pub trait Model {
6+
pub trait Model: Sized {
77
fn from_row(row: &pg::Row) -> Self;
88
fn table_name(_: Option<Self>) -> &'static str;
99

src/s3/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ path = "lib.rs"
1313
openssl = "0.2.0"
1414
time = "0.1.0"
1515
curl = "0.1.0"
16-
rustc-serialize = "0.1"
16+
rustc-serialize = "0.2"

0 commit comments

Comments
 (0)