Convert two rustc_middle::lint functions to Span methods.

`rustc_middle` is a huge crate and it's always good to move stuff out of
it. There are lots of similar methods already on `Span`, so these two
functions, `in_external_macro` and `is_from_async_await`, fit right in.
The diff is big because `in_external_macro` is used a lot by clippy
lints.
This commit is contained in:
Nicholas Nethercote 2025-02-02 13:54:50 +11:00
parent 9c8fe3078e
commit d30f045fce
95 changed files with 131 additions and 224 deletions

View file

@ -88,7 +88,7 @@ declare_lint_pass!(MissingInline => [MISSING_INLINE_IN_PUBLIC_ITEMS]);
impl<'tcx> LateLintPass<'tcx> for MissingInline {
fn check_item(&mut self, cx: &LateContext<'tcx>, it: &'tcx hir::Item<'_>) {
if rustc_middle::lint::in_external_macro(cx.sess(), it.span) || is_executable_or_proc_macro(cx) {
if it.span.in_external_macro(cx.sess().source_map()) || is_executable_or_proc_macro(cx) {
return;
}
@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
}
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
if rustc_middle::lint::in_external_macro(cx.sess(), impl_item.span) || is_executable_or_proc_macro(cx) {
if impl_item.span.in_external_macro(cx.sess().source_map()) || is_executable_or_proc_macro(cx) {
return;
}