FIXME(eddyb) make this reusable from somewhere in `rustc`.
(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>)
| 243 | |
| 244 | // FIXME(eddyb) make this reusable from somewhere in `rustc`. |
| 245 | fn target_from_impl_item(tcx: TyCtxt<'_>, impl_item: &hir::ImplItem<'_>) -> Target { |
| 246 | match impl_item.kind { |
| 247 | hir::ImplItemKind::Const(..) => Target::AssocConst, |
| 248 | hir::ImplItemKind::Fn(..) => { |
| 249 | let parent_owner_id = tcx.hir().get_parent_item(impl_item.hir_id()); |
| 250 | let containing_item = tcx.hir().expect_item(parent_owner_id.def_id); |
| 251 | let containing_impl_is_for_trait = match &containing_item.kind { |
| 252 | hir::ItemKind::Impl(hir::Impl { of_trait, .. }) => of_trait.is_some(), |
| 253 | _ => unreachable!("parent of an ImplItem must be an Impl"), |
| 254 | }; |
| 255 | if containing_impl_is_for_trait { |
| 256 | Target::Method(MethodKind::Trait { body: true }) |
| 257 | } else { |
| 258 | Target::Method(MethodKind::Inherent) |
| 259 | } |
| 260 | } |
| 261 | hir::ImplItemKind::Type(..) => Target::AssocTy, |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | struct CheckSpirvAttrVisitor<'tcx> { |
| 266 | tcx: TyCtxt<'tcx>, |