Skip to content

[beta] Backport #6771 #6808

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

Merged
merged 4 commits into from
Apr 1, 2019
Merged
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
14 changes: 0 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,6 @@ matrix:
rust: beta
if: branch != master OR type = pull_request

# Minimum Rust supported channel. We enable these to make sure we
# continue to work on the advertised minimum Rust version.
# However cargo only supports the latest stable so this will get
# increased every 6 weeks or so when the first PR to use a new feature.
- env: TARGET=x86_64-unknown-linux-gnu
ALT=i686-unknown-linux-gnu
rust: 1.31.0
script:
- rustup toolchain install nightly || travis_terminate 1
- cargo +nightly generate-lockfile -Z minimal-versions || travis_terminate 1
- cargo -V || travis_terminate 1
- cargo test --features=deny-warnings || travis_terminate 1
if: branch != master OR type = pull_request

- env: TARGET=x86_64-unknown-linux-gnu
ALT=i686-unknown-linux-gnu
rust: nightly
Expand Down
3 changes: 0 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ environment:
matrix:
- TARGET: x86_64-pc-windows-msvc
OTHER_TARGET: i686-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc
MINIMAL_VERSIONS: true
CFG_DISABLE_CROSS_TESTS: 1

install:
- if NOT defined APPVEYOR_PULL_REQUEST_NUMBER if "%APPVEYOR_REPO_BRANCH%" == "master" appveyor exit
Expand Down
1 change: 0 additions & 1 deletion src/cargo/util/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ pub fn process_error(

#[cfg(unix)]
fn status_to_string(status: ExitStatus) -> String {
use libc;
use std::os::unix::process::*;

if let Some(signal) = status.signal() {
Expand Down
1 change: 0 additions & 1 deletion src/cargo/util/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> {

#[cfg(unix)]
pub fn bytes2path(bytes: &[u8]) -> CargoResult<PathBuf> {
use std::ffi::OsStr;
use std::os::unix::prelude::*;
Ok(PathBuf::from(OsStr::from_bytes(bytes)))
}
Expand Down
1 change: 1 addition & 0 deletions src/crates-io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ path = "lib.rs"
[dependencies]
curl = "0.4"
failure = "0.1.1"
http = "0.1"
serde = { version = "1.0", features = ['derive'] }
serde_derive = "1.0"
serde_json = "1.0"
Expand Down
36 changes: 19 additions & 17 deletions src/crates-io/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use std::io::Cursor;

use curl::easy::{Easy, List};
use failure::bail;
use http::status::StatusCode;
use serde::{Deserialize, Serialize};
use serde_json;
use url::percent_encoding::{percent_encode, QUERY_ENCODE_SET};
Expand Down Expand Up @@ -323,30 +324,31 @@ fn handle(handle: &mut Easy, read: &mut dyn FnMut(&mut [u8]) -> usize) -> Result
handle.perform()?;
}

match handle.response_code()? {
0 => {} // file upload url sometimes
200 => {}
403 => bail!("received 403 unauthorized response code"),
404 => bail!("received 404 not found response code"),
code => bail!(
let body = match String::from_utf8(body) {
Ok(body) => body,
Err(..) => bail!("response body was not valid utf-8"),
};
let errors = serde_json::from_str::<ApiErrorList>(&body).ok().map(|s| {
s.errors.into_iter().map(|s| s.detail).collect::<Vec<_>>()
});

match (handle.response_code()?, errors) {
(0, None) | (200, None) => {},
(code, Some(errors)) => {
let code = StatusCode::from_u16(code as _)?;
bail!("api errors (status {}): {}", code, errors.join(", "))
}
(code, None) => bail!(
"failed to get a 200 OK response, got {}\n\
headers:\n\
\t{}\n\
body:\n\
{}",
code,
headers.join("\n\t"),
String::from_utf8_lossy(&body)
code,
headers.join("\n\t"),
body,
),
}

let body = match String::from_utf8(body) {
Ok(body) => body,
Err(..) => bail!("response body was not valid utf-8"),
};
if let Ok(errors) = serde_json::from_str::<ApiErrorList>(&body) {
let errors = errors.errors.into_iter().map(|s| s.detail);
bail!("api errors: {}", errors.collect::<Vec<_>>().join(", "));
}
Ok(body)
}
2 changes: 0 additions & 2 deletions tests/testsuite/death.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,6 @@ fn ctrl_c_kills_everyone() {

#[cfg(unix)]
fn ctrl_c(child: &mut Child) {
use libc;

let r = unsafe { libc::kill(-(child.id() as i32), libc::SIGINT) };
if r < 0 {
panic!("failed to kill: {}", io::Error::last_os_error());
Expand Down