Skip to content

Commit 8abb2dc

Browse files
upgrade cargo and start fixing upgrade errors
1 parent 32102ce commit 8abb2dc

File tree

9 files changed

+1747
-733
lines changed

9 files changed

+1747
-733
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ log = "0.3"
1212
rustc-serialize = "0.3"
1313
regex = "0.2"
1414
clap = "2"
15-
crates-index-diff = "3"
16-
git2 = "0.6"
15+
crates-index-diff = "4"
16+
git2 = "0.7"
1717
time = "0.1"
18-
reqwest = "0.5"
19-
semver = "0.6"
18+
reqwest = "0.9"
19+
semver = "0.9"
2020
slug = "=0.1.1"
2121
env_logger = "0.4"
2222
magic = "0.12"
@@ -25,10 +25,11 @@ r2d2_postgres = "0.12"
2525
url = "1.4"
2626
libc = "0.2"
2727
badge = { version = "0", path = "src/web/badge" }
28-
error-chain = "0.10"
28+
error-chain = "0.12"
2929
comrak = { version = "0.2.10", default-features = false }
3030
toml = "0.4"
3131
html5ever = "0.22"
32+
cargo = "0.30"
3233

3334
# iron dependencies
3435
iron = "0.5"
@@ -37,10 +38,6 @@ handlebars-iron = "0.22"
3738
params = "0.6"
3839
staticfile = { version = "0.4", features = [ "cache" ] }
3940

40-
[dependencies.cargo]
41-
git = "https://github.com/onur/cargo.git"
42-
branch = "docs.rs"
43-
4441
[dependencies.postgres]
4542
version = "0.14"
4643
features = [ "with-time", "with-rustc-serialize" ]
@@ -50,8 +47,8 @@ tempdir = "0.3"
5047

5148
[build-dependencies]
5249
time = "0.1"
53-
git2 = "0.6"
54-
sass-rs = "0.0.18"
50+
git2 = "0.7"
51+
sass-rs = "0.2"
5552

5653
[[bin]]
5754
name = "cratesfyi"

build.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ fn get_git_hash() -> Option<String> {
4040

4141

4242
fn compile_sass() {
43-
use sass_rs::sass_context::SassFileContext;
43+
use sass_rs::Context;
4444

45-
let mut file_context = SassFileContext::new(concat!(env!("CARGO_MANIFEST_DIR"),
46-
"/templates/style.scss"));
45+
let mut file_context = Context::new_file(concat!(env!("CARGO_MANIFEST_DIR"),
46+
"/templates/style.scss")).unwrap();
4747
let css = file_context.compile().unwrap();
4848
let dest_path = Path::new(&env::var("OUT_DIR").unwrap()).join("style.css");
4949
let mut file = File::create(&dest_path).unwrap();

src/db/add_package.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use cargo::core::{Package, TargetKind};
1313
use rustc_serialize::json::{Json, ToJson};
1414
use slug::slugify;
1515
use reqwest::Client;
16-
use reqwest::header::{Accept, qitem};
16+
use reqwest::header::ACCEPT;
1717
use semver;
1818
use postgres::Connection;
1919
use time;
@@ -197,11 +197,11 @@ pub fn add_build_into_database(conn: &Connection,
197197

198198
fn initialize_package_in_database(conn: &Connection, pkg: &Package) -> Result<i32> {
199199
let mut rows = try!(conn.query("SELECT id FROM crates WHERE name = $1",
200-
&[&pkg.manifest().name()]));
200+
&[&pkg.manifest().name().as_str()]));
201201
// insert crate into database if it is not exists
202202
if rows.len() == 0 {
203203
rows = try!(conn.query("INSERT INTO crates (name) VALUES ($1) RETURNING id",
204-
&[&pkg.manifest().name()]));
204+
&[&pkg.manifest().name().as_str()]));
205205
}
206206
Ok(rows.get(0).get(0))
207207
}
@@ -212,7 +212,7 @@ fn initialize_package_in_database(conn: &Connection, pkg: &Package) -> Result<i3
212212
fn convert_dependencies(pkg: &Package) -> Vec<(String, String)> {
213213
let mut dependencies: Vec<(String, String)> = Vec::new();
214214
for dependency in pkg.manifest().dependencies() {
215-
let name = dependency.name().to_string();
215+
let name = dependency.package_name().to_string();
216216
let version = format!("{}", dependency.version_req());
217217
dependencies.push((name, version));
218218
}
@@ -279,9 +279,9 @@ fn get_release_time_yanked_downloads
279279
pkg.manifest().name());
280280
// FIXME: There is probably better way to do this
281281
// and so many unwraps...
282-
let client = try!(Client::new());
282+
let client = Client::new();
283283
let mut res = try!(client.get(&url[..])
284-
.header(Accept(vec![qitem("application/json".parse().unwrap())]))
284+
.header(ACCEPT, "application/json")
285285
.send());
286286
let mut body = String::new();
287287
res.read_to_string(&mut body).unwrap();
@@ -387,9 +387,9 @@ fn add_owners_into_database(conn: &Connection, pkg: &Package, crate_id: &i32) ->
387387
// owners available in: https://crates.io/api/v1/crates/rand/owners
388388
let owners_url = format!("https://crates.io/api/v1/crates/{}/owners",
389389
&pkg.manifest().name());
390-
let client = try!(Client::new());
390+
let client = Client::new();
391391
let mut res = try!(client.get(&owners_url[..])
392-
.header(Accept(vec![qitem("application/json".parse().unwrap())]))
392+
.header(ACCEPT, "application/json")
393393
.send());
394394
// FIXME: There is probably better way to do this
395395
// and so many unwraps...

src/docbuilder/chroot_builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ impl DocBuilder {
239239
debug!("Cleaning package");
240240
use std::fs::remove_dir_all;
241241
let documentation_path = PathBuf::from(&self.options.destination)
242-
.join(package.manifest().name());
242+
.join(package.manifest().name().as_str());
243243
let source_path = source_path(&package).unwrap();
244244
// Some crates don't have documentation, so we don't care if removing_dir_all fails
245245
let _ = self.remove_build_dir();

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ error_chain! {
1919
ReqwestError(reqwest::Error);
2020
Git2Error(git2::Error);
2121
MagicError(MagicError);
22-
CargoError(Box<cargo::CargoError>);
22+
CargoError(cargo::CargoError);
2323
RegexError(regex::Error);
2424
}
2525
}

src/utils/build_doc.rs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ use std::env;
88
use std::sync::Arc;
99

1010
use cargo::core::{SourceId, Dependency, Registry, Source, Package, Workspace};
11-
use cargo::util::{CargoResult, Config, human, Filesystem};
11+
use cargo::core::compiler::{DefaultExecutor, CompileMode, MessageFormat, BuildConfig, Executor};
12+
use cargo::util::{CargoResult, Config, internal, Filesystem};
1213
use cargo::sources::SourceConfigMap;
13-
use cargo::ops::{self, Packages, DefaultExecutor};
14+
use cargo::ops::{self, Packages};
1415

1516
use utils::{get_current_versions, parse_rustc_version};
1617
use error::Result;
@@ -37,17 +38,17 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> Result
3738
try!(source.update());
3839

3940
let dep = try!(Dependency::parse_no_deprecated(name, vers, &source_id));
40-
let deps = try!(source.query(&dep));
41+
let deps = try!(source.query_vec(&dep));
4142
let pkg = try!(deps.iter().map(|p| p.package_id()).max()
4243
// FIXME: This is probably not a rusty way to handle options and results
4344
// or maybe it is who knows...
4445
.map(|pkgid| source.download(pkgid))
45-
.unwrap_or(Err(human("PKG download error"))));
46+
.unwrap_or(Err(internal("PKG download error"))));
4647

4748
let current_dir = try!(env::current_dir());
4849
let target_dir = PathBuf::from(current_dir).join("cratesfyi");
4950

50-
let metadata = Metadata::from_package(&pkg).map_err(|e| human(e.description()))?;
51+
let metadata = Metadata::from_package(&pkg).map_err(|e| internal(e.description()))?;
5152

5253
// This is only way to pass rustc_args to cargo.
5354
// CompileOptions::target_rustc_args is used only for the current crate,
@@ -60,6 +61,8 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> Result
6061

6162
// since https://github.com/rust-lang/rust/pull/48511 we can pass --resource-suffix to
6263
// add correct version numbers to css and javascript files
64+
// TODO: we can add --extern-html-root-url too, thanks to
65+
// https://github.com/rust-lang/rust/pull/51384
6366
let mut rustdoc_args: Vec<String> =
6467
vec!["-Z".to_string(), "unstable-options".to_string(),
6568
"--resource-suffix".to_string(),
@@ -68,28 +71,34 @@ pub fn build_doc(name: &str, vers: Option<&str>, target: Option<&str>) -> Result
6871
rustdoc_args.append(&mut package_rustdoc_args.iter().map(|s| s.to_owned()).collect());
6972
}
7073

74+
let mut build_config = try!(BuildConfig::new(&config,
75+
None,
76+
&target.map(|t| t.to_string()),
77+
CompileMode::Doc { deps: false }));
78+
build_config.release = false;
79+
build_config.message_format = MessageFormat::Human;
80+
7181
let opts = ops::CompileOptions {
7282
config: &config,
73-
jobs: None,
74-
target: target,
75-
features: &metadata.features.unwrap_or(Vec::new()),
83+
build_config,
84+
features: metadata.features.unwrap_or(Vec::new()),
7685
all_features: metadata.all_features,
7786
no_default_features: metadata.no_default_features,
78-
spec: Packages::Packages(&[]),
79-
mode: ops::CompileMode::Doc { deps: false },
80-
release: false,
81-
message_format: ops::MessageFormat::Human,
87+
spec: Packages::Packages(Vec::new()),
8288
filter: ops::CompileFilter::new(true,
83-
&[], false,
84-
&[], false,
85-
&[], false,
86-
&[], false),
89+
Vec::new(), false,
90+
Vec::new(), false,
91+
Vec::new(), false,
92+
Vec::new(), false,
93+
false),
8794
target_rustc_args: None,
88-
target_rustdoc_args: Some(rustdoc_args.as_slice()),
95+
target_rustdoc_args: Some(rustdoc_args),
96+
export_dir: None,
8997
};
9098

9199
let ws = try!(Workspace::ephemeral(pkg, &config, Some(Filesystem::new(target_dir)), false));
92-
try!(ops::compile_ws(&ws, Some(source), &opts, Arc::new(DefaultExecutor)));
100+
let exec: Arc<Executor> = Arc::new(DefaultExecutor);
101+
try!(ops::compile_ws(&ws, Some(source), &opts, &exec));
93102

94103
Ok(try!(ws.current()).clone())
95104
}
@@ -108,12 +117,12 @@ pub fn get_package(name: &str, vers: Option<&str>) -> CargoResult<Package> {
108117
try!(source.update());
109118

110119
let dep = try!(Dependency::parse_no_deprecated(name, vers, &source_id));
111-
let deps = try!(source.query(&dep));
120+
let deps = try!(source.query_vec(&dep));
112121
let pkg = try!(deps.iter().map(|p| p.package_id()).max()
113122
// FIXME: This is probably not a rusty way to handle options and results
114123
// or maybe it is who knows...
115124
.map(|pkgid| source.download(pkgid))
116-
.unwrap_or(Err(human("PKG download error"))));
125+
.unwrap_or(Err(internal("PKG download error"))));
117126

118127
Ok(pkg)
119128
}

src/utils/github_updater.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,24 +74,24 @@ fn get_github_fields(path: &str) -> Result<GitHubFields> {
7474
let body = {
7575
use std::io::Read;
7676
use reqwest::{Client, StatusCode};
77-
use reqwest::header::{UserAgent, Authorization, Basic};
77+
use reqwest::header::USER_AGENT;
7878
use std::env;
7979

80-
let client = try!(Client::new());
80+
let client = Client::new();
8181
let mut body = String::new();
8282

8383
let mut resp = try!(client.get(&format!("https://api.github.com/repos/{}", path)[..])
84-
.header(UserAgent(format!("cratesfyi/{}", env!("CARGO_PKG_VERSION"))))
85-
.header(Authorization(Basic {
86-
username: env::var("CRATESFYI_GITHUB_USERNAME")
84+
.header(USER_AGENT, format!("cratesfyi/{}", env!("CARGO_PKG_VERSION")))
85+
.basic_auth(
86+
env::var("CRATESFYI_GITHUB_USERNAME")
8787
.ok()
8888
.and_then(|u| Some(u.to_string()))
8989
.unwrap_or("".to_string()),
90-
password: env::var("CRATESFYI_GITHUB_ACCESSTOKEN").ok(),
91-
}))
90+
env::var("CRATESFYI_GITHUB_ACCESSTOKEN").ok(),
91+
)
9292
.send());
9393

94-
if resp.status() != &StatusCode::Ok {
94+
if resp.status() != StatusCode::OK {
9595
return Err("Failed to get github data".into());
9696
}
9797

src/utils/pubsubhubbub.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ fn ping_hub(url: &str) -> Result<Response> {
66
let mut params = HashMap::new();
77
params.insert("hub.mode", "publish");
88
params.insert("hub.url", "https://docs.rs/releases/feed");
9-
let client = try!(Client::new());
9+
let client = Client::new();
1010
client.post(url).form(&params).send()
1111
}
1212

0 commit comments

Comments
 (0)