Skip to content

Commit

Permalink
Auto merge of rust-lang#1475 - alexcrichton:update, r=huonw
Browse files Browse the repository at this point in the history
Along the way, this also removes the ability to specify `[[lib]]` targets while
getting warnings. While we're at it remove nearly all unstable features that
Cargo is depending on as well!

r? @huonw
  • Loading branch information
bors committed Apr 3, 2015
2 parents d7b6671 + 80fe0e6 commit d71f748
Show file tree
Hide file tree
Showing 37 changed files with 214 additions and 265 deletions.
98 changes: 54 additions & 44 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ regex = "0.1.18"
threadpool = "0.1.1"
libc = "0.1.2"
registry = { path = "src/registry" }
num_cpus = "0.1"

[target.i686-pc-windows-gnu]
dependencies = { winapi = "0.1", advapi32-sys = "0.1", kernel32-sys = "0.1" }
Expand Down
28 changes: 14 additions & 14 deletions src/bin/cargo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![feature(core, exit_status, fs_ext)]
#![cfg_attr(unix, feature(fs_ext))]

extern crate cargo;
extern crate env_logger;
Expand Down Expand Up @@ -153,18 +153,18 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
}

fn find_closest(cmd: &str) -> Option<String> {
match list_commands().iter()
// doing it this way (instead of just .min_by(|c|
// c.lev_distance(cmd))) allows us to only make
// suggestions that have an edit distance of
// 3 or less
.map(|c| (lev_distance(&c, cmd), c))
.filter(|&(d, _): &(usize, &String)| d < 4)
.min_by(|&(d, _)| d) {
Some((_, c)) => {
Some(c.to_string())
},
None => None
let cmds = list_commands();
// Only consider candidates with a lev_distance of 3 or less so we don't
// suggest out-of-the-blue options.
let mut filtered = cmds.iter().map(|c| (lev_distance(&c, cmd), c))
.filter(|&(d, _)| d < 4)
.collect::<Vec<_>>();
filtered.sort_by(|a, b| a.0.cmp(&b.0));

if filtered.len() == 0 {
None
} else {
Some(filtered[0].1.to_string())
}
}

Expand Down Expand Up @@ -245,7 +245,7 @@ fn is_executable(path: &Path) -> bool {
}
#[cfg(windows)]
fn is_executable(path: &Path) -> bool {
fs::metadata(path).map(|m| m.is_file()) == Ok(true)
fs::metadata(path).map(|m| m.is_file()).unwrap_or(false)
}

/// Get `Command` to run given command.
Expand Down
1 change: 1 addition & 0 deletions src/bin/read_manifest.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::path::Path;
use std::error::Error;

use cargo::core::{Package, Source};
use cargo::util::{CliResult, CliError, Config};
Expand Down
15 changes: 8 additions & 7 deletions src/bin/verify_project.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::process;

use toml;
use cargo::util::{CliResult, Config};
use rustc_serialize::json;
use toml;

pub type Error = HashMap<String, String>;

Expand Down Expand Up @@ -32,10 +33,10 @@ pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
let file = File::open(&args.flag_manifest_path);
match file.and_then(|mut f| f.read_to_string(&mut contents)) {
Ok(_) => {},
Err(e) => return fail("invalid", &format!("error reading file: {}", e))
Err(e) => fail("invalid", &format!("error reading file: {}", e))
};
match toml::Parser::new(&contents).parse() {
None => return fail("invalid", "invalid-format"),
None => fail("invalid", "invalid-format"),
Some(..) => {}
};

Expand All @@ -44,9 +45,9 @@ pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
Ok(Some(h))
}

fn fail(reason: &str, value: &str) -> CliResult<Option<Error>>{
fn fail(reason: &str, value: &str) -> ! {
let mut h = HashMap::new();
h.insert(reason.to_string(), value.to_string());
env::set_exit_status(1);
Ok(Some(h))
println!("{}", json::encode(&h).unwrap());
process::exit(1)
}
6 changes: 3 additions & 3 deletions src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use std::cmp::Ordering;
use std::error::{Error, FromError};
use std::error::Error;
use std::fmt::{self, Formatter};
use std::hash::Hash;
use std::hash;
Expand Down Expand Up @@ -108,8 +108,8 @@ impl CargoError for PackageIdError {
fn is_human(&self) -> bool { true }
}

impl FromError<PackageIdError> for Box<CargoError> {
fn from_error(t: PackageIdError) -> Box<CargoError> { Box::new(t) }
impl From<PackageIdError> for Box<CargoError> {
fn from(t: PackageIdError) -> Box<CargoError> { Box::new(t) }
}

#[derive(PartialEq, Eq, Hash, Clone, RustcEncodable, Debug)]
Expand Down
Loading

0 comments on commit d71f748

Please sign in to comment.