Skip to content

Commit 7dbee3c

Browse files
committed
1 parent c4b8702 commit 7dbee3c

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

README.md

Lines changed: 4 additions & 4 deletions
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-09-10` toolchain.
31-
You can install it by using `rustup install nightly-2021-09-10` if you already have rustup.
30+
It's recommended to use `nightly-2021-09-20` toolchain.
31+
You can install it by using `rustup install nightly-2021-09-20` 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-09-10
36-
$ cargo +nightly-2021-09-10 install --git https://github.com/rust-lang/rust-semverver
35+
$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-20
36+
$ cargo +nightly-2021-09-20 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

Lines changed: 1 addition & 1 deletion
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-09-10"
3+
channel = "nightly-2021-09-20"
44
components = ["llvm-tools-preview", "rustc-dev"]

src/changes.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,7 +1230,7 @@ pub mod tests {
12301230
use std::cmp::{max, min};
12311231

12321232
use rustc_span::hygiene::SyntaxContext;
1233-
use rustc_span::symbol::Interner;
1233+
use rustc_span::symbol::sym;
12341234
use rustc_span::BytePos;
12351235

12361236
/// A wrapper for `Span` that can be randomly generated.
@@ -1239,7 +1239,12 @@ pub mod tests {
12391239

12401240
impl Span_ {
12411241
pub fn inner(self) -> Span {
1242-
Span::new(BytePos(self.0), BytePos(self.1), SyntaxContext::root())
1242+
Span::new(
1243+
BytePos(self.0),
1244+
BytePos(self.1),
1245+
SyntaxContext::root(),
1246+
None,
1247+
)
12431248
}
12441249
}
12451250

@@ -1460,8 +1465,7 @@ pub mod tests {
14601465
output: bool,
14611466
changes: Vec<(ChangeType_, Option<Span_>)>,
14621467
) -> Change<'a> {
1463-
let mut interner = Interner::default();
1464-
let mut change = Change::new(Name::Symbol(RSymbol(interner.intern("test"))), s1, output);
1468+
let mut change = Change::new(Name::Symbol(RSymbol(sym::test)), s1, output);
14651469

14661470
for (type_, span) in changes {
14671471
change.insert(type_.inner(), span.map(|s| s.inner()));
@@ -1475,8 +1479,7 @@ pub mod tests {
14751479

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

14811484
for (add, span) in spans {
14821485
change.insert(span, add);
@@ -1546,8 +1549,7 @@ pub mod tests {
15461549
rustc_span::create_default_session_globals_then(|| {
15471550
let mut set = ChangeSet::default();
15481551

1549-
let mut interner = Interner::default();
1550-
let name = interner.intern("test");
1552+
let name = sym::test;
15511553

15521554
let max = changes
15531555
.iter()
@@ -1579,8 +1581,7 @@ pub mod tests {
15791581
rustc_span::create_default_session_globals_then(|| {
15801582
let mut set = ChangeSet::default();
15811583

1582-
let mut interner = Interner::default();
1583-
let name = interner.intern("test");
1584+
let name = sym::test;
15841585

15851586
let max = changes
15861587
.iter()
@@ -1614,8 +1615,7 @@ pub mod tests {
16141615
rustc_span::create_default_session_globals_then(|| {
16151616
let mut set = ChangeSet::default();
16161617

1617-
let mut interner = Interner::default();
1618-
let name = interner.intern("test");
1618+
let name = sym::test;
16191619

16201620
let max = pchanges
16211621
.iter()

src/mapping.rs

Lines changed: 5 additions & 7 deletions
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/traverse.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn run_analysis(tcx: TyCtxt, old: DefId, new: DefId) -> ChangeSet {
6868
}
6969

7070
// Get the visibility of the inner item, given the outer item's visibility.
71-
fn get_vis(outer_vis: Visibility, def: Export<HirId>) -> Visibility {
71+
fn get_vis(outer_vis: Visibility, def: Export) -> Visibility {
7272
if outer_vis == Public {
7373
def.vis
7474
} else {
@@ -156,7 +156,8 @@ fn diff_structure<'tcx>(
156156
match items {
157157
// an item pair is found
158158
(Some(o), Some(n)) => {
159-
if let (Def(Mod, o_def_id), Def(Mod, n_def_id)) = (o.res, n.res) {
159+
let (o_res, n_res) = (o.res.expect_non_local(), n.res.expect_non_local());
160+
if let (Def(Mod, o_def_id), Def(Mod, n_def_id)) = (o_res, n_res) {
160161
if visited.insert((o_def_id, n_def_id)) {
161162
let o_vis = get_vis(old_vis, o);
162163
let n_vis = get_vis(new_vis, n);
@@ -182,16 +183,16 @@ fn diff_structure<'tcx>(
182183

183184
mod_queue.push_back((o_def_id, n_def_id, o_vis, n_vis));
184185
}
185-
} else if id_mapping.add_export(o.res, n.res) {
186+
} else if id_mapping.add_export(o_res, n_res) {
186187
// struct constructors are weird/hard - let's go shopping!
187188
if let (Def(Ctor(CtorOf::Struct, _), _), Def(Ctor(CtorOf::Struct, _), _)) =
188-
(o.res, n.res)
189+
(o_res, n_res)
189190
{
190191
continue;
191192
}
192193

193-
let o_def_id = o.res.def_id();
194-
let n_def_id = n.res.def_id();
194+
let o_def_id = o_res.def_id();
195+
let n_def_id = n_res.def_id();
195196
let o_vis = get_vis(old_vis, o);
196197
let n_vis = get_vis(new_vis, n);
197198

@@ -211,7 +212,7 @@ fn diff_structure<'tcx>(
211212
changes.add_change(ChangeType::ItemMadePublic, o_def_id, None);
212213
}
213214

214-
let (o_kind, n_kind) = match (o.res, n.res) {
215+
let (o_kind, n_kind) = match (o_res, n_res) {
215216
(Res::Def(o_kind, _), Res::Def(n_kind, _)) => (o_kind, n_kind),
216217
_ => {
217218
// a non-matching item pair (seriously broken though) -
@@ -257,7 +258,7 @@ fn diff_structure<'tcx>(
257258
// that need to be compared
258259
(Fn, Fn) => {
259260
diff_generics(changes, id_mapping, tcx, true, o_def_id, n_def_id);
260-
diff_fn(changes, tcx, o.res, n.res);
261+
diff_fn(changes, tcx, o_res, n_res);
261262
}
262263
// type aliases can declare generics, too
263264
(TyAlias, TyAlias) => {
@@ -268,7 +269,7 @@ fn diff_structure<'tcx>(
268269
// fields
269270
(Struct, Struct) | (Union, Union) | (Enum, Enum) => {
270271
diff_generics(changes, id_mapping, tcx, false, o_def_id, n_def_id);
271-
diff_adts(changes, id_mapping, tcx, o.res, n.res);
272+
diff_adts(changes, id_mapping, tcx, o_res, n_res);
272273
}
273274
// trait definitions can declare generics and require us to check
274275
// for trait item addition and removal, as well as changes to their
@@ -298,7 +299,7 @@ fn diff_structure<'tcx>(
298299
// only an old item is found
299300
(Some(o), None) => {
300301
// struct constructors are weird/hard - let's go shopping!
301-
if let Def(Ctor(CtorOf::Struct, _), _) = o.res {
302+
if let Def(Ctor(CtorOf::Struct, _), _) = o.res.expect_non_local::<HirId>() {
302303
continue;
303304
}
304305

@@ -310,7 +311,7 @@ fn diff_structure<'tcx>(
310311
// only a new item is found
311312
(None, Some(n)) => {
312313
// struct constructors are weird/hard - let's go shopping!
313-
if let Def(Ctor(CtorOf::Struct, _), _) = n.res {
314+
if let Def(Ctor(CtorOf::Struct, _), _) = n.res.expect_non_local::<HirId>() {
314315
continue;
315316
}
316317

@@ -327,7 +328,7 @@ fn diff_structure<'tcx>(
327328

328329
// finally, process item additions and removals
329330
for n in additions {
330-
let n_def_id = n.res.def_id();
331+
let n_def_id = n.res.expect_non_local::<HirId>().def_id();
331332

332333
if !id_mapping.contains_new_id(n_def_id) {
333334
id_mapping.add_non_mapped(n_def_id);
@@ -338,7 +339,7 @@ fn diff_structure<'tcx>(
338339
}
339340

340341
for o in removals {
341-
let o_def_id = o.res.def_id();
342+
let o_def_id = o.res.expect_non_local::<HirId>().def_id();
342343

343344
// reuse an already existing path change entry, if possible
344345
if id_mapping.contains_old_id(o_def_id) {

0 commit comments

Comments
 (0)