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 #288 - dario23:update-rustc, r=JohnTitor
Browse files Browse the repository at this point in the history
Update rustc to 2022-03-13
  • Loading branch information
bors committed May 7, 2022
2 parents 4139b2d + 644b3e2 commit 324a149
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 78 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-12-31` toolchain.
You can install it by using `rustup install nightly-2021-12-31` if you already have rustup.
It's recommended to use `nightly-2022-03-13` toolchain.
You can install it by using `rustup install nightly-2022-03-13` if you already have rustup.
Then you can do:

```sh
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-12-31
$ cargo +nightly-2021-12-31 install --git https://github.com/rust-lang/rust-semverver
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2022-03-13
$ cargo +nightly-2022-03-13 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-12-31"
channel = "nightly-2022-03-13"
components = ["llvm-tools-preview", "rustc-dev"]
8 changes: 6 additions & 2 deletions src/changes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ impl PathChange {

let msg = format!("path changes to `{}`", self.name.0);
let mut builder = if cat == Breaking {
session.struct_span_err(self.def_span, &msg)
session
.struct_span_err(self.def_span, &msg)
.forget_guarantee()
} else {
session.struct_span_warn(self.def_span, &msg)
};
Expand Down Expand Up @@ -903,7 +905,9 @@ impl<'tcx> Change<'tcx> {

let msg = format!("{} changes in {}", self.max, self.name);
let mut builder = if self.max == Breaking {
session.struct_span_err(self.new_span, &msg)
session
.struct_span_err(self.new_span, &msg)
.forget_guarantee()
} else {
session.struct_span_warn(self.new_span, &msg)
};
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
extern crate rustc_const_eval; // Requires `rustup component add rustc-dev`
extern crate rustc_hir;
extern crate rustc_infer;
extern crate rustc_metadata;
extern crate rustc_middle;
extern crate rustc_session;
extern crate rustc_span;
Expand Down
12 changes: 6 additions & 6 deletions src/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use rustc_hir::{
HirId,
};
use rustc_middle::{
hir::exports::Export,
metadata::ModChild,
ty::{AssocKind, GenericParamDef, GenericParamDefKind},
};
use rustc_span::symbol::Symbol;
Expand Down Expand Up @@ -325,7 +325,7 @@ impl IdMapping {
}

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

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

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

Expand Down Expand Up @@ -382,7 +382,7 @@ impl NameMapping {
Closure |
Generator => None,
},
PrimTy(_) | SelfTy(_, _) => Some(&mut self.type_map),
PrimTy(_) | SelfTy { .. } => Some(&mut self.type_map),
SelfCtor(_) | Local(_) => Some(&mut self.value_map),
_ => None,
};
Expand All @@ -397,7 +397,7 @@ impl NameMapping {
}

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

/// Drain the item pairs being stored.
pub fn drain(&mut self) -> impl Iterator<Item = (Option<Export>, Option<Export>)> + '_ {
pub fn drain(&mut self) -> impl Iterator<Item = (Option<ModChild>, Option<ModChild>)> + '_ {
self.type_map
.drain()
.chain(self.value_map.drain())
Expand Down
30 changes: 15 additions & 15 deletions src/mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
// could potentially short-circuit somewhere).
let dummy_type = self.tcx.types.unit;

if self.current_old_types.contains(a) || self.current_new_types.contains(b) {
if self.current_old_types.contains(&a) || self.current_new_types.contains(&b) {
return Ok(dummy_type);
}

Expand All @@ -151,9 +151,9 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
let matching = match (a.kind(), b.kind()) {
(&TyKind::Adt(a_def, a_substs), &TyKind::Adt(b_def, b_substs)) => {
if self.check_substs(a_substs, b_substs) {
let _ = self.relate_item_substs(a_def.did, a_substs, b_substs)?;
let a_adt = self.tcx.adt_def(a_def.did);
let b_adt = self.tcx.adt_def(b_def.did);
let _ = self.relate_item_substs(a_def.did(), a_substs, b_substs)?;
let a_adt = self.tcx.adt_def(a_def.did());
let b_adt = self.tcx.adt_def(b_def.did());

let b_fields: HashMap<_, _> = b_adt.all_fields().map(|f| (f.did, f)).collect();

Expand All @@ -172,19 +172,19 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
}

let a = if a_def.is_struct() {
Res::Def(DefKind::Struct, a_def.did)
Res::Def(DefKind::Struct, a_def.did())
} else if a_def.is_union() {
Res::Def(DefKind::Union, a_def.did)
Res::Def(DefKind::Union, a_def.did())
} else {
Res::Def(DefKind::Enum, a_def.did)
Res::Def(DefKind::Enum, a_def.did())
};

let b = if b_def.is_struct() {
Res::Def(DefKind::Struct, b_def.did)
Res::Def(DefKind::Struct, b_def.did())
} else if b_def.is_union() {
Res::Def(DefKind::Union, b_def.did)
Res::Def(DefKind::Union, b_def.did())
} else {
Res::Def(DefKind::Enum, b_def.did)
Res::Def(DefKind::Enum, b_def.did())
};

Some((a, b))
Expand Down Expand Up @@ -270,8 +270,8 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
_ => None,
};

self.current_old_types.remove(a);
self.current_new_types.remove(b);
self.current_old_types.remove(&a);
self.current_new_types.remove(&b);

if let Some((old, new)) = matching {
let old_def_id = old.def_id();
Expand All @@ -298,9 +298,9 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {

fn consts(
&mut self,
a: &'tcx ty::Const<'tcx>,
_: &'tcx ty::Const<'tcx>,
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
a: ty::Const<'tcx>,
_: ty::Const<'tcx>,
) -> RelateResult<'tcx, ty::Const<'tcx>> {
Ok(a) // TODO
}

Expand Down
21 changes: 12 additions & 9 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, Unevaluated,
GenericParamDefKind, ParamEnv, Predicate, Region, Term, TraitRef, Ty, TyCtxt, Unevaluated,
};
use std::collections::HashMap;

Expand Down Expand Up @@ -164,18 +164,18 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
use rustc_middle::ty::ExistentialPredicate::*;
use rustc_middle::ty::TyKind;
use rustc_middle::ty::TypeAndMut;
use rustc_middle::ty::{AdtDef, Binder, ExistentialProjection, ExistentialTraitRef};
use rustc_middle::ty::{Binder, ExistentialProjection, ExistentialTraitRef};

orig.fold_with(&mut BottomUpFolder {
tcx: self.tcx,
ty_op: |ty| {
match *ty.kind() {
TyKind::Adt(&AdtDef { ref did, .. }, substs)
if self.needs_translation(*did) =>
{
TyKind::Adt(adt_def, substs) if self.needs_translation(adt_def.did()) => {
// we fold bottom-up, so the code above is invalid, as it assumes the
// substs (that have been folded already) are yet untranslated
if let Some(target_def_id) = (self.translate_orig)(self.id_mapping, *did) {
if let Some(target_def_id) =
(self.translate_orig)(self.id_mapping, adt_def.did())
{
let target_adt = self.tcx.adt_def(target_def_id);
self.tcx.mk_adt(target_adt, substs)
} else {
Expand Down Expand Up @@ -261,7 +261,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
substs: self
.tcx
.intern_substs(&target_substs[1..]),
ty,
term: Term::Ty(ty),
})
} else {
success.set(false);
Expand Down Expand Up @@ -420,7 +420,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
substs: target_substs,
item_def_id: target_def_id,
},
ty: self.translate(index_map, pred.ty),
term: match pred.term {
Term::Ty(ty) => Term::Ty(self.translate(index_map, ty)),
Term::Const(_) => pred.term,
},
}
} else {
return None;
Expand Down Expand Up @@ -451,7 +454,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
}),
PredicateKind::ConstEvaluatable(uv) => {
if let Some((target_def_id, target_substs)) =
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
self.translate_orig_substs(index_map, uv.def.did, uv.substs)
{
// TODO: We could probably use translated version for
// `WithOptConstParam::const_param_did`
Expand Down
Loading

0 comments on commit 324a149

Please sign in to comment.