Closed
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=edb0af9c0b63ae2876296998fe8645dd
#![allow(unused_variables)]
use std::fs::File;
fn main() {
if Err(err) = File::open("hello.txt") {
}
}
The current output is:
error[E0425]: cannot find value `err` in this scope
--> src/main.rs:5:12
|
5 | if Err(err) = File::open("hello.txt") {
| ^^^
|
help: you might have meant to use pattern matching
|
5 | if let Err(err) = File::open("hello.txt") {
| +++
help: a tuple variant with a similar name exists
|
5 | if Err(Err) = File::open("hello.txt") {
| ~~~
help: consider importing one of these items
|
2 | use futures::future::err;
|
2 | use futures_0_1_31::future::err;
|
2 | use futures_util::future::err;
|
error[E0308]: mismatched types
--> src/main.rs:5:8
|
5 | if Err(err) = File::open("hello.txt") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `()`
Ideally the output should look like:
error[E0425]: cannot find value `err` in this scope
--> src/main.rs:5:12
|
5 | if Err(err) = File::open("hello.txt") {
| ^^^
|
help: you might have meant to use pattern matching
|
5 | if let Err(err) = File::open("hello.txt") {
| +++
How do we remove other diagnostics in this scenario?