Ensure that associated async fns have unique fresh param names
This commit is contained in:
parent
2e7244807a
commit
1471f0bc1b
2 changed files with 24 additions and 1 deletions
|
|
@ -844,7 +844,7 @@ impl<'a> LoweringContext<'a> {
|
|||
/// header, we convert it to an in-band lifetime.
|
||||
fn collect_fresh_in_band_lifetime(&mut self, span: Span) -> ParamName {
|
||||
assert!(self.is_collecting_in_band_lifetimes);
|
||||
let index = self.lifetimes_to_define.len();
|
||||
let index = self.lifetimes_to_define.len() + self.in_scope_lifetimes.len();
|
||||
let hir_name = ParamName::Fresh(index);
|
||||
self.lifetimes_to_define.push((span, hir_name));
|
||||
hir_name
|
||||
|
|
|
|||
23
src/test/ui/async-await/async-assoc-fn-anon-lifetimes.rs
Normal file
23
src/test/ui/async-await/async-assoc-fn-anon-lifetimes.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// check-pass
|
||||
// Check that the anonymous lifetimes used here aren't considered to shadow one
|
||||
// another. Note that `async fn` is different to `fn` here because the lifetimes
|
||||
// are numbered by HIR lowering, rather than lifetime resolution.
|
||||
|
||||
// edition:2018
|
||||
|
||||
struct A<'a, 'b>(&'a &'b i32);
|
||||
struct B<'a>(&'a i32);
|
||||
|
||||
impl A<'_, '_> {
|
||||
async fn assoc(x: &u32, y: B<'_>) {
|
||||
async fn nested(x: &u32, y: A<'_, '_>) {}
|
||||
}
|
||||
|
||||
async fn assoc2(x: &u32, y: A<'_, '_>) {
|
||||
impl A<'_, '_> {
|
||||
async fn nested_assoc(x: &u32, y: B<'_>) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
Loading…
Add table
Add a link
Reference in a new issue