Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into warn-no-git-repo
Browse files Browse the repository at this point in the history
  • Loading branch information
dekellum committed Jul 28, 2018
2 parents 8781de1 + db48c63 commit ad0b252
Show file tree
Hide file tree
Showing 83 changed files with 1,395 additions and 8,348 deletions.
13 changes: 13 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ matrix:
ALT=i686-unknown-linux-gnu
rust: beta

# 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.27.2
script:
- rustup toolchain install nightly
- cargo +nightly generate-lockfile -Z minimal-versions
- cargo -V
- cargo check --tests

- env: TARGET=x86_64-unknown-linux-gnu
ALT=i686-unknown-linux-gnu
rust: nightly
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,26 @@ path = "src/cargo/lib.rs"
[dependencies]
atty = "0.2"
crates-io = { path = "src/crates-io", version = "0.18" }
crossbeam = "0.3"
crossbeam-utils = "0.5"
crypto-hash = "0.3.1"
curl = "0.4.12"
curl = "0.4.13"
env_logger = "0.5.4"
failure = "0.1.1"
filetime = "0.2"
flate2 = "1.0"
fs2 = "0.4"
git2 = "0.7.0"
git2 = "0.7.3"
git2-curl = "0.8.1"
glob = "0.2.11"
hex = "0.3"
home = "0.3"
ignore = "0.4"
lazy_static = "1.0.0"
jobserver = "0.1.9"
jobserver = "0.1.11"
lazycell = "1.0"
libc = "0.2"
libgit2-sys = "0.7.1"
log = "0.4"
libgit2-sys = "0.7.5"
num_cpus = "1.0"
rustfix = "0.4"
same-file = "1"
Expand All @@ -64,7 +64,7 @@ num-traits = "0.2" # enable the default feature
core-foundation = { version = "0.6.0", features = ["mac_os_10_7_support"] }

[target.'cfg(windows)'.dependencies]
miow = "0.3"
miow = "0.3.1"

[target.'cfg(windows)'.dependencies.winapi]
version = "0.3"
Expand Down
8 changes: 7 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,16 @@ environment:
- TARGET: x86_64-pc-windows-msvc
OTHER_TARGET: i686-pc-windows-msvc
MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc
OTHER_TARGET: i686-pc-windows-msvc
MAKE_TARGETS: test-unit-x86_64-pc-windows-msvc
MINIMAL_VERSIONS: true

install:
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- if defined MINIMAL_VERSIONS rustup toolchain install stable
- rustup target add %OTHER_TARGET%
- rustc -V
- cargo -V
Expand All @@ -18,4 +23,5 @@ clone_depth: 1
build: false

test_script:
- cargo test
- if defined MINIMAL_VERSIONS cargo +nightly generate-lockfile -Z minimal-versions && cargo +stable check --tests
- if NOT defined MINIMAL_VERSIONS cargo test
19 changes: 12 additions & 7 deletions src/bin/cargo/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,19 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
if args.is_present("list") {
println!("Installed Commands:");
for command in list_commands(config) {
let (command, path) = command;
if is_verbose {
match path {
Some(p) => println!(" {:<20} {}", command, p),
None => println!(" {:<20}", command),
match command {
CommandInfo::BuiltIn { name, about } => {
let summary = about.unwrap_or_default();
let summary = summary.lines().next().unwrap_or(&summary); // display only the first line
println!(" {:<20} {}", name, summary)
}
CommandInfo::External { name, path } => {
if is_verbose {
println!(" {:<20} {}", name, path.display())
} else {
println!(" {}", name)
}
}
} else {
println!(" {}", command);
}
}
return Ok(());
Expand Down
15 changes: 15 additions & 0 deletions src/bin/cargo/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,18 @@ pub fn values(args: &ArgMatches, name: &str) -> Vec<String> {
.map(|s| s.to_string())
.collect()
}

#[derive(PartialEq, PartialOrd, Eq, Ord)]
pub enum CommandInfo {
BuiltIn { name: String, about: Option<String>, },
External { name: String, path: PathBuf },
}

impl CommandInfo {
pub fn name(&self) -> String {
match self {
CommandInfo::BuiltIn { name, .. } => name.to_string(),
CommandInfo::External { name, .. } => name.to_string(),
}
}
}
7 changes: 5 additions & 2 deletions src/bin/cargo/commands/read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ use cargo::print_json;
pub fn cli() -> App {
subcommand("read-manifest")
.about(
"Deprecated, use `cargo metadata --no-deps` instead.
Print a JSON representation of a Cargo.toml manifest.",
"\
Print a JSON representation of a Cargo.toml manifest.
Deprecated, use `cargo metadata --no-deps` instead.\
",
)
.arg_manifest_path()
}
Expand Down
20 changes: 13 additions & 7 deletions src/bin/cargo/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ mod cli;
mod command_prelude;
mod commands;

use command_prelude::*;

fn main() {
env_logger::init();
cargo::core::maybe_allow_nightly_features();
Expand Down Expand Up @@ -81,7 +83,7 @@ fn aliased_command(config: &Config, command: &str) -> CargoResult<Option<Vec<Str
}

/// List all runnable commands
fn list_commands(config: &Config) -> BTreeSet<(String, Option<String>)> {
fn list_commands(config: &Config) -> BTreeSet<CommandInfo> {
let prefix = "cargo-";
let suffix = env::consts::EXE_SUFFIX;
let mut commands = BTreeSet::new();
Expand All @@ -101,16 +103,19 @@ fn list_commands(config: &Config) -> BTreeSet<(String, Option<String>)> {
}
if is_executable(entry.path()) {
let end = filename.len() - suffix.len();
commands.insert((
filename[prefix.len()..end].to_string(),
Some(path.display().to_string()),
));
commands.insert(CommandInfo::External {
name: filename[prefix.len()..end].to_string(),
path: path.clone(),
});
}
}
}

for cmd in commands::builtin() {
commands.insert((cmd.get_name().to_string(), None));
commands.insert(CommandInfo::BuiltIn {
name: cmd.get_name().to_string(),
about: cmd.p.meta.about.map(|s| s.to_string()),
});
}

commands
Expand All @@ -121,7 +126,8 @@ fn find_closest(config: &Config, cmd: &str) -> Option<String> {
// Only consider candidates with a lev_distance of 3 or less so we don't
// suggest out-of-the-blue options.
cmds.into_iter()
.map(|(c, _)| (lev_distance(&c, cmd), c))
.map(|c| c.name())
.map(|c| (lev_distance(&c, cmd), c))
.filter(|&(d, _)| d < 4)
.min_by_key(|a| a.0)
.map(|slot| slot.1)
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/compilation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct Doctest {
pub target: Target,
/// Extern dependencies needed by `rustdoc`. The path is the location of
/// the compiled lib.
pub deps: Vec<(Target, PathBuf)>,
pub deps: Vec<(String, PathBuf)>,
}

/// A structure returning the result of a compilation.
Expand Down
19 changes: 10 additions & 9 deletions src/cargo/core/compiler/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,16 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
for dep in self.dep_targets(unit) {
if dep.target.is_lib() && dep.mode == CompileMode::Build {
let outputs = self.outputs(&dep)?;
doctest_deps.extend(
outputs
.iter()
.filter(|output| {
output.path.extension() == Some(OsStr::new("rlib"))
|| dep.target.for_host()
})
.map(|output| (dep.target.clone(), output.path.clone())),
);
let outputs = outputs.iter().filter(|output| {
output.path.extension() == Some(OsStr::new("rlib"))
|| dep.target.for_host()
});
for output in outputs {
doctest_deps.push((
self.bcx.extern_crate_name(unit, &dep)?,
output.path.clone(),
));
}
}
}
self.compilation.to_doc_test.push(compilation::Doctest {
Expand Down
5 changes: 3 additions & 2 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use std::mem;
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::Arc;

use crossbeam::{self, Scope};
use crossbeam_utils;
use crossbeam_utils::thread::Scope;
use jobserver::{Acquired, HelperThread};

use core::profiles::Profile;
Expand Down Expand Up @@ -165,7 +166,7 @@ impl<'a> JobQueue<'a> {
srv.start(move |msg| drop(tx2.send(Message::FixDiagnostic(msg))))
});

crossbeam::scope(|scope| self.drain_the_queue(cx, plan, scope, &helper))
crossbeam_utils::thread::scope(|scope| self.drain_the_queue(cx, plan, scope, &helper))
}

fn drain_the_queue(
Expand Down
7 changes: 5 additions & 2 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,12 @@ impl Target {
pub fn benched(&self) -> bool {
self.benched
}

pub fn doctested(&self) -> bool {
self.doctest && match self.kind {
self.doctest
}

pub fn doctestable(&self) -> bool {
match self.kind {
TargetKind::Lib(ref kinds) => kinds
.iter()
.any(|k| *k == LibKind::Rlib || *k == LibKind::Lib || *k == LibKind::ProcMacro),
Expand Down
10 changes: 10 additions & 0 deletions src/cargo/core/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ pub trait Source {
/// Returns the `SourceId` corresponding to this source
fn source_id(&self) -> &SourceId;

/// Returns the replaced `SourceId` corresponding to this source
fn replaced_source_id(&self) -> &SourceId {
self.source_id()
}

/// Returns whether or not this source will return summaries with
/// checksums listed.
fn supports_checksums(&self) -> bool;
Expand Down Expand Up @@ -95,6 +100,11 @@ impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
(**self).source_id()
}

/// Forwards to `Source::replaced_source_id`
fn replaced_source_id(&self) -> &SourceId {
(**self).replaced_source_id()
}

/// Forwards to `Source::update`
fn update(&mut self) -> CargoResult<()> {
(**self).update()
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extern crate clap;
#[cfg(target_os = "macos")]
extern crate core_foundation;
extern crate crates_io as registry;
extern crate crossbeam;
extern crate crossbeam_utils;
extern crate curl;
#[macro_use]
extern crate failure;
Expand Down
15 changes: 13 additions & 2 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,11 @@ fn generate_targets<'a>(
proposals.extend(default_units);
if build_config.mode == CompileMode::Test {
// Include doctest for lib.
if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) {
if let Some(t) = pkg
.targets()
.iter()
.find(|t| t.is_lib() && t.doctested() && t.doctestable())
{
proposals.push((new_unit(pkg, t, CompileMode::Doctest), false));
}
}
Expand All @@ -560,9 +564,16 @@ fn generate_targets<'a>(
} => {
if lib {
if let Some(target) = pkg.targets().iter().find(|t| t.is_lib()) {
if build_config.mode == CompileMode::Doctest && !target.doctestable() {
bail!(
"doc tests are not supported for crate type(s) `{}` in package `{}`",
target.rustc_crate_types().join(", "),
pkg.name()
);
}
proposals.push((new_unit(pkg, target, build_config.mode), false));
} else if !all_targets {
bail!("no library targets found")
bail!("no library targets found in package `{}`", pkg.name())
}
}
// If --tests was specified, add all targets that would be
Expand Down
6 changes: 1 addition & 5 deletions src/cargo/ops/cargo_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use git2::Config as GitConfig;
use git2::Repository as GitRepository;

use core::{compiler, Workspace};
use util::{internal, FossilRepo, GitRepo, HgRepo, PijulRepo};
use util::{internal, FossilRepo, GitRepo, HgRepo, PijulRepo, existing_vcs_repo};
use util::{paths, Config};
use util::errors::{CargoResult, CargoResultExt};

Expand Down Expand Up @@ -409,10 +409,6 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
Ok(())
}

pub fn existing_vcs_repo(path: &Path, cwd: &Path) -> bool {
GitRepo::discover(path, cwd).is_ok() || HgRepo::discover(path, cwd).is_ok()
}

fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
let path = opts.path;
let name = opts.name;
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ fn run_doc_tests(
}
}

for &(ref target, ref lib) in deps.iter() {
let mut arg = OsString::from(target.crate_name());
for &(ref extern_crate_name, ref lib) in deps.iter() {
let mut arg = OsString::from(extern_crate_name);
arg.push("=");
arg.push(lib);
p.arg("--extern").arg(&arg);
Expand Down
3 changes: 1 addition & 2 deletions src/cargo/ops/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use serde_json;

use core::Workspace;
use ops::{self, CompileOptions};
use ops::cargo_new::existing_vcs_repo;
use util::errors::CargoResult;
use util::{LockServer, LockServerClient};
use util::{LockServer, LockServerClient, existing_vcs_repo};
use util::diagnostic_server::{Message, RustfixDiagnosticServer};
use util::paths;

Expand Down
Loading

0 comments on commit ad0b252

Please sign in to comment.