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

Commit

Permalink
Auto merge of #227 - JohnTitor:rustups-2021-10, r=JohnTitor
Browse files Browse the repository at this point in the history
Some rustups
  • Loading branch information
bors committed Oct 19, 2021
2 parents 978dae7 + 88e114b commit c4626b5
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 136 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ repository and compiled from source or installed from
of the nightly toolchain is supported at any given time.

<!-- NOTE: Keep in sync with nightly date on rust-toolchain. -->
It's recommended to use `nightly-2021-07-23` toolchain.
You can install it by using `rustup install nightly-2021-07-23` if you already have rustup.
It's recommended to use `nightly-2021-09-30` toolchain.
You can install it by using `rustup install nightly-2021-09-30` if you already have rustup.
Then you can do:

```sh
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-07-23
$ cargo +nightly-2021-07-23 install --git https://github.com/rust-lang/rust-semverver
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-30
$ cargo +nightly-2021-09-30 install --git https://github.com/rust-lang/rust-semverver
```

You'd also need `cmake` for some dependencies, and a few common libraries (if you hit
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Keep in sync with nightly date on README
[toolchain]
channel = "nightly-2021-07-23"
channel = "nightly-2021-09-30"
components = ["llvm-tools-preview", "rustc-dev"]
24 changes: 12 additions & 12 deletions src/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ pub mod tests {
use std::cmp::{max, min};

use rustc_span::hygiene::SyntaxContext;
use rustc_span::symbol::Interner;
use rustc_span::symbol::sym;
use rustc_span::BytePos;

/// A wrapper for `Span` that can be randomly generated.
Expand All @@ -1248,7 +1248,12 @@ pub mod tests {

impl Span_ {
pub fn inner(self) -> Span {
Span::new(BytePos(self.0), BytePos(self.1), SyntaxContext::root())
Span::new(
BytePos(self.0),
BytePos(self.1),
SyntaxContext::root(),
None,
)
}
}

Expand Down Expand Up @@ -1469,8 +1474,7 @@ pub mod tests {
output: bool,
changes: Vec<(ChangeType_, Option<Span_>)>,
) -> Change<'a> {
let mut interner = Interner::default();
let mut change = Change::new(Name::Symbol(RSymbol(interner.intern("test"))), s1, output);
let mut change = Change::new(Name::Symbol(RSymbol(sym::test)), s1, output);

for (type_, span) in changes {
change.insert(type_.inner(), span.map(|s| s.inner()));
Expand All @@ -1484,8 +1488,7 @@ pub mod tests {

/// Construct `PathChange`s from things that can be generated.
fn build_path_change(s1: Span, spans: Vec<(bool, Span)>) -> PathChange {
let mut interner = Interner::default();
let mut change = PathChange::new(interner.intern("test"), s1);
let mut change = PathChange::new(sym::test, s1);

for (add, span) in spans {
change.insert(span, add);
Expand Down Expand Up @@ -1555,8 +1558,7 @@ pub mod tests {
rustc_span::create_default_session_globals_then(|| {
let mut set = ChangeSet::default();

let mut interner = Interner::default();
let name = interner.intern("test");
let name = sym::test;

let max = changes
.iter()
Expand Down Expand Up @@ -1588,8 +1590,7 @@ pub mod tests {
rustc_span::create_default_session_globals_then(|| {
let mut set = ChangeSet::default();

let mut interner = Interner::default();
let name = interner.intern("test");
let name = sym::test;

let max = changes
.iter()
Expand Down Expand Up @@ -1623,8 +1624,7 @@ pub mod tests {
rustc_span::create_default_session_globals_then(|| {
let mut set = ChangeSet::default();

let mut interner = Interner::default();
let name = interner.intern("test");
let name = sym::test;

let max = pchanges
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#![allow(clippy::unnested_or_patterns)]
#![deny(warnings)]

extern crate rustc_hir; // Requires `rustup component add rustc-dev`
extern crate rustc_const_eval; // Requires `rustup component add rustc-dev`
extern crate rustc_hir;
extern crate rustc_infer;
extern crate rustc_middle;
extern crate rustc_mir;
extern crate rustc_session;
extern crate rustc_span;
extern crate rustc_trait_selection;
Expand Down
12 changes: 5 additions & 7 deletions src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ impl IdMapping {
}

/// An export that could be missing from one of the crate versions.
type OptionalExport = Option<Export<HirId>>;
type OptionalExport = Option<Export>;

/// A mapping from names to pairs of old and new exports.
///
Expand All @@ -343,11 +343,11 @@ pub struct NameMapping {

impl NameMapping {
/// Insert a single export in the appropriate map, at the appropriate position.
fn insert(&mut self, item: Export<HirId>, old: bool) {
fn insert(&mut self, item: Export, old: bool) {
use rustc_hir::def::DefKind::*;
use rustc_hir::def::Res::*;

let map = match item.res {
let map = match item.res.expect_non_local::<HirId>() {
Def(kind, _) => match kind {
Mod |
Struct |
Expand Down Expand Up @@ -396,7 +396,7 @@ impl NameMapping {
}

/// Add all items from two vectors of old/new exports.
pub fn add(&mut self, old_items: Vec<Export<HirId>>, new_items: Vec<Export<HirId>>) {
pub fn add(&mut self, old_items: Vec<Export>, new_items: Vec<Export>) {
for item in old_items {
self.insert(item, true);
}
Expand All @@ -407,9 +407,7 @@ impl NameMapping {
}

/// Drain the item pairs being stored.
pub fn drain(
&mut self,
) -> impl Iterator<Item = (Option<Export<HirId>>, Option<Export<HirId>>)> + '_ {
pub fn drain(&mut self) -> impl Iterator<Item = (Option<Export>, Option<Export>)> + '_ {
self.type_map
.drain()
.chain(self.value_map.drain())
Expand Down
174 changes: 88 additions & 86 deletions src/translate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
use rustc_middle::ty::{
fold::{BottomUpFolder, TypeFoldable, TypeFolder},
subst::{GenericArg, InternalSubsts, SubstsRef},
GenericParamDefKind, ParamEnv, Predicate, Region, TraitRef, Ty, TyCtxt,
GenericParamDefKind, ParamEnv, Predicate, Region, TraitRef, Ty, TyCtxt, Unevaluated,
};
use std::collections::HashMap;

Expand Down Expand Up @@ -376,97 +376,99 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
predicate: Predicate<'tcx>,
) -> Option<Predicate<'tcx>> {
use rustc_middle::ty::{
OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy, SubtypePredicate,
ToPredicate, TraitPredicate, WithOptConstParam,
self, CoercePredicate, OutlivesPredicate, PredicateKind, ProjectionPredicate,
ProjectionTy, SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
};

Some(
match predicate.kind().skip_binder() {
PredicateKind::Trait(pred, constness) => PredicateKind::Trait(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.trait_ref.def_id,
pred.trait_ref.substs,
) {
TraitPredicate {
trait_ref: TraitRef {
def_id: target_def_id,
substs: target_substs,
},
}
} else {
return None;
},
constness,
),
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
let l = self.translate_region(pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
let l = self.translate(index_map, pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::Projection(pred) => PredicateKind::Projection(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.projection_ty.item_def_id,
pred.projection_ty.substs,
) {
ProjectionPredicate {
projection_ty: ProjectionTy {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, pred.ty),
}
} else {
return None;
},
),
PredicateKind::WellFormed(ty) => {
PredicateKind::WellFormed(self.translate(index_map, ty))
}
PredicateKind::ObjectSafe(did) => {
PredicateKind::ObjectSafe(self.translate_orig(did))
}
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
self.translate_orig(did),
self.translate(index_map, substs),
kind,
),
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
let l = self.translate(index_map, pred.a);
let r = self.translate(index_map, pred.b);
SubtypePredicate {
a_is_expected: pred.a_is_expected,
a: l,
b: r,
let pred = match predicate.kind().skip_binder() {
PredicateKind::Trait(pred) => PredicateKind::Trait(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.trait_ref.def_id,
pred.trait_ref.substs,
) {
TraitPredicate {
trait_ref: TraitRef {
def_id: target_def_id,
substs: target_substs,
},
constness: pred.constness,
}
}),
PredicateKind::ConstEvaluatable(param, orig_substs) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, param.did, orig_substs)
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
let const_param = WithOptConstParam::unknown(target_def_id);
PredicateKind::ConstEvaluatable(const_param, target_substs)
} else {
return None;
} else {
return None;
},
),
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
let l = self.translate_region(pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
let l = self.translate(index_map, pred.0);
let r = self.translate_region(pred.1);
OutlivesPredicate(l, r)
}),
PredicateKind::Projection(pred) => PredicateKind::Projection(
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
index_map,
pred.projection_ty.item_def_id,
pred.projection_ty.substs,
) {
ProjectionPredicate {
projection_ty: ProjectionTy {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, pred.ty),
}
} else {
return None;
},
),
PredicateKind::WellFormed(ty) => {
PredicateKind::WellFormed(self.translate(index_map, ty))
}
PredicateKind::ObjectSafe(did) => PredicateKind::ObjectSafe(self.translate_orig(did)),
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
self.translate_orig(did),
self.translate(index_map, substs),
kind,
),
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
let l = self.translate(index_map, pred.a);
let r = self.translate(index_map, pred.b);
SubtypePredicate {
a_is_expected: pred.a_is_expected,
a: l,
b: r,
}
}),
PredicateKind::Coerce(pred) => PredicateKind::Coerce({
let a = self.translate(index_map, pred.a);
let b = self.translate(index_map, pred.b);
CoercePredicate { a, b }
}),
PredicateKind::ConstEvaluatable(uv) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
let const_param = WithOptConstParam::unknown(target_def_id);
PredicateKind::ConstEvaluatable(Unevaluated::new(const_param, target_substs))
} else {
return None;
}
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
self.translate(index_map, c1),
self.translate(index_map, c2),
),
// NOTE: Only used for Chalk trait solver
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
}
.to_predicate(self.tcx),
)
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
self.translate(index_map, c1),
self.translate(index_map, c2),
),
// NOTE: Only used for Chalk trait solver
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
};

Some(ty::Binder::dummy(pred).to_predicate(self.tcx))
}

/// Translate a slice of predicates in the context of an item.
Expand Down
Loading

0 comments on commit c4626b5

Please sign in to comment.