-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #102161 - compiler-errors:issue-102138, r=tmandry
Resolve async fn signature even without body (e.g., in trait) Fixes #102138 This "bail if no body" behavior was introduced in #69539 to fix #69401, but that ICE does not reproduce any more. The error message changes a bit, but that's all, and I don't think it's a particularly diagnostic bad regression.
- Loading branch information
Showing
3 changed files
with
94 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// check-pass | ||
// edition:2021 | ||
|
||
#![feature(async_fn_in_trait)] | ||
#![allow(incomplete_features)] | ||
|
||
use std::future::Future; | ||
|
||
async fn yield_now() {} | ||
|
||
trait AsyncIterator { | ||
type Item; | ||
async fn next(&mut self) -> Option<Self::Item>; | ||
} | ||
|
||
struct YieldingRange { | ||
counter: u32, | ||
stop: u32, | ||
} | ||
|
||
impl AsyncIterator for YieldingRange { | ||
type Item = u32; | ||
|
||
async fn next(&mut self) -> Option<Self::Item> { | ||
if self.counter == self.stop { | ||
None | ||
} else { | ||
let c = self.counter; | ||
self.counter += 1; | ||
yield_now().await; | ||
Some(c) | ||
} | ||
} | ||
} | ||
|
||
async fn async_main() { | ||
let mut x = YieldingRange { counter: 0, stop: 10 }; | ||
|
||
while let Some(v) = x.next().await { | ||
println!("Hi: {v}"); | ||
} | ||
} | ||
|
||
fn main() { | ||
let _ = async_main(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// check-pass | ||
// This is currently stable behavior, which was almost accidentally made an | ||
// error in #102161 since there is no test exercising it. I am not sure if | ||
// this _should_ be the desired behavior, but at least we should know if it | ||
// changes. | ||
|
||
fn main() {} | ||
|
||
trait Foo { | ||
fn fn_with_type_named_same_as_local_in_param(b: i32, b: i32); | ||
} |