Invalid ?
suggestion on mismatched Ok(T)
This commit is contained in:
parent
7849162ace
commit
6c97f13612
@ -983,6 +983,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
let e_ok = args_e.type_at(0);
|
||||
let f_ok = args_f.type_at(0);
|
||||
if !self.infcx.can_eq(self.param_env, f_ok, e_ok) {
|
||||
return false;
|
||||
}
|
||||
let e = args_e.type_at(1);
|
||||
let f = args_f.type_at(1);
|
||||
if self
|
||||
|
@ -0,0 +1,6 @@
|
||||
fn foo() -> Result<String, ()> {
|
||||
let out: Result<(), ()> = Ok(());
|
||||
out //~ ERROR mismatched types
|
||||
}
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,15 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/issue-116967-cannot-coerce-returned-result.rs:3:5
|
||||
|
|
||||
LL | fn foo() -> Result<String, ()> {
|
||||
| ------------------ expected `Result<String, ()>` because of return type
|
||||
LL | let out: Result<(), ()> = Ok(());
|
||||
LL | out
|
||||
| ^^^ expected `Result<String, ()>`, found `Result<(), ()>`
|
||||
|
|
||||
= note: expected enum `Result<String, _>`
|
||||
found enum `Result<(), _>`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0308`.
|
Loading…
x
Reference in New Issue
Block a user