Remove TyCtxt::get_attrs_unchecked.
It's identical to `TyCtxt::get_all_attrs` except it takes `DefId` instead of `impl Into<DefIf>`.
This commit is contained in:
@@ -1706,15 +1706,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(@lcnr): Remove this function.
|
||||
pub fn get_attrs_unchecked(self, did: DefId) -> &'tcx [hir::Attribute] {
|
||||
if let Some(did) = did.as_local() {
|
||||
self.hir_attrs(self.local_def_id_to_hir_id(did))
|
||||
} else {
|
||||
self.attrs_for_def(did)
|
||||
}
|
||||
}
|
||||
|
||||
/// Gets all attributes with the given name.
|
||||
pub fn get_attrs(
|
||||
self,
|
||||
@@ -1726,7 +1717,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
|
||||
/// Gets all attributes.
|
||||
///
|
||||
/// To see if an item has a specific attribute, you should use [`rustc_attr_data_structures::find_attr!`] so you can use matching.
|
||||
/// To see if an item has a specific attribute, you should use
|
||||
/// [`rustc_attr_data_structures::find_attr!`] so you can use matching.
|
||||
pub fn get_all_attrs(self, did: impl Into<DefId>) -> &'tcx [hir::Attribute] {
|
||||
let did: DefId = did.into();
|
||||
if let Some(did) = did.as_local() {
|
||||
|
||||
@@ -217,7 +217,7 @@ pub(crate) fn try_inline_glob(
|
||||
}
|
||||
|
||||
pub(crate) fn load_attrs<'hir>(cx: &DocContext<'hir>, did: DefId) -> &'hir [hir::Attribute] {
|
||||
cx.tcx.get_attrs_unchecked(did)
|
||||
cx.tcx.get_all_attrs(did)
|
||||
}
|
||||
|
||||
pub(crate) fn item_relative_path(tcx: TyCtxt<'_>, def_id: DefId) -> Vec<Symbol> {
|
||||
|
||||
@@ -404,10 +404,7 @@ impl Item {
|
||||
}
|
||||
|
||||
pub(crate) fn inner_docs(&self, tcx: TyCtxt<'_>) -> bool {
|
||||
self.item_id
|
||||
.as_def_id()
|
||||
.map(|did| inner_docs(tcx.get_attrs_unchecked(did)))
|
||||
.unwrap_or(false)
|
||||
self.item_id.as_def_id().map(|did| inner_docs(tcx.get_all_attrs(did))).unwrap_or(false)
|
||||
}
|
||||
|
||||
pub(crate) fn span(&self, tcx: TyCtxt<'_>) -> Option<Span> {
|
||||
@@ -452,7 +449,7 @@ impl Item {
|
||||
kind: ItemKind,
|
||||
cx: &mut DocContext<'_>,
|
||||
) -> Item {
|
||||
let hir_attrs = cx.tcx.get_attrs_unchecked(def_id);
|
||||
let hir_attrs = cx.tcx.get_all_attrs(def_id);
|
||||
|
||||
Self::from_def_id_and_attrs_and_parts(
|
||||
def_id,
|
||||
|
||||
@@ -185,7 +185,7 @@ impl<'a, 'tcx> SigDropChecker<'a, 'tcx> {
|
||||
if let Some(adt) = ty.ty_adt_def()
|
||||
&& get_attr(
|
||||
self.cx.sess(),
|
||||
self.cx.tcx.get_attrs_unchecked(adt.did()),
|
||||
self.cx.tcx.get_all_attrs(adt.did()),
|
||||
sym::has_significant_drop,
|
||||
)
|
||||
.count()
|
||||
|
||||
@@ -168,7 +168,7 @@ impl<'cx, 'others, 'tcx> AttrChecker<'cx, 'others, 'tcx> {
|
||||
if let Some(adt) = ty.ty_adt_def() {
|
||||
let mut iter = get_attr(
|
||||
self.cx.sess(),
|
||||
self.cx.tcx.get_attrs_unchecked(adt.did()),
|
||||
self.cx.tcx.get_all_attrs(adt.did()),
|
||||
sym::has_significant_drop,
|
||||
);
|
||||
if iter.next().is_some() {
|
||||
|
||||
@@ -42,7 +42,7 @@ pub fn is_format_macro(cx: &LateContext<'_>, macro_def_id: DefId) -> bool {
|
||||
} else {
|
||||
// Allow users to tag any macro as being format!-like
|
||||
// TODO: consider deleting FORMAT_MACRO_DIAG_ITEMS and using just this method
|
||||
get_unique_attr(cx.sess(), cx.tcx.get_attrs_unchecked(macro_def_id), sym::format_args).is_some()
|
||||
get_unique_attr(cx.sess(), cx.tcx.get_all_attrs(macro_def_id), sym::format_args).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user