diff --git a/README.md b/README.md index 2739175c..b48b37c6 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ repository and compiled from source or installed from of the nightly toolchain is supported at any given time. -It's recommended to use `nightly-2021-09-10` toolchain. -You can install it by using `rustup install nightly-2021-09-10` if you already have rustup. +It's recommended to use `nightly-2021-09-20` toolchain. +You can install it by using `rustup install nightly-2021-09-20` if you already have rustup. Then you can do: ```sh -$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-10 -$ cargo +nightly-2021-09-10 install --git https://github.com/rust-lang/rust-semverver +$ rustup component add rustc-dev llvm-tools-preview --toolchain nightly-2021-09-20 +$ cargo +nightly-2021-09-20 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 diff --git a/rust-toolchain b/rust-toolchain index 544711cd..a52f4999 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1,4 +1,4 @@ # NOTE: Keep in sync with nightly date on README [toolchain] -channel = "nightly-2021-09-10" +channel = "nightly-2021-09-20" components = ["llvm-tools-preview", "rustc-dev"] diff --git a/src/changes.rs b/src/changes.rs index 3e83cada..55f15889 100644 --- a/src/changes.rs +++ b/src/changes.rs @@ -1230,7 +1230,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. @@ -1239,7 +1239,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, + ) } } @@ -1460,8 +1465,7 @@ pub mod tests { output: bool, changes: Vec<(ChangeType_, Option)>, ) -> 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())); @@ -1475,8 +1479,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); @@ -1546,8 +1549,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() @@ -1579,8 +1581,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() @@ -1614,8 +1615,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() diff --git a/src/mapping.rs b/src/mapping.rs index 1a3b1283..6830b47f 100644 --- a/src/mapping.rs +++ b/src/mapping.rs @@ -325,7 +325,7 @@ impl IdMapping { } /// An export that could be missing from one of the crate versions. -type OptionalExport = Option>; +type OptionalExport = Option; /// A mapping from names to pairs of old and new exports. /// @@ -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, 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::() { Def(kind, _) => match kind { Mod | Struct | @@ -396,7 +396,7 @@ impl NameMapping { } /// Add all items from two vectors of old/new exports. - pub fn add(&mut self, old_items: Vec>, new_items: Vec>) { + pub fn add(&mut self, old_items: Vec, new_items: Vec) { for item in old_items { self.insert(item, true); } @@ -407,9 +407,7 @@ impl NameMapping { } /// Drain the item pairs being stored. - pub fn drain( - &mut self, - ) -> impl Iterator>, Option>)> + '_ { + pub fn drain(&mut self) -> impl Iterator, Option)> + '_ { self.type_map .drain() .chain(self.value_map.drain()) diff --git a/src/traverse.rs b/src/traverse.rs index 14c951c6..2cc67961 100644 --- a/src/traverse.rs +++ b/src/traverse.rs @@ -68,7 +68,7 @@ pub fn run_analysis(tcx: TyCtxt, old: DefId, new: DefId) -> ChangeSet { } // Get the visibility of the inner item, given the outer item's visibility. -fn get_vis(outer_vis: Visibility, def: Export) -> Visibility { +fn get_vis(outer_vis: Visibility, def: Export) -> Visibility { if outer_vis == Public { def.vis } else { @@ -156,7 +156,8 @@ fn diff_structure<'tcx>( match items { // an item pair is found (Some(o), Some(n)) => { - if let (Def(Mod, o_def_id), Def(Mod, n_def_id)) = (o.res, n.res) { + let (o_res, n_res) = (o.res.expect_non_local(), n.res.expect_non_local()); + if let (Def(Mod, o_def_id), Def(Mod, n_def_id)) = (o_res, n_res) { if visited.insert((o_def_id, n_def_id)) { let o_vis = get_vis(old_vis, o); let n_vis = get_vis(new_vis, n); @@ -182,16 +183,16 @@ fn diff_structure<'tcx>( mod_queue.push_back((o_def_id, n_def_id, o_vis, n_vis)); } - } else if id_mapping.add_export(o.res, n.res) { + } else if id_mapping.add_export(o_res, n_res) { // struct constructors are weird/hard - let's go shopping! if let (Def(Ctor(CtorOf::Struct, _), _), Def(Ctor(CtorOf::Struct, _), _)) = - (o.res, n.res) + (o_res, n_res) { continue; } - let o_def_id = o.res.def_id(); - let n_def_id = n.res.def_id(); + let o_def_id = o_res.def_id(); + let n_def_id = n_res.def_id(); let o_vis = get_vis(old_vis, o); let n_vis = get_vis(new_vis, n); @@ -211,7 +212,7 @@ fn diff_structure<'tcx>( changes.add_change(ChangeType::ItemMadePublic, o_def_id, None); } - let (o_kind, n_kind) = match (o.res, n.res) { + let (o_kind, n_kind) = match (o_res, n_res) { (Res::Def(o_kind, _), Res::Def(n_kind, _)) => (o_kind, n_kind), _ => { // a non-matching item pair (seriously broken though) - @@ -257,7 +258,7 @@ fn diff_structure<'tcx>( // that need to be compared (Fn, Fn) => { diff_generics(changes, id_mapping, tcx, true, o_def_id, n_def_id); - diff_fn(changes, tcx, o.res, n.res); + diff_fn(changes, tcx, o_res, n_res); } // type aliases can declare generics, too (TyAlias, TyAlias) => { @@ -268,7 +269,7 @@ fn diff_structure<'tcx>( // fields (Struct, Struct) | (Union, Union) | (Enum, Enum) => { diff_generics(changes, id_mapping, tcx, false, o_def_id, n_def_id); - diff_adts(changes, id_mapping, tcx, o.res, n.res); + diff_adts(changes, id_mapping, tcx, o_res, n_res); } // trait definitions can declare generics and require us to check // for trait item addition and removal, as well as changes to their @@ -298,7 +299,7 @@ fn diff_structure<'tcx>( // only an old item is found (Some(o), None) => { // struct constructors are weird/hard - let's go shopping! - if let Def(Ctor(CtorOf::Struct, _), _) = o.res { + if let Def(Ctor(CtorOf::Struct, _), _) = o.res.expect_non_local::() { continue; } @@ -310,7 +311,7 @@ fn diff_structure<'tcx>( // only a new item is found (None, Some(n)) => { // struct constructors are weird/hard - let's go shopping! - if let Def(Ctor(CtorOf::Struct, _), _) = n.res { + if let Def(Ctor(CtorOf::Struct, _), _) = n.res.expect_non_local::() { continue; } @@ -327,7 +328,7 @@ fn diff_structure<'tcx>( // finally, process item additions and removals for n in additions { - let n_def_id = n.res.def_id(); + let n_def_id = n.res.expect_non_local::().def_id(); if !id_mapping.contains_new_id(n_def_id) { id_mapping.add_non_mapped(n_def_id); @@ -338,7 +339,7 @@ fn diff_structure<'tcx>( } for o in removals { - let o_def_id = o.res.def_id(); + let o_def_id = o.res.expect_non_local::().def_id(); // reuse an already existing path change entry, if possible if id_mapping.contains_old_id(o_def_id) {