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

Commit c4626b5

Browse files
committed
Auto merge of #227 - JohnTitor:rustups-2021-10, r=JohnTitor
Some rustups
2 parents 978dae7 + 88e114b commit c4626b5

File tree

8 files changed

+134
-136
lines changed

8 files changed

+134
-136
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-07-23` toolchain.
31-
You can install it by using `rustup install nightly-2021-07-23` if you already have rustup.
30+
It's recommended to use `nightly-2021-09-30` toolchain.
31+
You can install it by using `rustup install nightly-2021-09-30` 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-07-23
36-
$ cargo +nightly-2021-07-23 install --git https://github.com/rust-lang/rust-semverver
35+
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-30
36+
$ cargo +nightly-2021-09-30 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-07-23"
3+
channel = "nightly-2021-09-30"
44
components = ["llvm-tools-preview", "rustc-dev"]

src/changes.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ pub mod tests {
12391239
use std::cmp::{max, min};
12401240

12411241
use rustc_span::hygiene::SyntaxContext;
1242-
use rustc_span::symbol::Interner;
1242+
use rustc_span::symbol::sym;
12431243
use rustc_span::BytePos;
12441244

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

12491249
impl Span_ {
12501250
pub fn inner(self) -> Span {
1251-
Span::new(BytePos(self.0), BytePos(self.1), SyntaxContext::root())
1251+
Span::new(
1252+
BytePos(self.0),
1253+
BytePos(self.1),
1254+
SyntaxContext::root(),
1255+
None,
1256+
)
12521257
}
12531258
}
12541259

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

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

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

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

1558-
let mut interner = Interner::default();
1559-
let name = interner.intern("test");
1561+
let name = sym::test;
15601562

15611563
let max = changes
15621564
.iter()
@@ -1588,8 +1590,7 @@ pub mod tests {
15881590
rustc_span::create_default_session_globals_then(|| {
15891591
let mut set = ChangeSet::default();
15901592

1591-
let mut interner = Interner::default();
1592-
let name = interner.intern("test");
1593+
let name = sym::test;
15931594

15941595
let max = changes
15951596
.iter()
@@ -1623,8 +1624,7 @@ pub mod tests {
16231624
rustc_span::create_default_session_globals_then(|| {
16241625
let mut set = ChangeSet::default();
16251626

1626-
let mut interner = Interner::default();
1627-
let name = interner.intern("test");
1627+
let name = sym::test;
16281628

16291629
let max = pchanges
16301630
.iter()

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
#![allow(clippy::unnested_or_patterns)]
88
#![deny(warnings)]
99

10-
extern crate rustc_hir; // Requires `rustup component add rustc-dev`
10+
extern crate rustc_const_eval; // Requires `rustup component add rustc-dev`
11+
extern crate rustc_hir;
1112
extern crate rustc_infer;
1213
extern crate rustc_middle;
13-
extern crate rustc_mir;
1414
extern crate rustc_session;
1515
extern crate rustc_span;
1616
extern crate rustc_trait_selection;

src/mapping.rs

+5-7
Original file line numberDiff line numberDiff line change
@@ -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<HirId>>;
328+
type OptionalExport = Option<Export>;
329329

330330
/// A mapping from names to pairs of old and new exports.
331331
///
@@ -343,11 +343,11 @@ 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<HirId>, old: bool) {
346+
fn insert(&mut self, item: Export, old: bool) {
347347
use rustc_hir::def::DefKind::*;
348348
use rustc_hir::def::Res::*;
349349

350-
let map = match item.res {
350+
let map = match item.res.expect_non_local::<HirId>() {
351351
Def(kind, _) => match kind {
352352
Mod |
353353
Struct |
@@ -396,7 +396,7 @@ impl NameMapping {
396396
}
397397

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

409409
/// Drain the item pairs being stored.
410-
pub fn drain(
411-
&mut self,
412-
) -> impl Iterator<Item = (Option<Export<HirId>>, Option<Export<HirId>>)> + '_ {
410+
pub fn drain(&mut self) -> impl Iterator<Item = (Option<Export>, Option<Export>)> + '_ {
413411
self.type_map
414412
.drain()
415413
.chain(self.value_map.drain())

src/translate.rs

+88-86
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,
11+
GenericParamDefKind, ParamEnv, Predicate, Region, TraitRef, Ty, TyCtxt, Unevaluated,
1212
};
1313
use std::collections::HashMap;
1414

@@ -376,97 +376,99 @@ impl<'a, 'tcx> TranslationContext<'a, 'tcx> {
376376
predicate: Predicate<'tcx>,
377377
) -> Option<Predicate<'tcx>> {
378378
use rustc_middle::ty::{
379-
OutlivesPredicate, PredicateKind, ProjectionPredicate, ProjectionTy, SubtypePredicate,
380-
ToPredicate, TraitPredicate, WithOptConstParam,
379+
self, CoercePredicate, OutlivesPredicate, PredicateKind, ProjectionPredicate,
380+
ProjectionTy, SubtypePredicate, ToPredicate, TraitPredicate, WithOptConstParam,
381381
};
382382

383-
Some(
384-
match predicate.kind().skip_binder() {
385-
PredicateKind::Trait(pred, constness) => PredicateKind::Trait(
386-
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
387-
index_map,
388-
pred.trait_ref.def_id,
389-
pred.trait_ref.substs,
390-
) {
391-
TraitPredicate {
392-
trait_ref: TraitRef {
393-
def_id: target_def_id,
394-
substs: target_substs,
395-
},
396-
}
397-
} else {
398-
return None;
399-
},
400-
constness,
401-
),
402-
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
403-
let l = self.translate_region(pred.0);
404-
let r = self.translate_region(pred.1);
405-
OutlivesPredicate(l, r)
406-
}),
407-
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
408-
let l = self.translate(index_map, pred.0);
409-
let r = self.translate_region(pred.1);
410-
OutlivesPredicate(l, r)
411-
}),
412-
PredicateKind::Projection(pred) => PredicateKind::Projection(
413-
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
414-
index_map,
415-
pred.projection_ty.item_def_id,
416-
pred.projection_ty.substs,
417-
) {
418-
ProjectionPredicate {
419-
projection_ty: ProjectionTy {
420-
substs: target_substs,
421-
item_def_id: target_def_id,
422-
},
423-
ty: self.translate(index_map, pred.ty),
424-
}
425-
} else {
426-
return None;
427-
},
428-
),
429-
PredicateKind::WellFormed(ty) => {
430-
PredicateKind::WellFormed(self.translate(index_map, ty))
431-
}
432-
PredicateKind::ObjectSafe(did) => {
433-
PredicateKind::ObjectSafe(self.translate_orig(did))
434-
}
435-
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
436-
self.translate_orig(did),
437-
self.translate(index_map, substs),
438-
kind,
439-
),
440-
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
441-
let l = self.translate(index_map, pred.a);
442-
let r = self.translate(index_map, pred.b);
443-
SubtypePredicate {
444-
a_is_expected: pred.a_is_expected,
445-
a: l,
446-
b: r,
383+
let pred = match predicate.kind().skip_binder() {
384+
PredicateKind::Trait(pred) => PredicateKind::Trait(
385+
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
386+
index_map,
387+
pred.trait_ref.def_id,
388+
pred.trait_ref.substs,
389+
) {
390+
TraitPredicate {
391+
trait_ref: TraitRef {
392+
def_id: target_def_id,
393+
substs: target_substs,
394+
},
395+
constness: pred.constness,
447396
}
448-
}),
449-
PredicateKind::ConstEvaluatable(param, orig_substs) => {
450-
if let Some((target_def_id, target_substs)) =
451-
self.translate_orig_substs(index_map, param.did, orig_substs)
452-
{
453-
// TODO: We could probably use translated version for
454-
// `WithOptConstParam::const_param_did`
455-
let const_param = WithOptConstParam::unknown(target_def_id);
456-
PredicateKind::ConstEvaluatable(const_param, target_substs)
457-
} else {
458-
return None;
397+
} else {
398+
return None;
399+
},
400+
),
401+
PredicateKind::RegionOutlives(pred) => PredicateKind::RegionOutlives({
402+
let l = self.translate_region(pred.0);
403+
let r = self.translate_region(pred.1);
404+
OutlivesPredicate(l, r)
405+
}),
406+
PredicateKind::TypeOutlives(pred) => PredicateKind::TypeOutlives({
407+
let l = self.translate(index_map, pred.0);
408+
let r = self.translate_region(pred.1);
409+
OutlivesPredicate(l, r)
410+
}),
411+
PredicateKind::Projection(pred) => PredicateKind::Projection(
412+
if let Some((target_def_id, target_substs)) = self.translate_orig_substs(
413+
index_map,
414+
pred.projection_ty.item_def_id,
415+
pred.projection_ty.substs,
416+
) {
417+
ProjectionPredicate {
418+
projection_ty: ProjectionTy {
419+
substs: target_substs,
420+
item_def_id: target_def_id,
421+
},
422+
ty: self.translate(index_map, pred.ty),
459423
}
424+
} else {
425+
return None;
426+
},
427+
),
428+
PredicateKind::WellFormed(ty) => {
429+
PredicateKind::WellFormed(self.translate(index_map, ty))
430+
}
431+
PredicateKind::ObjectSafe(did) => PredicateKind::ObjectSafe(self.translate_orig(did)),
432+
PredicateKind::ClosureKind(did, substs, kind) => PredicateKind::ClosureKind(
433+
self.translate_orig(did),
434+
self.translate(index_map, substs),
435+
kind,
436+
),
437+
PredicateKind::Subtype(pred) => PredicateKind::Subtype({
438+
let l = self.translate(index_map, pred.a);
439+
let r = self.translate(index_map, pred.b);
440+
SubtypePredicate {
441+
a_is_expected: pred.a_is_expected,
442+
a: l,
443+
b: r,
444+
}
445+
}),
446+
PredicateKind::Coerce(pred) => PredicateKind::Coerce({
447+
let a = self.translate(index_map, pred.a);
448+
let b = self.translate(index_map, pred.b);
449+
CoercePredicate { a, b }
450+
}),
451+
PredicateKind::ConstEvaluatable(uv) => {
452+
if let Some((target_def_id, target_substs)) =
453+
self.translate_orig_substs(index_map, uv.def.did, uv.substs(self.tcx))
454+
{
455+
// TODO: We could probably use translated version for
456+
// `WithOptConstParam::const_param_did`
457+
let const_param = WithOptConstParam::unknown(target_def_id);
458+
PredicateKind::ConstEvaluatable(Unevaluated::new(const_param, target_substs))
459+
} else {
460+
return None;
460461
}
461-
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
462-
self.translate(index_map, c1),
463-
self.translate(index_map, c2),
464-
),
465-
// NOTE: Only used for Chalk trait solver
466-
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
467462
}
468-
.to_predicate(self.tcx),
469-
)
463+
PredicateKind::ConstEquate(c1, c2) => PredicateKind::ConstEquate(
464+
self.translate(index_map, c1),
465+
self.translate(index_map, c2),
466+
),
467+
// NOTE: Only used for Chalk trait solver
468+
PredicateKind::TypeWellFormedFromEnv(_) => unimplemented!(),
469+
};
470+
471+
Some(ty::Binder::dummy(pred).to_predicate(self.tcx))
470472
}
471473

472474
/// Translate a slice of predicates in the context of an item.

0 commit comments

Comments
 (0)