diff options
| author | bors <bors@rust-lang.org> | 2019-05-05 21:11:47 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-05-05 21:11:47 +0000 |
| commit | 40bd145cbef28d279aacc903907c3945f83a6296 (patch) | |
| tree | 482b6a07004b00963ca608ac27e1e6d4ed1bfde0 /src/librustc/ty | |
| parent | d628c2e642c6f8f85f24dd5d7f49de89b95bf682 (diff) | |
| parent | ff7ef116fbe4698f9df0370021d398dc345b832b (diff) | |
| download | rust-40bd145cbef28d279aacc903907c3945f83a6296.tar.gz rust-40bd145cbef28d279aacc903907c3945f83a6296.zip | |
Auto merge of #60567 - Manishearth:rollup-rjagqnw, r=Manishearth
Rollup of 5 pull requests Successful merges: - #60131 (Fix broken link in rustc_plugin doc) - #60426 (Stop `-O`/`-C opt-level` and `-g`/`-C debuginfo` conflicting) - #60515 (use span instead of div for since version) - #60530 (rustc: rename all occurences of "freevar" to "upvar".) - #60536 (Correct code points to match their textual description) Failed merges: r? @ghost
Diffstat (limited to 'src/librustc/ty')
| -rw-r--r-- | src/librustc/ty/context.rs | 8 | ||||
| -rw-r--r-- | src/librustc/ty/mod.rs | 18 | ||||
| -rw-r--r-- | src/librustc/ty/print/pretty.rs | 12 |
3 files changed, 13 insertions, 25 deletions
diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index fddae024091..19440d0bc64 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -1071,10 +1071,10 @@ pub struct GlobalCtxt<'tcx> { pub queries: query::Queries<'tcx>, - // Records the free variables referenced by every closure + // Records the captured variables referenced by every closure // expression. Do not track deps for this, just recompute it from // scratch every time. - freevars: FxHashMap<DefId, Lrc<Vec<hir::Freevar>>>, + upvars: FxHashMap<DefId, Lrc<Vec<hir::Upvar>>>, maybe_unused_trait_imports: FxHashSet<DefId>, maybe_unused_extern_crates: Vec<(DefId, Span)>, @@ -1317,7 +1317,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { }).collect(); (k, Lrc::new(exports)) }).collect(), - freevars: resolutions.freevars.into_iter().map(|(k, v)| { + upvars: resolutions.upvars.into_iter().map(|(k, v)| { let vars: Vec<_> = v.into_iter().map(|e| { e.map_id(|id| hir.node_to_hir_id(id)) }).collect(); @@ -3055,7 +3055,7 @@ pub fn provide(providers: &mut ty::query::Providers<'_>) { assert_eq!(id, LOCAL_CRATE); Lrc::new(middle::lang_items::collect(tcx)) }; - providers.freevars = |tcx, id| tcx.gcx.freevars.get(&id).cloned(); + providers.upvars = |tcx, id| tcx.gcx.upvars.get(&id).cloned(); providers.maybe_unused_trait_import = |tcx, id| { tcx.maybe_unused_trait_imports.contains(&id) }; diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index feedf5741f6..cb92e4b7470 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -8,8 +8,8 @@ pub use self::BorrowKind::*; pub use self::IntVarValue::*; pub use self::fold::TypeFoldable; -use crate::hir::{map as hir_map, FreevarMap, GlobMap, TraitMap}; -use crate::hir::{HirId, Node}; +use crate::hir::{map as hir_map, UpvarMap, GlobMap, TraitMap}; +use crate::hir::Node; use crate::hir::def::{Res, DefKind, CtorOf, CtorKind, ExportMap}; use crate::hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX, LOCAL_CRATE}; use rustc_data_structures::svh::Svh; @@ -122,7 +122,7 @@ mod sty; #[derive(Clone)] pub struct Resolutions { - pub freevars: FreevarMap, + pub upvars: UpvarMap, pub trait_map: TraitMap, pub maybe_unused_trait_imports: NodeSet, pub maybe_unused_extern_crates: Vec<(NodeId, Span)>, @@ -3120,18 +3120,6 @@ impl Iterator for AssociatedItemsIterator<'_, '_, '_> { } } -impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { - pub fn with_freevars<T, F>(self, fid: HirId, f: F) -> T where - F: FnOnce(&[hir::Freevar]) -> T, - { - let def_id = self.hir().local_def_id_from_hir_id(fid); - match self.freevars(def_id) { - None => f(&[]), - Some(d) => f(&d), - } - } -} - fn associated_item<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> AssociatedItem { let id = tcx.hir().as_local_hir_id(def_id).unwrap(); let parent_id = tcx.hir().get_parent_item(id); diff --git a/src/librustc/ty/print/pretty.rs b/src/librustc/ty/print/pretty.rs index e09dcd16bd3..8e98d4d85b9 100644 --- a/src/librustc/ty/print/pretty.rs +++ b/src/librustc/ty/print/pretty.rs @@ -582,16 +582,16 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: if let Some(hir_id) = self.tcx().hir().as_local_hir_id(did) { p!(write("@{:?}", self.tcx().hir().span_by_hir_id(hir_id))); let mut sep = " "; - for (freevar, upvar_ty) in self.tcx().freevars(did) + for (upvar, upvar_ty) in self.tcx().upvars(did) .as_ref() - .map_or(&[][..], |fv| &fv[..]) + .map_or(&[][..], |v| &v[..]) .iter() .zip(upvar_tys) { p!( write("{}{}:", sep, - self.tcx().hir().name_by_hir_id(freevar.var_id())), + self.tcx().hir().name_by_hir_id(upvar.var_id())), print(upvar_ty)); sep = ", "; } @@ -625,16 +625,16 @@ pub trait PrettyPrinter<'gcx: 'tcx, 'tcx>: p!(write("@{:?}", self.tcx().hir().span_by_hir_id(hir_id))); } let mut sep = " "; - for (freevar, upvar_ty) in self.tcx().freevars(did) + for (upvar, upvar_ty) in self.tcx().upvars(did) .as_ref() - .map_or(&[][..], |fv| &fv[..]) + .map_or(&[][..], |v| &v[..]) .iter() .zip(upvar_tys) { p!( write("{}{}:", sep, - self.tcx().hir().name_by_hir_id(freevar.var_id())), + self.tcx().hir().name_by_hir_id(upvar.var_id())), print(upvar_ty)); sep = ", "; } |
