diff options
| author | Michael Goulet <michael@errs.io> | 2023-03-13 18:54:05 +0000 | 
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2023-03-21 15:38:51 +0000 | 
| commit | 2eb1c08e433aadf2362a65f2ef1387670a6d34cf (patch) | |
| tree | 1d8465f4d80adbbe4a44dd72eedc3361bd2b8f7c /compiler/rustc_middle/src/ty/mod.rs | |
| parent | a01b4cc9f375f1b95fa8195daeea938d3d9c4c34 (diff) | |
| download | rust-2eb1c08e433aadf2362a65f2ef1387670a6d34cf.tar.gz rust-2eb1c08e433aadf2362a65f2ef1387670a6d34cf.zip | |
Use local key in providers
Diffstat (limited to 'compiler/rustc_middle/src/ty/mod.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/mod.rs | 14 | 
1 files changed, 10 insertions, 4 deletions
| diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs index 298b2c3073c..d8da8e0f34a 100644 --- a/compiler/rustc_middle/src/ty/mod.rs +++ b/compiler/rustc_middle/src/ty/mod.rs @@ -2027,7 +2027,6 @@ impl<'tcx> FieldDef { } } -pub type Attributes<'tcx> = impl Iterator<Item = &'tcx ast::Attribute>; #[derive(Debug, PartialEq, Eq)] pub enum ImplOverlapKind { /// These impls are always allowed to overlap. @@ -2375,7 +2374,12 @@ impl<'tcx> TyCtxt<'tcx> { } /// Gets all attributes with the given name. - pub fn get_attrs(self, did: DefId, attr: Symbol) -> ty::Attributes<'tcx> { + pub fn get_attrs( + self, + did: impl Into<DefId>, + attr: Symbol, + ) -> impl Iterator<Item = &'tcx ast::Attribute> { + let did: DefId = did.into(); let filter_fn = move |a: &&ast::Attribute| a.has_name(attr); if let Some(did) = did.as_local() { self.hir().attrs(self.hir().local_def_id_to_hir_id(did)).iter().filter(filter_fn) @@ -2386,8 +2390,9 @@ impl<'tcx> TyCtxt<'tcx> { } } - pub fn get_attr(self, did: DefId, attr: Symbol) -> Option<&'tcx ast::Attribute> { + pub fn get_attr(self, did: impl Into<DefId>, attr: Symbol) -> Option<&'tcx ast::Attribute> { if cfg!(debug_assertions) && !rustc_feature::is_valid_for_get_attr(attr) { + let did: DefId = did.into(); bug!("get_attr: unexpected called with DefId `{:?}`, attr `{:?}`", did, attr); } else { self.get_attrs(did, attr).next() @@ -2395,7 +2400,8 @@ impl<'tcx> TyCtxt<'tcx> { } /// Determines whether an item is annotated with an attribute. - pub fn has_attr(self, did: DefId, attr: Symbol) -> bool { + pub fn has_attr(self, did: impl Into<DefId>, attr: Symbol) -> bool { + let did: DefId = did.into(); if cfg!(debug_assertions) && !did.is_local() && rustc_feature::is_builtin_only_local(attr) { bug!("tried to access the `only_local` attribute `{}` from an extern crate", attr); } else { | 
