mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Expose registered_tools
directly without TyCtxt
-query
This commit is contained in:
parent
1238a20d38
commit
69cb0a9e15
@ -88,6 +88,8 @@ mod late;
|
|||||||
mod macros;
|
mod macros;
|
||||||
pub mod rustdoc;
|
pub mod rustdoc;
|
||||||
|
|
||||||
|
pub use macros::registered_tools_ast;
|
||||||
|
|
||||||
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -10,7 +10,7 @@ use rustc_ast::{self as ast, Crate, NodeId, attr};
|
|||||||
use rustc_ast_pretty::pprust;
|
use rustc_ast_pretty::pprust;
|
||||||
use rustc_attr_parsing::{AttributeKind, StabilityLevel, find_attr};
|
use rustc_attr_parsing::{AttributeKind, StabilityLevel, find_attr};
|
||||||
use rustc_data_structures::intern::Interned;
|
use rustc_data_structures::intern::Interned;
|
||||||
use rustc_errors::{Applicability, StashKey};
|
use rustc_errors::{Applicability, DiagCtxtHandle, StashKey};
|
||||||
use rustc_expand::base::{
|
use rustc_expand::base::{
|
||||||
DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind,
|
DeriveResolution, Indeterminate, ResolverExpand, SyntaxExtension, SyntaxExtensionKind,
|
||||||
};
|
};
|
||||||
@ -124,14 +124,21 @@ fn fast_print_path(path: &ast::Path) -> Symbol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
||||||
let mut registered_tools = RegisteredTools::default();
|
|
||||||
let (_, pre_configured_attrs) = &*tcx.crate_for_resolver(()).borrow();
|
let (_, pre_configured_attrs) = &*tcx.crate_for_resolver(()).borrow();
|
||||||
|
registered_tools_ast(tcx.dcx(), pre_configured_attrs)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn registered_tools_ast(
|
||||||
|
dcx: DiagCtxtHandle<'_>,
|
||||||
|
pre_configured_attrs: &[ast::Attribute],
|
||||||
|
) -> RegisteredTools {
|
||||||
|
let mut registered_tools = RegisteredTools::default();
|
||||||
for attr in attr::filter_by_name(pre_configured_attrs, sym::register_tool) {
|
for attr in attr::filter_by_name(pre_configured_attrs, sym::register_tool) {
|
||||||
for meta_item_inner in attr.meta_item_list().unwrap_or_default() {
|
for meta_item_inner in attr.meta_item_list().unwrap_or_default() {
|
||||||
match meta_item_inner.ident() {
|
match meta_item_inner.ident() {
|
||||||
Some(ident) => {
|
Some(ident) => {
|
||||||
if let Some(old_ident) = registered_tools.replace(ident) {
|
if let Some(old_ident) = registered_tools.replace(ident) {
|
||||||
tcx.dcx().emit_err(errors::ToolWasAlreadyRegistered {
|
dcx.emit_err(errors::ToolWasAlreadyRegistered {
|
||||||
span: ident.span,
|
span: ident.span,
|
||||||
tool: ident,
|
tool: ident,
|
||||||
old_ident_span: old_ident.span,
|
old_ident_span: old_ident.span,
|
||||||
@ -139,7 +146,7 @@ pub(crate) fn registered_tools(tcx: TyCtxt<'_>, (): ()) -> RegisteredTools {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
tcx.dcx().emit_err(errors::ToolOnlyAcceptsIdentifiers {
|
dcx.emit_err(errors::ToolOnlyAcceptsIdentifiers {
|
||||||
span: meta_item_inner.span(),
|
span: meta_item_inner.span(),
|
||||||
tool: sym::register_tool,
|
tool: sym::register_tool,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user