Skip to content

Commit 29baebc

Browse files
committed
Update cargo to 0.34
1 parent 5894a47 commit 29baebc

File tree

4 files changed

+40
-21
lines changed

4 files changed

+40
-21
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ name = "rust-semverver"
2525
path = "src/bin/rust_semverver.rs"
2626

2727
[dependencies]
28-
cargo = "0.32"
28+
cargo = { git = "https://github.com/gnzlbg/cargo", branch = "revert_6193" }
29+
failure = "0.1"
2930
crates-io = "0.20"
3031
env_logger = "0.6"
3132
log = "0.4"

src/bin/cargo_semver.rs

+35-17
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@
44
extern crate cargo;
55
extern crate crates_io;
66
extern crate env_logger;
7+
extern crate failure;
78
extern crate getopts;
89
#[macro_use]
910
extern crate log;
1011

1112
use cargo::{
12-
core::{compiler::CompileMode, Package, PackageId, Source, SourceId, Workspace},
13+
core::{
14+
compiler::CompileMode, Package, PackageId, PackageSet, Source, SourceId, SourceMap,
15+
Workspace,
16+
},
1317
exit_with_error,
1418
ops::{compile, CompileOptions},
15-
util::{
16-
config::Config, important_paths::find_root_manifest_for_wd, CargoError, CargoResult,
17-
CliError,
18-
},
19+
util::{config::Config, important_paths::find_root_manifest_for_wd, CargoResult, CliError},
1920
};
2021
use crates_io::{Crate, Registry};
2122
use getopts::{Matches, Options};
@@ -123,17 +124,36 @@ impl<'a> WorkInfo<'a> {
123124
/// version.
124125
fn remote(
125126
config: &'a Config,
126-
source: &mut SourceInfo<'a>,
127+
source: SourceInfo<'a>,
127128
info: &NameAndVersion,
128129
) -> CargoResult<WorkInfo<'a>> {
129130
// TODO: fall back to locally cached package instance, or better yet, search for it
130131
// first.
131-
let package_id = PackageId::new(info.name, info.version, &source.id)?;
132-
debug!("(remote) package id: {:?}", package_id);
133-
let package = source.source.download(&package_id)?;
132+
let package_ids = [PackageId::new(info.name, info.version, source.id)?];
133+
debug!("(remote) package id: {:?}", package_ids[0]);
134+
let sources = {
135+
let mut s = SourceMap::new();
136+
s.insert(source.source);
137+
s
138+
};
139+
140+
let package_set = PackageSet::new(&package_ids, sources, config)?;
141+
let mut downloads = package_set.enable_download()?;
142+
let package = if let Some(package) = downloads.start(package_ids[0])? {
143+
package
144+
} else {
145+
downloads.wait()?;
146+
downloads
147+
.start(package_ids[0])?
148+
.expect("started download did not finish after wait")
149+
};
150+
134151
let workspace = Workspace::ephemeral(package.clone(), config, None, false)?;
135152

136-
Ok(Self { package, workspace })
153+
Ok(Self {
154+
package: package.clone(),
155+
workspace,
156+
})
137157
}
138158

139159
/// Obtain the paths to the produced rlib and the dependency output directory.
@@ -155,7 +175,7 @@ impl<'a> WorkInfo<'a> {
155175

156176
env::remove_var("RUSTFLAGS");
157177

158-
let rlib = compilation.libraries[self.package.package_id()]
178+
let rlib = compilation.libraries[&self.package.package_id()]
159179
.iter()
160180
.find(|t| t.0.name() == name)
161181
.ok_or_else(|| Error("lost a build artifact".to_owned()))?;
@@ -192,10 +212,8 @@ fn do_main(config: &Config, matches: &Matches, explain: bool) -> CargoResult<()>
192212

193213
debug!("running cargo-semver");
194214

195-
let mut source = SourceInfo::new(config)?;
196-
197215
let current = if let Some(opt) = matches.opt_str("C") {
198-
WorkInfo::remote(config, &mut source, &parse_arg(&opt)?)?
216+
WorkInfo::remote(config, SourceInfo::new(config)?, &parse_arg(&opt)?)?
199217
} else {
200218
WorkInfo::local(config, matches.opt_str("c").map(PathBuf::from))?
201219
};
@@ -206,7 +224,7 @@ fn do_main(config: &Config, matches: &Matches, explain: bool) -> CargoResult<()>
206224
let info = parse_arg(&opt)?;
207225
let version = info.version.to_owned();
208226

209-
let work_info = WorkInfo::remote(config, &mut source, &info)?;
227+
let work_info = WorkInfo::remote(config, SourceInfo::new(config)?, &info)?;
210228

211229
(work_info, version)
212230
} else if let Some(path) = matches.opt_str("s") {
@@ -219,7 +237,7 @@ fn do_main(config: &Config, matches: &Matches, explain: bool) -> CargoResult<()>
219237
name: &name,
220238
version: &stable_crate.max_version,
221239
};
222-
let work_info = WorkInfo::remote(config, &mut source, &info)?;
240+
let work_info = WorkInfo::remote(config, SourceInfo::new(config)?, &info)?;
223241

224242
(work_info, stable_crate.max_version.clone())
225243
};
@@ -305,7 +323,7 @@ fn version() {
305323
///
306324
/// Parse CLI arguments, handle their semantics, and provide for proper error handling.
307325
fn main() {
308-
fn err(config: &Config, e: CargoError) -> ! {
326+
fn err(config: &Config, e: failure::Error) -> ! {
309327
exit_with_error(CliError::new(e, 1), &mut config.shell());
310328
}
311329

src/semcheck/translate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl<'a, 'gcx, 'tcx> TranslationContext<'a, 'gcx, 'tcx> {
479479
self.translate_predicates(orig_def_id, param_env.caller_bounds)
480480
.map(|target_preds| ParamEnv {
481481
caller_bounds: self.tcx.intern_predicates(&target_preds),
482-
reveal: param_env.reveal,
482+
..param_env
483483
})
484484
}
485485

src/semcheck/traverse.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -386,11 +386,11 @@ fn diff_adts(changes: &mut ChangeSet, id_mapping: &mut IdMapping, tcx: TyCtxt, o
386386
let mut fields = BTreeMap::new();
387387

388388
for variant in &old_def.variants {
389-
variants.entry(variant.name).or_insert((None, None)).0 = Some(variant);
389+
variants.entry(variant.ident.name).or_insert((None, None)).0 = Some(variant);
390390
}
391391

392392
for variant in &new_def.variants {
393-
variants.entry(variant.name).or_insert((None, None)).1 = Some(variant);
393+
variants.entry(variant.ident.name).or_insert((None, None)).1 = Some(variant);
394394
}
395395

396396
for items in variants.values() {

0 commit comments

Comments
 (0)