From 94a0819fe3a0d679c3042a77bfe6a2afc505daea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:28 +0200 Subject: Adding upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/try-trait/bad-interconversion.stderr | 77 +++++++++------------- src/test/ui/try-trait/option-to-result.stderr | 24 +++---- .../ui/try-trait/try-on-option-diagnostics.stderr | 47 ++++++------- src/test/ui/try-trait/try-on-option.stderr | 24 +++---- src/test/ui/try-trait/try-operator-on-main.stderr | 30 +++------ 5 files changed, 80 insertions(+), 122 deletions(-) (limited to 'src/test/ui/try-trait') diff --git a/src/test/ui/try-trait/bad-interconversion.stderr b/src/test/ui/try-trait/bad-interconversion.stderr index 1dbf3ebdf..419a86bf3 100644 --- a/src/test/ui/try-trait/bad-interconversion.stderr +++ b/src/test/ui/try-trait/bad-interconversion.stderr @@ -16,19 +16,16 @@ LL | Ok(Err(123_i32)?) > > > - and 67 others - = note: required because of the requirements on the impl of `FromResidual>` for `Result` + and 68 others + = note: required for `Result` to implement `FromResidual>` error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` --> $DIR/bad-interconversion.rs:11:12 | -LL | / fn option_to_result() -> Result { -LL | | Some(3)?; - | | ^ use `.ok_or(...)?` to provide an error compatible with `Result` -LL | | -LL | | Ok(10) -LL | | } - | |_- this function returns a `Result` +LL | fn option_to_result() -> Result { + | -------------------------------------------- this function returns a `Result` +LL | Some(3)?; + | ^ use `.ok_or(...)?` to provide an error compatible with `Result` | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: @@ -38,12 +35,10 @@ LL | | } error[E0277]: the `?` operator can only be used on `Result`s in a function that returns `Result` --> $DIR/bad-interconversion.rs:17:31 | -LL | / fn control_flow_to_result() -> Result { -LL | | Ok(ControlFlow::Break(123)?) - | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result` -LL | | -LL | | } - | |_- this function returns a `Result` +LL | fn control_flow_to_result() -> Result { + | -------------------------------------------------- this function returns a `Result` +LL | Ok(ControlFlow::Break(123)?) + | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Result` | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: @@ -53,12 +48,10 @@ LL | | } error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/bad-interconversion.rs:22:22 | -LL | / fn result_to_option() -> Option { -LL | | Some(Err("hello")?) - | | ^ use `.ok()?` if you want to discard the `Result` error information -LL | | -LL | | } - | |_- this function returns an `Option` +LL | fn result_to_option() -> Option { + | ------------------------------------ this function returns an `Option` +LL | Some(Err("hello")?) + | ^ use `.ok()?` if you want to discard the `Result` error information | = help: the trait `FromResidual>` is not implemented for `Option` = help: the following other types implement trait `FromResidual`: @@ -68,12 +61,10 @@ LL | | } error[E0277]: the `?` operator can only be used on `Option`s in a function that returns `Option` --> $DIR/bad-interconversion.rs:27:33 | -LL | / fn control_flow_to_option() -> Option { -LL | | Some(ControlFlow::Break(123)?) - | | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option` -LL | | -LL | | } - | |_- this function returns an `Option` +LL | fn control_flow_to_option() -> Option { + | ------------------------------------------ this function returns an `Option` +LL | Some(ControlFlow::Break(123)?) + | ^ this `?` produces `ControlFlow<{integer}, Infallible>`, which is incompatible with `Option` | = help: the trait `FromResidual>` is not implemented for `Option` = help: the following other types implement trait `FromResidual`: @@ -83,12 +74,10 @@ LL | | } error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` --> $DIR/bad-interconversion.rs:32:39 | -LL | / fn result_to_control_flow() -> ControlFlow { -LL | | ControlFlow::Continue(Err("hello")?) - | | ^ this `?` produces `Result`, which is incompatible with `ControlFlow` -LL | | -LL | | } - | |_- this function returns a `ControlFlow` +LL | fn result_to_control_flow() -> ControlFlow { + | -------------------------------------------------- this function returns a `ControlFlow` +LL | ControlFlow::Continue(Err("hello")?) + | ^ this `?` produces `Result`, which is incompatible with `ControlFlow` | = help: the trait `FromResidual>` is not implemented for `ControlFlow` = help: the trait `FromResidual` is implemented for `ControlFlow` @@ -96,13 +85,10 @@ LL | | } error[E0277]: the `?` operator can only be used on `ControlFlow`s in a function that returns `ControlFlow` --> $DIR/bad-interconversion.rs:37:12 | -LL | / fn option_to_control_flow() -> ControlFlow { -LL | | Some(3)?; - | | ^ this `?` produces `Option`, which is incompatible with `ControlFlow` -LL | | -LL | | ControlFlow::Break(10) -LL | | } - | |_- this function returns a `ControlFlow` +LL | fn option_to_control_flow() -> ControlFlow { + | ----------------------------------------------- this function returns a `ControlFlow` +LL | Some(3)?; + | ^ this `?` produces `Option`, which is incompatible with `ControlFlow` | = help: the trait `FromResidual>` is not implemented for `ControlFlow` = help: the trait `FromResidual` is implemented for `ControlFlow` @@ -110,13 +96,10 @@ LL | | } error[E0277]: the `?` operator in a function that returns `ControlFlow` can only be used on other `ControlFlow`s (with the same Break type) --> $DIR/bad-interconversion.rs:43:29 | -LL | / fn control_flow_to_control_flow() -> ControlFlow { -LL | | ControlFlow::Break(4_u8)?; - | | ^ this `?` produces `ControlFlow`, which is incompatible with `ControlFlow` -LL | | -LL | | ControlFlow::Continue(()) -LL | | } - | |_- this function returns a `ControlFlow` +LL | fn control_flow_to_control_flow() -> ControlFlow { + | ----------------------------------------------------- this function returns a `ControlFlow` +LL | ControlFlow::Break(4_u8)?; + | ^ this `?` produces `ControlFlow`, which is incompatible with `ControlFlow` | = help: the trait `FromResidual>` is not implemented for `ControlFlow` = note: unlike `Result`, there's no `From`-conversion performed for `ControlFlow` diff --git a/src/test/ui/try-trait/option-to-result.stderr b/src/test/ui/try-trait/option-to-result.stderr index ae5c3ad62..fabc1ff2c 100644 --- a/src/test/ui/try-trait/option-to-result.stderr +++ b/src/test/ui/try-trait/option-to-result.stderr @@ -1,13 +1,11 @@ error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` --> $DIR/option-to-result.rs:5:6 | -LL | / fn test_result() -> Result<(),()> { -LL | | let a:Option<()> = Some(()); -LL | | a?; - | | ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), ()>` -LL | | Ok(()) -LL | | } - | |_- this function returns a `Result` +LL | fn test_result() -> Result<(),()> { + | --------------------------------- this function returns a `Result` +LL | let a:Option<()> = Some(()); +LL | a?; + | ^ use `.ok_or(...)?` to provide an error compatible with `Result<(), ()>` | = help: the trait `FromResidual>` is not implemented for `Result<(), ()>` = help: the following other types implement trait `FromResidual`: @@ -17,13 +15,11 @@ LL | | } error[E0277]: the `?` operator can only be used on `Option`s, not `Result`s, in a function that returns `Option` --> $DIR/option-to-result.rs:11:6 | -LL | / fn test_option() -> Option{ -LL | | let a:Result = Ok(5); -LL | | a?; - | | ^ use `.ok()?` if you want to discard the `Result` error information -LL | | Some(5) -LL | | } - | |_- this function returns an `Option` +LL | fn test_option() -> Option{ + | ------------------------------- this function returns an `Option` +LL | let a:Result = Ok(5); +LL | a?; + | ^ use `.ok()?` if you want to discard the `Result` error information | = help: the trait `FromResidual>` is not implemented for `Option` = help: the following other types implement trait `FromResidual`: diff --git a/src/test/ui/try-trait/try-on-option-diagnostics.stderr b/src/test/ui/try-trait/try-on-option-diagnostics.stderr index a6badd190..9ee540c79 100644 --- a/src/test/ui/try-trait/try-on-option-diagnostics.stderr +++ b/src/test/ui/try-trait/try-on-option-diagnostics.stderr @@ -1,51 +1,44 @@ error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:7:6 | -LL | / fn a_function() -> u32 { -LL | | let x: Option = None; -LL | | x?; - | | ^ cannot use the `?` operator in a function that returns `u32` -LL | | 22 -LL | | } - | |_- this function should return `Result` or `Option` to accept `?` +LL | fn a_function() -> u32 { + | ---------------------- this function should return `Result` or `Option` to accept `?` +LL | let x: Option = None; +LL | x?; + | ^ cannot use the `?` operator in a function that returns `u32` | = help: the trait `FromResidual>` is not implemented for `u32` error[E0277]: the `?` operator can only be used in a closure that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:14:10 | -LL | let a_closure = || { - | _____________________- -LL | | let x: Option = None; -LL | | x?; - | | ^ cannot use the `?` operator in a closure that returns `{integer}` -LL | | 22 -LL | | }; - | |_____- this function should return `Result` or `Option` to accept `?` +LL | let a_closure = || { + | -- this function should return `Result` or `Option` to accept `?` +LL | let x: Option = None; +LL | x?; + | ^ cannot use the `?` operator in a closure that returns `{integer}` | = help: the trait `FromResidual>` is not implemented for `{integer}` error[E0277]: the `?` operator can only be used in a method that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:26:14 | -LL | / fn a_method() { -LL | | let x: Option = None; -LL | | x?; - | | ^ cannot use the `?` operator in a method that returns `()` -LL | | } - | |_________- this function should return `Result` or `Option` to accept `?` +LL | fn a_method() { + | ------------- this function should return `Result` or `Option` to accept `?` +LL | let x: Option = None; +LL | x?; + | ^ cannot use the `?` operator in a method that returns `()` | = help: the trait `FromResidual>` is not implemented for `()` error[E0277]: the `?` operator can only be used in a trait method that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option-diagnostics.rs:39:14 | -LL | / fn a_trait_method() { -LL | | let x: Option = None; -LL | | x?; - | | ^ cannot use the `?` operator in a trait method that returns `()` -LL | | } - | |_________- this function should return `Result` or `Option` to accept `?` +LL | fn a_trait_method() { + | ------------------- this function should return `Result` or `Option` to accept `?` +LL | let x: Option = None; +LL | x?; + | ^ cannot use the `?` operator in a trait method that returns `()` | = help: the trait `FromResidual>` is not implemented for `()` diff --git a/src/test/ui/try-trait/try-on-option.stderr b/src/test/ui/try-trait/try-on-option.stderr index ba85a7cad..fad6a1fe8 100644 --- a/src/test/ui/try-trait/try-on-option.stderr +++ b/src/test/ui/try-trait/try-on-option.stderr @@ -1,13 +1,11 @@ error[E0277]: the `?` operator can only be used on `Result`s, not `Option`s, in a function that returns `Result` --> $DIR/try-on-option.rs:5:6 | -LL | / fn foo() -> Result { -LL | | let x: Option = None; -LL | | x?; - | | ^ use `.ok_or(...)?` to provide an error compatible with `Result` -LL | | Ok(22) -LL | | } - | |_- this function returns a `Result` +LL | fn foo() -> Result { + | --------------------------- this function returns a `Result` +LL | let x: Option = None; +LL | x?; + | ^ use `.ok_or(...)?` to provide an error compatible with `Result` | = help: the trait `FromResidual>` is not implemented for `Result` = help: the following other types implement trait `FromResidual`: @@ -17,13 +15,11 @@ LL | | } error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-on-option.rs:11:6 | -LL | / fn bar() -> u32 { -LL | | let x: Option = None; -LL | | x?; - | | ^ cannot use the `?` operator in a function that returns `u32` -LL | | 22 -LL | | } - | |_- this function should return `Result` or `Option` to accept `?` +LL | fn bar() -> u32 { + | --------------- this function should return `Result` or `Option` to accept `?` +LL | let x: Option = None; +LL | x?; + | ^ cannot use the `?` operator in a function that returns `u32` | = help: the trait `FromResidual>` is not implemented for `u32` diff --git a/src/test/ui/try-trait/try-operator-on-main.stderr b/src/test/ui/try-trait/try-operator-on-main.stderr index ad55f40b5..7cd38e0cf 100644 --- a/src/test/ui/try-trait/try-operator-on-main.stderr +++ b/src/test/ui/try-trait/try-operator-on-main.stderr @@ -1,15 +1,11 @@ error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-operator-on-main.rs:7:31 | -LL | / fn main() { -LL | | // error for a `Try` type on a non-`Try` fn -LL | | std::fs::File::open("foo")?; - | | ^ cannot use the `?` operator in a function that returns `()` -LL | | -... | -LL | | try_trait_generic::<()>(); -LL | | } - | |_- this function should return `Result` or `Option` to accept `?` +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +LL | // error for a `Try` type on a non-`Try` fn +LL | std::fs::File::open("foo")?; + | ^ cannot use the `?` operator in a function that returns `()` | = help: the trait `FromResidual>` is not implemented for `()` @@ -24,17 +20,11 @@ LL | ()?; error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `FromResidual`) --> $DIR/try-operator-on-main.rs:10:7 | -LL | / fn main() { -LL | | // error for a `Try` type on a non-`Try` fn -LL | | std::fs::File::open("foo")?; -LL | | -LL | | // a non-`Try` type on a non-`Try` fn -LL | | ()?; - | | ^ cannot use the `?` operator in a function that returns `()` -... | -LL | | try_trait_generic::<()>(); -LL | | } - | |_- this function should return `Result` or `Option` to accept `?` +LL | fn main() { + | --------- this function should return `Result` or `Option` to accept `?` +... +LL | ()?; + | ^ cannot use the `?` operator in a function that returns `()` | = help: the trait `FromResidual<_>` is not implemented for `()` -- cgit v1.2.3