Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit bd2c747

Browse files
authored
Merge pull request #110 from orium/fix-compilation
Fix compilation for the latest nightly
2 parents cad2a60 + f44f873 commit bd2c747

File tree

14 files changed

+108
-119
lines changed

14 files changed

+108
-119
lines changed

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ name = "rust-semver-public"
2727
path = "src/bin/rust_semver_public.rs"
2828

2929
[dependencies]
30-
cargo = "0.37"
31-
crates-io = "0.24"
30+
cargo = "0.39"
31+
crates-io = "0.27"
3232
curl = "0.4.21"
33-
env_logger = "0.6"
33+
env_logger = "0.7"
3434
failure = "0.1"
3535
log = "0.4"
36-
rand = "0.6"
36+
rand = "0.7"
3737
semver = "0.9"
3838
serde = "1.0.84"
3939
serde_derive = "1.0.84"
4040
serde_json = "1.0.34"
4141

4242
[dev-dependencies]
43-
quickcheck = "0.7"
43+
quickcheck = "0.9"

ci/run.sh

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,25 @@ cp target/debug/cargo-semver ~/rust/cargo/bin
3131
cp target/debug/rust-semverver ~/rust/cargo/bin
3232

3333
# become semververver
34-
PATH=~/rust/cargo/bin:$PATH cargo semver | tee semver_out
35-
current_version="$(grep -e '^version = .*$' Cargo.toml | cut -d ' ' -f 3)"
36-
current_version="${current_version%\"}"
37-
current_version="${current_version#\"}"
38-
result="$(head -n 1 semver_out)"
39-
if echo "$result" | grep -- "-> $current_version"; then
40-
echo "version ok"
41-
exit 0
34+
#
35+
# Note: Because we rely on rust nightly building the previously published
36+
# semver can often fail. To avoid failing the build we first check
37+
# if we can compile the previously published version.
38+
if cargo install --root "$(mktemp -d)" semverver > /dev/null 2>/dev/null; then
39+
PATH=~/rust/cargo/bin:$PATH cargo semver | tee semver_out
40+
current_version="$(grep -e '^version = .*$' Cargo.toml | cut -d ' ' -f 3)"
41+
current_version="${current_version%\"}"
42+
current_version="${current_version#\"}"
43+
result="$(head -n 1 semver_out)"
44+
if echo "$result" | grep -- "-> $current_version"; then
45+
echo "version ok"
46+
exit 0
47+
else
48+
echo "versioning mismatch"
49+
cat semver_out
50+
echo "versioning mismatch"
51+
exit 1
52+
fi
4253
else
43-
echo "versioning mismatch"
44-
cat semver_out
45-
echo "versioning mismatch"
46-
exit 1
54+
echo 'Failed to check semver-compliance of semverver. Failed to compiled previous version.' >&2
4755
fi

src/bin/cargo_semver.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![feature(rustc_private)]
22
#![feature(set_stdio)]
3+
#![allow(clippy::too_many_lines)]
34

45
extern crate curl;
56
extern crate getopts;
@@ -54,7 +55,7 @@ fn main() {
5455

5556
let matches = match cli::parse_args(&opts) {
5657
Ok(m) => m,
57-
Err(f) => cli::exit_with_error(&config, f.to_owned().into()),
58+
Err(f) => cli::exit_with_error(&config, f.into()),
5859
};
5960

6061
if matches.opt_present("h") {

src/bin/rust_semver_public.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ extern crate rustc_interface;
77
extern crate syntax;
88

99
use log::debug;
10-
use rustc::middle::cstore::ExternCrate;
1110
use rustc_driver::{Callbacks, Compilation};
1211
use rustc_interface::interface;
1312
use semverver::run_traversal;
@@ -48,9 +47,7 @@ fn main() {
4847
let def_id = crate_num.as_def_id();
4948

5049
match tcx.extern_crate(def_id) {
51-
Some(ExternCrate {
52-
span, direct: true, ..
53-
}) if span.data().lo.to_usize() > 0 => Some(def_id),
50+
Some(extern_crate) if extern_crate.is_direct() && extern_crate.span.data().lo.to_usize() > 0 => Some(def_id),
5451
_ => None,
5552
}
5653
})
@@ -110,10 +107,9 @@ fn main() {
110107
// `clippy_driver` directly
111108
// without having to pass --sysroot or anything
112109
let args: Vec<String> = if orig_args.iter().any(|s| s == "--sysroot") {
113-
orig_args.clone()
110+
orig_args
114111
} else {
115112
orig_args
116-
.clone()
117113
.into_iter()
118114
.chain(Some("--sysroot".to_owned()))
119115
.chain(Some(sys_root))

src/bin/rust_semverver.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ extern crate rustc_metadata;
1010
extern crate syntax;
1111

1212
use log::debug;
13-
use rustc::middle::cstore::ExternCrate;
1413
use rustc_driver::{Callbacks, Compilation};
1514
use rustc_interface::interface;
1615
use semverver::run_analysis;
@@ -69,10 +68,8 @@ fn main() {
6968
let def_id = crate_num.as_def_id();
7069

7170
match tcx.extern_crate(def_id) {
72-
Some(ExternCrate {
73-
span, direct: true, ..
74-
}) if span.data().lo.to_usize() > 0 =>
75-
Some((span.data().lo.to_usize(), def_id)),
71+
Some(extern_crate) if extern_crate.is_direct() && extern_crate.span.data().lo.to_usize() > 0 =>
72+
Some((extern_crate.span.data().lo.to_usize(), def_id)),
7673
_ => None,
7774
}
7875
})
@@ -139,10 +136,9 @@ fn main() {
139136
// `clippy_driver` directly
140137
// without having to pass --sysroot or anything
141138
let args: Vec<String> = if orig_args.iter().any(|s| s == "--sysroot") {
142-
orig_args.clone()
139+
orig_args
143140
} else {
144141
orig_args
145-
.clone()
146142
.into_iter()
147143
.chain(Some("--sysroot".to_owned()))
148144
.chain(Some(sys_root))

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![feature(rustc_private)]
22
#![allow(clippy::similar_names)]
33
#![allow(clippy::single_match_else)]
4+
#![allow(clippy::too_many_lines)]
45
#![deny(warnings)]
56
extern crate rustc;
67
extern crate syntax;

src/mismatch.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ impl<'a, 'tcx> MismatchRelation<'a, 'tcx> {
8787

8888
/// Ensure that the pair of given `SubstsRef`s is suitable to be related.
8989
fn check_substs(&self, a_substs: SubstsRef<'tcx>, b_substs: SubstsRef<'tcx>) -> bool {
90-
use rustc::ty::subst::UnpackedKind::*;
90+
use rustc::ty::subst::GenericArgKind::*;
9191

9292
for (a, b) in a_substs.iter().zip(b_substs) {
9393
match (a.unpack(), b.unpack()) {
@@ -142,7 +142,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
142142
self.current_new_types.insert(b);
143143

144144
debug!("tys: mismatch relation: a: {:?}, b: {:?}", a, b);
145-
let matching = match (&a.sty, &b.sty) {
145+
let matching = match (&a.kind, &b.kind) {
146146
(&TyKind::Adt(a_def, a_substs), &TyKind::Adt(b_def, b_substs)) => {
147147
if self.check_substs(a_substs, b_substs) {
148148
let _ = self.relate_item_substs(a_def.did, a_substs, b_substs)?;

src/translate.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc::{
88
infer::InferCtxt,
99
ty::{
1010
fold::{BottomUpFolder, TypeFoldable, TypeFolder},
11-
subst::{InternalSubsts, Kind, SubstsRef},
11+
subst::{GenericArg, InternalSubsts, SubstsRef},
1212
GenericParamDefKind, ParamEnv, Predicate, Region, TraitRef, Ty, TyCtxt,
1313
},
1414
};
@@ -103,7 +103,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
103103
orig_def_id: DefId,
104104
orig_substs: SubstsRef<'tcx>,
105105
) -> Option<(DefId, SubstsRef<'tcx>)> {
106-
use rustc::ty::subst::UnpackedKind;
106+
use rustc::ty::subst::GenericArgKind;
107107
use rustc::ty::ReEarlyBound;
108108
use std::cell::Cell;
109109

@@ -119,10 +119,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
119119

120120
let target_substs =
121121
InternalSubsts::for_item(self.tcx, target_def_id, |def, _| match def.kind {
122-
GenericParamDefKind::Lifetime => Kind::from(if !success.get() {
122+
GenericParamDefKind::Lifetime => GenericArg::from(if !success.get() {
123123
self.tcx
124124
.mk_region(ReEarlyBound(def.to_early_bound_region_data()))
125-
} else if let Some(UnpackedKind::Lifetime(region)) =
125+
} else if let Some(GenericArgKind::Lifetime(region)) =
126126
orig_substs.get(def.index as usize).map(|k| k.unpack())
127127
{
128128
self.translate_region(region)
@@ -134,15 +134,15 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
134134
GenericParamDefKind::Type { .. } => {
135135
if !success.get() {
136136
self.tcx.mk_param_from_def(def)
137-
} else if let Some(UnpackedKind::Type(type_)) =
137+
} else if let Some(GenericArgKind::Type(type_)) =
138138
orig_substs.get(def.index as usize).map(|k| k.unpack())
139139
{
140-
self.translate(index_map, &Kind::from(type_))
140+
self.translate(index_map, &GenericArg::from(type_))
141141
} else if self
142142
.id_mapping
143143
.is_non_mapped_defaulted_type_param(def.def_id)
144144
{
145-
Kind::from(self.tcx.type_of(def.def_id))
145+
GenericArg::from(self.tcx.type_of(def.def_id))
146146
} else if self.tcx.generics_of(target_def_id).has_self && def.index == 0 {
147147
self.tcx.mk_param_from_def(def)
148148
} else {
@@ -171,7 +171,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
171171
orig.fold_with(&mut BottomUpFolder {
172172
tcx: self.tcx,
173173
ty_op: |ty| {
174-
match ty.sty {
174+
match ty.kind {
175175
TyKind::Adt(&AdtDef { ref did, .. }, substs)
176176
if self.needs_translation(*did) =>
177177
{
@@ -293,14 +293,14 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
293293
// `Self` is special
294294
let orig_def_id = index_map[&param.index];
295295
if self.needs_translation(orig_def_id) {
296-
use rustc::ty::subst::UnpackedKind;
296+
use rustc::ty::subst::GenericArgKind;
297297

298298
let target_def_id = self.translate_orig(orig_def_id);
299299
debug!("translating type param: {:?}", param);
300300
let type_param = self.id_mapping.get_type_param(&target_def_id);
301301
debug!("translated type param: {:?}", type_param);
302302
match self.tcx.mk_param_from_def(&type_param).unpack() {
303-
UnpackedKind::Type(param_t) => param_t,
303+
GenericArgKind::Type(param_t) => param_t,
304304
_ => unreachable!(),
305305
}
306306
} else {
@@ -542,7 +542,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for InferenceCleanupFolder<'a, 'tcx> {
542542
use rustc::ty::TypeAndMut;
543543

544544
let t1 = ty.super_fold_with(self);
545-
match t1.sty {
545+
match t1.kind {
546546
TyKind::Ref(region, ty, mutbl) if region.needs_infer() => {
547547
let ty_and_mut = TypeAndMut { ty, mutbl };
548548
self.infcx

src/traverse.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ fn diff_traits<'tcx>(
560560
output: bool,
561561
) {
562562
use rustc::hir::Unsafety::Unsafe;
563-
use rustc::ty::subst::UnpackedKind::Type;
563+
use rustc::ty::subst::GenericArgKind::Type;
564564
use rustc::ty::{ParamTy, Predicate, TyS};
565565

566566
debug!(
@@ -590,7 +590,7 @@ fn diff_traits<'tcx>(
590590

591591
if id_mapping.is_private_trait(trait_ref.def_id) && trait_ref.substs.len() == 1 {
592592
if let Type(&TyS {
593-
sty: TyKind::Param(ParamTy { index: 0, .. }),
593+
kind: TyKind::Param(ParamTy { index: 0, .. }),
594594
..
595595
}) = trait_ref.substs[0].unpack()
596596
{
@@ -1087,7 +1087,7 @@ fn diff_inherent_impls<'tcx>(
10871087
#[allow(clippy::match_same_arms)]
10881088
fn is_impl_trait_public<'tcx>(tcx: TyCtxt<'tcx>, impl_def_id: DefId) -> bool {
10891089
fn type_visibility(tcx: TyCtxt, ty: Ty) -> Visibility {
1090-
match ty.sty {
1090+
match ty.kind {
10911091
TyKind::Adt(def, _) => tcx.visibility(def.did),
10921092

10931093
TyKind::Array(t, _)

src/typeck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc::{
1616
ty::{
1717
error::TypeError,
1818
fold::TypeFoldable,
19-
subst::{InternalSubsts, Kind, SubstsRef},
19+
subst::{GenericArg, InternalSubsts, SubstsRef},
2020
GenericParamDefKind, ParamEnv, Predicate, TraitRef, Ty, TyCtxt,
2121
},
2222
};
@@ -181,7 +181,7 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
181181
use rustc::ty::ReEarlyBound;
182182

183183
InternalSubsts::for_item(self.infcx.tcx, target_def_id, |def, _| match def.kind {
184-
GenericParamDefKind::Lifetime => Kind::from(
184+
GenericParamDefKind::Lifetime => GenericArg::from(
185185
self.infcx
186186
.tcx
187187
.mk_region(ReEarlyBound(def.to_early_bound_region_data())),
@@ -191,7 +191,7 @@ impl<'a, 'tcx> TypeComparisonContext<'a, 'tcx> {
191191
.id_mapping
192192
.is_non_mapped_defaulted_type_param(def.def_id)
193193
{
194-
Kind::from(self.infcx.tcx.type_of(def.def_id))
194+
GenericArg::from(self.infcx.tcx.type_of(def.def_id))
195195
} else {
196196
self.infcx.tcx.mk_param_from_def(def)
197197
}

0 commit comments

Comments
 (0)