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};
}
}
-#[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 {
/// 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)
}
}
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;
}
}
}
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;
}
}