Walk back to the root context to compute the span (#14349)

Since the error kind (`io::ErrorKind::other`) is in the root context,
the error message must be found in the root context as well to compute
the correct span to remove.

Fix #14346

changelog: [`io_error_other`]: fix non-applicable suggestion

r? @llogiq
This commit is contained in:
llogiq 2025-03-05 05:52:19 +00:00 committed by GitHub
commit 9538e5bcd0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 2 deletions

View file

@ -27,7 +27,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, path: &Expr<'_>, args
"use `std::io::Error::other`",
vec![
(new_segment.ident.span, "other".to_owned()),
(error_kind.span.until(error.span), String::new()),
(error_kind.span.until(error.span.source_callsite()), String::new()),
],
Applicability::MachineApplicable,
);