diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-03-14 17:43:27 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2020-04-05 15:26:09 +0200 |
| commit | 587b9abd4e0a72a3490766399659e393e3ed4da9 (patch) | |
| tree | 111e85be716efd37e43f64cf636394e73cbf885a | |
| parent | 81f0e90c62bda14f5e7279b3f771f69ac6bc153f (diff) | |
| download | rust-587b9abd4e0a72a3490766399659e393e3ed4da9.tar.gz rust-587b9abd4e0a72a3490766399659e393e3ed4da9.zip | |
Retire rustc::ty::Attributes enum.
| -rw-r--r-- | src/librustc_middle/ty/mod.rs | 23 | ||||
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 20 |
2 files changed, 10 insertions, 33 deletions
diff --git a/src/librustc_middle/ty/mod.rs b/src/librustc_middle/ty/mod.rs index 5bd467f8793..f35734fb353 100644 --- a/src/librustc_middle/ty/mod.rs +++ b/src/librustc_middle/ty/mod.rs @@ -29,7 +29,7 @@ use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::sorted_map::SortedIndexMultiMap; use rustc_data_structures::stable_hasher::{HashStable, StableHasher}; -use rustc_data_structures::sync::{self, par_iter, Lrc, ParallelIterator}; +use rustc_data_structures::sync::{self, par_iter, ParallelIterator}; use rustc_hir as hir; use rustc_hir::def::{CtorKind, CtorOf, DefKind, Namespace, Res}; use rustc_hir::def_id::{CrateNum, DefId, DefIdMap, LocalDefId, CRATE_DEF_INDEX}; @@ -2760,22 +2760,7 @@ impl BorrowKind { } } -#[derive(Debug, Clone)] -pub enum Attributes<'tcx> { - Owned(Lrc<[ast::Attribute]>), - Borrowed(&'tcx [ast::Attribute]), -} - -impl<'tcx> ::std::ops::Deref for Attributes<'tcx> { - type Target = [ast::Attribute]; - - fn deref(&self) -> &[ast::Attribute] { - match self { - &Attributes::Owned(ref data) => &data, - &Attributes::Borrowed(data) => data, - } - } -} +pub type Attributes<'tcx> = &'tcx [ast::Attribute]; #[derive(Debug, PartialEq, Eq)] pub enum ImplOverlapKind { @@ -3011,9 +2996,9 @@ impl<'tcx> TyCtxt<'tcx> { /// Gets the attributes of a definition. pub fn get_attrs(self, did: DefId) -> Attributes<'tcx> { if let Some(id) = self.hir().as_local_hir_id(did) { - Attributes::Borrowed(self.hir().attrs(id)) + self.hir().attrs(id) } else { - Attributes::Borrowed(self.item_attrs(did)) + self.item_attrs(did) } } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 1c26d401d56..4d9b36d8010 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2178,13 +2178,9 @@ impl Clean<Vec<Item>> for doctree::ExternCrate<'_> { let res = Res::Def(DefKind::Mod, DefId { krate: self.cnum, index: CRATE_DEF_INDEX }); - if let Some(items) = inline::try_inline( - cx, - res, - self.name, - Some(rustc_middle::ty::Attributes::Borrowed(self.attrs)), - &mut visited, - ) { + if let Some(items) = + inline::try_inline(cx, res, self.name, Some(self.attrs), &mut visited) + { return items; } } @@ -2245,13 +2241,9 @@ impl Clean<Vec<Item>> for doctree::Import<'_> { } if !denied { let mut visited = FxHashSet::default(); - if let Some(items) = inline::try_inline( - cx, - path.res, - name, - Some(rustc_middle::ty::Attributes::Borrowed(self.attrs)), - &mut visited, - ) { + if let Some(items) = + inline::try_inline(cx, path.res, name, Some(self.attrs), &mut visited) + { return items; } } |
