rust/tests/ui/return/return-from-residual-sugg-issue-125997.stderr

87 lines
3.4 KiB
Plaintext

error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/return-from-residual-sugg-issue-125997.rs:10:44
|
LL | fn test1() {
| ---------- this function should return `Result` or `Option` to accept `?`
LL | let mut _file = File::create("foo.txt")?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
help: consider adding return type
|
LL ~ fn test1() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL +
LL + Ok(())
LL + }
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/return-from-residual-sugg-issue-125997.rs:15:44
|
LL | fn test2() {
| ---------- this function should return `Result` or `Option` to accept `?`
LL | let mut _file = File::create("foo.txt")?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
help: consider adding return type
|
LL ~ fn test2() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | println!();
LL +
LL + Ok(())
LL + }
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/return-from-residual-sugg-issue-125997.rs:31:44
|
LL | fn main() {
| --------- this function should return `Result` or `Option` to accept `?`
LL | let mut _file = File::create("foo.txt")?;
| ^ cannot use the `?` operator in a function that returns `()`
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
help: consider adding return type
|
LL ~ fn main() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | mac!();
LL +
LL + Ok(())
LL + }
|
error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`)
--> $DIR/return-from-residual-sugg-issue-125997.rs:23:52
|
LL | fn test3() {
| ---------- this function should return `Result` or `Option` to accept `?`
LL | let mut _file = File::create("foo.txt")?;
| ^ cannot use the `?` operator in a function that returns `()`
...
LL | mac!();
| ------ in this macro invocation
|
= help: the trait `FromResidual<Result<Infallible, std::io::Error>>` is not implemented for `()`
= note: this error originates in the macro `mac` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider adding return type
|
LL ~ fn test3() -> Result<(), Box<dyn std::error::Error>> {
LL | let mut _file = File::create("foo.txt")?;
LL |
LL | println!();
LL ~
LL + Ok(())
LL + }
|
error: aborting due to 4 previous errors
For more information about this error, try `rustc --explain E0277`.