diff options
| author | Oneirical <manchot@videotron.ca> | 2025-07-13 16:25:27 -0400 |
|---|---|---|
| committer | Oneirical <manchot@videotron.ca> | 2025-08-04 16:43:53 -0400 |
| commit | 7196d8cd661b875401126a81641d2effc40b3d85 (patch) | |
| tree | 4e3f314add6e442f40dc9cba83c397a942c01776 /tests/ui/try-trait | |
| parent | 4b596bbd847672da87763b76171687d3544863c2 (diff) | |
| download | rust-7196d8cd661b875401126a81641d2effc40b3d85.tar.gz rust-7196d8cd661b875401126a81641d2effc40b3d85.zip | |
Rehome tests/ui/issues/ tests [3/?]
Diffstat (limited to 'tests/ui/try-trait')
| -rw-r--r-- | tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs | 13 | ||||
| -rw-r--r-- | tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr | 24 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs new file mode 100644 index 00000000000..4b2081d14d0 --- /dev/null +++ b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.rs @@ -0,0 +1,13 @@ +// https://github.com/rust-lang/rust/issues/51632 +#![allow(dead_code)] + +fn missing_discourses() -> Result<isize, ()> { + Ok(1) +} + +fn forbidden_narratives() -> Result<isize, ()> { + missing_discourses()? + //~^ ERROR: `?` operator has incompatible types +} + +fn main() {} diff --git a/tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr new file mode 100644 index 00000000000..c624605d76a --- /dev/null +++ b/tests/ui/try-trait/incompatible-types-with-question-mark-51632.stderr @@ -0,0 +1,24 @@ +error[E0308]: `?` operator has incompatible types + --> $DIR/incompatible-types-with-question-mark-51632.rs:9:5 + | +LL | fn forbidden_narratives() -> Result<isize, ()> { + | ----------------- expected `Result<isize, ()>` because of return type +LL | missing_discourses()? + | ^^^^^^^^^^^^^^^^^^^^^ expected `Result<isize, ()>`, found `isize` + | + = note: `?` operator cannot convert from `isize` to `Result<isize, ()>` + = note: expected enum `Result<isize, ()>` + found type `isize` +help: try removing this `?` + | +LL - missing_discourses()? +LL + missing_discourses() + | +help: try wrapping the expression in `Ok` + | +LL | Ok(missing_discourses()?) + | +++ + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. |
