@@ -1952,6 +1952,52 @@ async fn main() {
19521952 "# ] ] ,
19531953 )
19541954}
1955+ #[ test]
1956+ fn async_block_early_return ( ) {
1957+ check_infer (
1958+ r#"
1959+ //- minicore: future, result, fn
1960+ fn test<I, E, F: FnMut() -> Fut, Fut: core::future::Future<Output = Result<I, E>>>(f: F) {}
1961+
1962+ fn main() {
1963+ async {
1964+ return Err(());
1965+ Ok(())
1966+ };
1967+ test(|| async {
1968+ return Err(());
1969+ Ok(())
1970+ });
1971+ }
1972+ "# ,
1973+ expect ! [ [ r#"
1974+ 83..84 'f': F
1975+ 89..91 '{}': ()
1976+ 103..231 '{ ... }); }': ()
1977+ 109..161 'async ... }': Result<(), ()>
1978+ 109..161 'async ... }': impl Future<Output = Result<(), ()>>
1979+ 125..139 'return Err(())': !
1980+ 132..135 'Err': Err<(), ()>(()) -> Result<(), ()>
1981+ 132..139 'Err(())': Result<(), ()>
1982+ 136..138 '()': ()
1983+ 149..151 'Ok': Ok<(), ()>(()) -> Result<(), ()>
1984+ 149..155 'Ok(())': Result<(), ()>
1985+ 152..154 '()': ()
1986+ 167..171 'test': fn test<(), (), || -> impl Future<Output = Result<(), ()>>, impl Future<Output = Result<(), ()>>>(|| -> impl Future<Output = Result<(), ()>>)
1987+ 167..228 'test(|... })': ()
1988+ 172..227 '|| asy... }': || -> impl Future<Output = Result<(), ()>>
1989+ 175..227 'async ... }': Result<(), ()>
1990+ 175..227 'async ... }': impl Future<Output = Result<(), ()>>
1991+ 191..205 'return Err(())': !
1992+ 198..201 'Err': Err<(), ()>(()) -> Result<(), ()>
1993+ 198..205 'Err(())': Result<(), ()>
1994+ 202..204 '()': ()
1995+ 215..217 'Ok': Ok<(), ()>(()) -> Result<(), ()>
1996+ 215..221 'Ok(())': Result<(), ()>
1997+ 218..220 '()': ()
1998+ "# ] ] ,
1999+ )
2000+ }
19552001
19562002#[ test]
19572003fn infer_generic_from_later_assignment ( ) {
0 commit comments