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

Commit 324a149

Browse files
committed
Auto merge of #288 - dario23:update-rustc, r=JohnTitor
Update rustc to 2022-03-13
2 parents 4139b2d + 644b3e2 commit 324a149

File tree

9 files changed

+93
-78
lines changed

9 files changed

+93
-78
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ repository and compiled from source or installed from
2727
of the nightly toolchain is supported at any given time.
2828

2929
<!-- NOTE: Keep in sync with nightly date on rust-toolchain. -->
30-
It's recommended to use `nightly-2021-12-31` toolchain.
31-
You can install it by using `rustup install nightly-2021-12-31` if you already have rustup.
30+
It's recommended to use `nightly-2022-03-13` toolchain.
31+
You can install it by using `rustup install nightly-2022-03-13` if you already have rustup.
3232
Then you can do:
3333

3434
```sh
35-
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-12-31
36-
$ cargo +nightly-2021-12-31 install --git https://github.com/rust-lang/rust-semverver
35+
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2022-03-13
36+
$ cargo +nightly-2022-03-13 install --git https://github.com/rust-lang/rust-semverver
3737
```
3838

3939
You'd also need `cmake` for some dependencies, and a few common libraries (if you hit

rust-toolchain

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# NOTE: Keep in sync with nightly date on README
22
[toolchain]
3-
channel = "nightly-2021-12-31"
3+
channel = "nightly-2022-03-13"
44
components = ["llvm-tools-preview", "rustc-dev"]

src/changes.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,9 @@ impl PathChange {
202202

203203
let msg = format!("path changes to `{}`", self.name.0);
204204
let mut builder = if cat == Breaking {
205-
session.struct_span_err(self.def_span, &msg)
205+
session
206+
.struct_span_err(self.def_span, &msg)
207+
.forget_guarantee()
206208
} else {
207209
session.struct_span_warn(self.def_span, &msg)
208210
};
@@ -903,7 +905,9 @@ impl<'tcx> Change<'tcx> {
903905

904906
let msg = format!("{} changes in {}", self.max, self.name);
905907
let mut builder = if self.max == Breaking {
906-
session.struct_span_err(self.new_span, &msg)
908+
session
909+
.struct_span_err(self.new_span, &msg)
910+
.forget_guarantee()
907911
} else {
908912
session.struct_span_warn(self.new_span, &msg)
909913
};

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
extern crate rustc_const_eval; // Requires `rustup component add rustc-dev`
1212
extern crate rustc_hir;
1313
extern crate rustc_infer;
14+
extern crate rustc_metadata;
1415
extern crate rustc_middle;
1516
extern crate rustc_session;
1617
extern crate rustc_span;

src/mapping.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rustc_hir::{
99
HirId,
1010
};
1111
use rustc_middle::{
12-
hir::exports::Export,
12+
metadata::ModChild,
1313
ty::{AssocKind, GenericParamDef, GenericParamDefKind},
1414
};
1515
use rustc_span::symbol::Symbol;
@@ -325,7 +325,7 @@ impl IdMapping {
325325
}
326326

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

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

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

@@ -382,7 +382,7 @@ impl NameMapping {
382382
Closure |
383383
Generator => None,
384384
},
385-
PrimTy(_) | SelfTy(_, _) => Some(&mut self.type_map),
385+
PrimTy(_) | SelfTy { .. } => Some(&mut self.type_map),
386386
SelfCtor(_) | Local(_) => Some(&mut self.value_map),
387387
_ => None,
388388
};
@@ -397,7 +397,7 @@ impl NameMapping {
397397
}
398398

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

410410
/// Drain the item pairs being stored.
411-
pub fn drain(&mut self) -> impl Iterator<Item = (Option<Export>, Option<Export>)> + '_ {
411+
pub fn drain(&mut self) -> impl Iterator<Item = (Option<ModChild>, Option<ModChild>)> + '_ {
412412
self.type_map
413413
.drain()
414414
.chain(self.value_map.drain())

src/mismatch.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
140140
// could potentially short-circuit somewhere).
141141
let dummy_type = self.tcx.types.unit;
142142

143-
if self.current_old_types.contains(a) || self.current_new_types.contains(b) {
143+
if self.current_old_types.contains(&a) || self.current_new_types.contains(&b) {
144144
return Ok(dummy_type);
145145
}
146146

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

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

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

174174
let a = if a_def.is_struct() {
175-
Res::Def(DefKind::Struct, a_def.did)
175+
Res::Def(DefKind::Struct, a_def.did())
176176
} else if a_def.is_union() {
177-
Res::Def(DefKind::Union, a_def.did)
177+
Res::Def(DefKind::Union, a_def.did())
178178
} else {
179-
Res::Def(DefKind::Enum, a_def.did)
179+
Res::Def(DefKind::Enum, a_def.did())
180180
};
181181

182182
let b = if b_def.is_struct() {
183-
Res::Def(DefKind::Struct, b_def.did)
183+
Res::Def(DefKind::Struct, b_def.did())
184184
} else if b_def.is_union() {
185-
Res::Def(DefKind::Union, b_def.did)
185+
Res::Def(DefKind::Union, b_def.did())
186186
} else {
187-
Res::Def(DefKind::Enum, b_def.did)
187+
Res::Def(DefKind::Enum, b_def.did())
188188
};
189189

190190
Some((a, b))
@@ -270,8 +270,8 @@ impl<'a, 'tcx> TypeRelation<'tcx> for MismatchRelation<'a, 'tcx> {
270270
_ => None,
271271
};
272272

273-
self.current_old_types.remove(a);
274-
self.current_new_types.remove(b);
273+
self.current_old_types.remove(&a);
274+
self.current_new_types.remove(&b);
275275

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

299299
fn consts(
300300
&mut self,
301-
a: &'tcx ty::Const<'tcx>,
302-
_: &'tcx ty::Const<'tcx>,
303-
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
301+
a: ty::Const<'tcx>,
302+
_: ty::Const<'tcx>,
303+
) -> RelateResult<'tcx, ty::Const<'tcx>> {
304304
Ok(a) // TODO
305305
}
306306

src/translate.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use rustc_infer::infer::InferCtxt;
88
use rustc_middle::ty::{
99
fold::{BottomUpFolder, TypeFoldable, TypeFolder},
1010
subst::{GenericArg, InternalSubsts, SubstsRef},
11-
GenericParamDefKind, ParamEnv, Predicate, Region, TraitRef, Ty, TyCtxt, Unevaluated,
11+
GenericParamDefKind, ParamEnv, Predicate, Region, Term, TraitRef, Ty, TyCtxt, Unevaluated,
1212
};
1313
use std::collections::HashMap;
1414

@@ -164,18 +164,18 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
164164
use rustc_middle::ty::ExistentialPredicate::*;
165165
use rustc_middle::ty::TyKind;
166166
use rustc_middle::ty::TypeAndMut;
167-
use rustc_middle::ty::{AdtDef, Binder, ExistentialProjection, ExistentialTraitRef};
167+
use rustc_middle::ty::{Binder, ExistentialProjection, ExistentialTraitRef};
168168

169169
orig.fold_with(&mut BottomUpFolder {
170170
tcx: self.tcx,
171171
ty_op: |ty| {
172172
match *ty.kind() {
173-
TyKind::Adt(&AdtDef { ref did, .. }, substs)
174-
if self.needs_translation(*did) =>
175-
{
173+
TyKind::Adt(adt_def, substs) if self.needs_translation(adt_def.did()) => {
176174
// we fold bottom-up, so the code above is invalid, as it assumes the
177175
// substs (that have been folded already) are yet untranslated
178-
if let Some(target_def_id) = (self.translate_orig)(self.id_mapping, *did) {
176+
if let Some(target_def_id) =
177+
(self.translate_orig)(self.id_mapping, adt_def.did())
178+
{
179179
let target_adt = self.tcx.adt_def(target_def_id);
180180
self.tcx.mk_adt(target_adt, substs)
181181
} else {
@@ -261,7 +261,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
261261
substs: self
262262
.tcx
263263
.intern_substs(&target_substs[1..]),
264-
ty,
264+
term: Term::Ty(ty),
265265
})
266266
} else {
267267
success.set(false);
@@ -420,7 +420,10 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
420420
substs: target_substs,
421421
item_def_id: target_def_id,
422422
},
423-
ty: self.translate(index_map, pred.ty),
423+
term: match pred.term {
424+
Term::Ty(ty) => Term::Ty(self.translate(index_map, ty)),
425+
Term::Const(_) => pred.term,
426+
},
424427
}
425428
} else {
426429
return None;
@@ -451,7 +454,7 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
451454
}),
452455
PredicateKind::ConstEvaluatable(uv) => {
453456
if let Some((target_def_id, target_substs)) =
454-
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
457+
self.translate_orig_substs(index_map, uv.def.did, uv.substs)
455458
{
456459
// TODO: We could probably use translated version for
457460
// `WithOptConstParam::const_param_did`

0 commit comments

Comments
 (0)