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:
commit
9538e5bcd0
4 changed files with 24 additions and 2 deletions
|
|
@ -53,3 +53,8 @@ mod paths {
|
|||
fn under_msrv() {
|
||||
let _err = std::io::Error::new(std::io::ErrorKind::Other, E);
|
||||
}
|
||||
|
||||
pub fn issue14346(x: i32) -> std::io::Error {
|
||||
std::io::Error::other(format!("{x}"))
|
||||
//~^ ERROR: this can be `std::io::Error::other(_)`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,3 +53,8 @@ mod paths {
|
|||
fn under_msrv() {
|
||||
let _err = std::io::Error::new(std::io::ErrorKind::Other, E);
|
||||
}
|
||||
|
||||
pub fn issue14346(x: i32) -> std::io::Error {
|
||||
std::io::Error::new(std::io::ErrorKind::Other, format!("{x}"))
|
||||
//~^ ERROR: this can be `std::io::Error::other(_)`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,5 +48,17 @@ LL - let _err = io::Error::new(io::ErrorKind::Other, super::E);
|
|||
LL + let _err = io::Error::other(super::E);
|
||||
|
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
error: this can be `std::io::Error::other(_)`
|
||||
--> tests/ui/io_other_error.rs:58:5
|
||||
|
|
||||
LL | std::io::Error::new(std::io::ErrorKind::Other, format!("{x}"))
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: use `std::io::Error::other`
|
||||
|
|
||||
LL - std::io::Error::new(std::io::ErrorKind::Other, format!("{x}"))
|
||||
LL + std::io::Error::other(format!("{x}"))
|
||||
|
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue