Simplify code
This commit is contained in:
parent
452cf4f710
commit
04583f29c8
1 changed files with 5 additions and 10 deletions
|
@ -4,21 +4,16 @@ use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
|
|
||||||
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
fn proc_macro_decls_static(tcx: TyCtxt<'_>, (): ()) -> Option<LocalDefId> {
|
||||||
let mut finder = Finder { tcx, decls: None };
|
let mut decls = None;
|
||||||
|
|
||||||
for id in tcx.hir().items() {
|
for id in tcx.hir().items() {
|
||||||
let attrs = finder.tcx.hir().attrs(id.hir_id());
|
let attrs = tcx.hir().attrs(id.hir_id());
|
||||||
if finder.tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
|
if tcx.sess.contains_name(attrs, sym::rustc_proc_macro_decls) {
|
||||||
finder.decls = Some(id.owner_id.def_id);
|
decls = Some(id.owner_id.def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finder.decls
|
decls
|
||||||
}
|
|
||||||
|
|
||||||
struct Finder<'tcx> {
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
decls: Option<LocalDefId>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue