mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-02 21:17:39 +00:00
![]() Fix await suggestion on non-future type Remove a match block that would suggest to add `.await` in the case where the expected type's `Future::Output` equals the found type. We only want to suggest `.await`ing in the opposite case (the found type's `Future::Output` equals the expected type). The code sample is here: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=6ba6b83d4dddda263553b79dca9f6bcb Before: ``` ➜ ~ rustc --edition=2021 --crate-type=lib test.rs error[E0308]: `match` arms have incompatible types --> test.rs:4:14 | 2 | let x = match 1 { | _____________- 3 | | 1 => other(), | | ------- this is found to be of type `impl Future` 4 | | 2 => other().await, | | ^^^^^^^^^^^^^ expected opaque type, found enum `Result` 5 | | }; | |_____- `match` arms have incompatible types | = note: expected type `impl Future` found enum `Result<(), ()>` help: consider `await`ing on the `Future` | 4 | 2 => other().await.await, | ++++++ error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. ``` After: ``` ➜ ~ rustc +stage1 --edition=2021 --crate-type=lib test.rs error[E0308]: `match` arms have incompatible types --> test.rs:4:14 | 2 | let x = match 1 { | _____________- 3 | | 1 => other(), | | ------- this is found to be of type `impl Future` 4 | | 2 => other().await, | | ^^^^^^^^^^^^^ expected opaque type, found enum `Result` 5 | | }; | |_____- `match` arms have incompatible types | = note: expected type `impl Future` found enum `Result<(), ()>` error: aborting due to previous error For more information about this error, try `rustc --explain E0308`. ``` Fixes #90931 |
||
---|---|---|
.. | ||
rustc | ||
rustc_apfloat | ||
rustc_arena | ||
rustc_ast | ||
rustc_ast_lowering | ||
rustc_ast_passes | ||
rustc_ast_pretty | ||
rustc_attr | ||
rustc_borrowck | ||
rustc_builtin_macros | ||
rustc_codegen_cranelift | ||
rustc_codegen_gcc | ||
rustc_codegen_llvm | ||
rustc_codegen_ssa | ||
rustc_const_eval | ||
rustc_data_structures | ||
rustc_driver | ||
rustc_error_codes | ||
rustc_errors | ||
rustc_expand | ||
rustc_feature | ||
rustc_fs_util | ||
rustc_graphviz | ||
rustc_hir | ||
rustc_hir_pretty | ||
rustc_incremental | ||
rustc_index | ||
rustc_infer | ||
rustc_interface | ||
rustc_lexer | ||
rustc_lint | ||
rustc_lint_defs | ||
rustc_llvm | ||
rustc_macros | ||
rustc_metadata | ||
rustc_middle | ||
rustc_mir_build | ||
rustc_mir_dataflow | ||
rustc_mir_transform | ||
rustc_monomorphize | ||
rustc_parse | ||
rustc_parse_format | ||
rustc_passes | ||
rustc_plugin_impl | ||
rustc_privacy | ||
rustc_query_impl | ||
rustc_query_system | ||
rustc_resolve | ||
rustc_save_analysis | ||
rustc_serialize | ||
rustc_session | ||
rustc_span | ||
rustc_symbol_mangling | ||
rustc_target | ||
rustc_trait_selection | ||
rustc_traits | ||
rustc_ty_utils | ||
rustc_type_ir | ||
rustc_typeck |