Auto merge of #13248 - Alexendoo:format-arg-ast-fallback, r=xFrednet

Remove `find_format_arg_expr` AST fallback

If the function fails where it shouldn't we can fix that directly, but the fallback path is untested as I'm not aware of a case where it would fail

changelog: none
This commit is contained in:
bors 2024-08-18 09:11:03 +00:00
commit bfe7f070bd
4 changed files with 10 additions and 32 deletions

View file

@ -426,12 +426,8 @@ impl FormatArgsStorage {
}
}
/// Attempt to find the [`rustc_hir::Expr`] that corresponds to the [`FormatArgument`]'s value, if
/// it cannot be found it will return the [`rustc_ast::Expr`].
pub fn find_format_arg_expr<'hir, 'ast>(
start: &'hir Expr<'hir>,
target: &'ast FormatArgument,
) -> Result<&'hir Expr<'hir>, &'ast rustc_ast::Expr> {
/// Attempt to find the [`rustc_hir::Expr`] that corresponds to the [`FormatArgument`]'s value
pub fn find_format_arg_expr<'hir>(start: &'hir Expr<'hir>, target: &FormatArgument) -> Option<&'hir Expr<'hir>> {
let SpanData {
lo,
hi,
@ -449,7 +445,6 @@ pub fn find_format_arg_expr<'hir, 'ast>(
ControlFlow::Continue(())
}
})
.ok_or(&target.expr)
}
/// Span of the `:` and format specifiers