diff options
| author | Nicholas Nethercote <nnethercote@mozilla.com> | 2020-07-30 11:27:50 +1000 |
|---|---|---|
| committer | Nicholas Nethercote <nnethercote@mozilla.com> | 2020-08-08 12:03:42 +1000 |
| commit | e539dd65f8ba80837f7477c0547c61514bceb3ad (patch) | |
| tree | 4d52e0a8cb566c47f9f189b7d11af5095d65eb2d /src/librustc_plugin_impl | |
| parent | d6fa011f62ee0c3b256d0be9a69369cbceb3c45b (diff) | |
Eliminate the `SessionGlobals` from `librustc_ast`.
By moving `{known,used}_attrs` from `SessionGlobals` to `Session`. This
means they are accessed via the `Session`, rather than via TLS. A few
`Attr` methods and `librustc_ast` functions are now methods of
`Session`.
All of this required passing a `Session` to lots of functions that didn't
already have one. Some of these functions also had arguments removed, because
those arguments could be accessed directly via the `Session` argument.
`contains_feature_attr()` was dead, and is removed.
Some functions were moved from `librustc_ast` elsewhere because they now need
to access `Session`, which isn't available in that crate.
- `entry_point_type()` --> `librustc_builtin_macros`
- `global_allocator_spans()` --> `librustc_metadata`
- `is_proc_macro_attr()` --> `Session`
Diffstat (limited to 'src/librustc_plugin_impl')
| -rw-r--r-- | src/librustc_plugin_impl/build.rs | 10 | ||||
| -rw-r--r-- | src/librustc_plugin_impl/load.rs | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/librustc_plugin_impl/build.rs b/src/librustc_plugin_impl/build.rs index db2363316cd..d16dd701a12 100644 --- a/src/librustc_plugin_impl/build.rs +++ b/src/librustc_plugin_impl/build.rs @@ -1,6 +1,5 @@ //! Used by `rustc` when compiling a plugin crate. -use rustc_ast::attr; use rustc_hir as hir; use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; use rustc_hir::itemlikevisit::ItemLikeVisitor; @@ -9,14 +8,15 @@ use rustc_middle::ty::TyCtxt; use rustc_span::symbol::sym; use rustc_span::Span; -struct RegistrarFinder { +struct RegistrarFinder<'tcx> { + tcx: TyCtxt<'tcx>, registrars: Vec<(hir::HirId, Span)>, } -impl<'v> ItemLikeVisitor<'v> for RegistrarFinder { +impl<'v, 'tcx> ItemLikeVisitor<'v> for RegistrarFinder<'tcx> { fn visit_item(&mut self, item: &hir::Item<'_>) { if let hir::ItemKind::Fn(..) = item.kind { - if attr::contains_name(&item.attrs, sym::plugin_registrar) { + if self.tcx.sess.contains_name(&item.attrs, sym::plugin_registrar) { self.registrars.push((item.hir_id, item.span)); } } @@ -35,7 +35,7 @@ pub fn find_plugin_registrar(tcx: TyCtxt<'_>) -> Option<DefId> { fn plugin_registrar_fn(tcx: TyCtxt<'_>, cnum: CrateNum) -> Option<DefId> { assert_eq!(cnum, LOCAL_CRATE); - let mut finder = RegistrarFinder { registrars: Vec::new() }; + let mut finder = RegistrarFinder { tcx, registrars: Vec::new() }; tcx.hir().krate().visit_all_item_likes(&mut finder); match finder.registrars.len() { diff --git a/src/librustc_plugin_impl/load.rs b/src/librustc_plugin_impl/load.rs index 62a87b47a2f..2f307302db0 100644 --- a/src/librustc_plugin_impl/load.rs +++ b/src/librustc_plugin_impl/load.rs @@ -32,7 +32,7 @@ pub fn load_plugins( let mut plugins = Vec::new(); for attr in &krate.attrs { - if !attr.check_name(sym::plugin) { + if !sess.check_name(attr, sym::plugin) { continue; } |
