Skip to content

Commit 1471f0b

Browse files
committed
Ensure that associated async fns have unique fresh param names
1 parent 2e72448 commit 1471f0b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/librustc/hir/lowering.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ impl<'a> LoweringContext<'a> {
844844
/// header, we convert it to an in-band lifetime.
845845
fn collect_fresh_in_band_lifetime(&mut self, span: Span) -> ParamName {
846846
assert!(self.is_collecting_in_band_lifetimes);
847-
let index = self.lifetimes_to_define.len();
847+
let index = self.lifetimes_to_define.len() + self.in_scope_lifetimes.len();
848848
let hir_name = ParamName::Fresh(index);
849849
self.lifetimes_to_define.push((span, hir_name));
850850
hir_name
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// check-pass
2+
// Check that the anonymous lifetimes used here aren't considered to shadow one
3+
// another. Note that `async fn` is different to `fn` here because the lifetimes
4+
// are numbered by HIR lowering, rather than lifetime resolution.
5+
6+
// edition:2018
7+
8+
struct A<'a, 'b>(&'a &'b i32);
9+
struct B<'a>(&'a i32);
10+
11+
impl A<'_, '_> {
12+
async fn assoc(x: &u32, y: B<'_>) {
13+
async fn nested(x: &u32, y: A<'_, '_>) {}
14+
}
15+
16+
async fn assoc2(x: &u32, y: A<'_, '_>) {
17+
impl A<'_, '_> {
18+
async fn nested_assoc(x: &u32, y: B<'_>) {}
19+
}
20+
}
21+
}
22+
23+
fn main() {}

0 commit comments

Comments
 (0)