mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-05 21:24:12 +00:00
review comments: reword and add test
This commit is contained in:
parent
ba8e09415b
commit
a710c610b2
@ -269,8 +269,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
let f_str = values.found.to_string();
|
||||
if &e_str == &f_str && &e_str == "impl std::future::Future" {
|
||||
// FIXME: use non-string based check.
|
||||
db.help("if both futures resolve to the same type, consider `await`ing \
|
||||
on both of them");
|
||||
db.help("if both `Future`s have the same `Output` type, consider \
|
||||
`.await`ing on both of them");
|
||||
}
|
||||
}
|
||||
if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) =
|
||||
|
24
src/test/ui/suggestions/opaque-type-error.rs
Normal file
24
src/test/ui/suggestions/opaque-type-error.rs
Normal file
@ -0,0 +1,24 @@
|
||||
// edition:2018
|
||||
use core::future::Future;
|
||||
|
||||
async fn base_thing() -> Result<(), ()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn thing_one() -> impl Future<Output = Result<(), ()>> {
|
||||
base_thing()
|
||||
}
|
||||
|
||||
fn thing_two() -> impl Future<Output = Result<(), ()>> {
|
||||
base_thing()
|
||||
}
|
||||
|
||||
async fn thing() -> Result<(), ()> {
|
||||
if true {
|
||||
thing_one()
|
||||
} else {
|
||||
thing_two() //~ ERROR if and else have incompatible types
|
||||
}.await
|
||||
}
|
||||
|
||||
fn main() {}
|
20
src/test/ui/suggestions/opaque-type-error.stderr
Normal file
20
src/test/ui/suggestions/opaque-type-error.stderr
Normal file
@ -0,0 +1,20 @@
|
||||
error[E0308]: if and else have incompatible types
|
||||
--> $DIR/opaque-type-error.rs:20:9
|
||||
|
|
||||
LL | / if true {
|
||||
LL | | thing_one()
|
||||
| | ----------- expected because of this
|
||||
LL | | } else {
|
||||
LL | | thing_two()
|
||||
| | ^^^^^^^^^^^ expected opaque type, found a different opaque type
|
||||
LL | | }.await
|
||||
| |_____- if and else have incompatible types
|
||||
|
|
||||
= note: expected type `impl std::future::Future` (opaque type)
|
||||
found type `impl std::future::Future` (opaque type)
|
||||
= note: distinct uses of `impl Trait` result in different opaque types
|
||||
= help: if both `Future`s have the same `Output` type, consider `.await`ing on both of them
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user