Skip to content

Commit 2fc0483

Browse files
committed
Fix an assertion failure in bind_generator_hidden_types_above.
Fixes rust-lang#110941.
1 parent 9ecda8d commit 2fc0483

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

compiler/rustc_trait_selection/src/traits/select/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3016,6 +3016,7 @@ fn bind_generator_hidden_types_above<'tcx>(
30163016
counter += 1;
30173017
tcx.mk_re_late_bound(current_depth, br)
30183018
}
3019+
ty::RePlaceholder(_) => r,
30193020
r => bug!("unexpected region: {r:?}"),
30203021
})
30213022
}

tests/ui/regions/issue-110941.rs

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// run-pass
2+
// compile-flags: --edition=2018 -Zdrop-tracking-mir=yes
3+
4+
use std::future::{Future, Ready};
5+
async fn read() {}
6+
async fn connect<A: ToSocketAddr>(addr: A) {
7+
let _ = addr.to_socket_addr().await;
8+
}
9+
pub trait ToSocketAddr {
10+
type Future: Future;
11+
fn to_socket_addr(&self) -> Self::Future;
12+
}
13+
impl ToSocketAddr for &() {
14+
type Future = Ready<()>;
15+
fn to_socket_addr(&self) -> Self::Future {
16+
unimplemented!()
17+
}
18+
}
19+
struct Server;
20+
impl Server {
21+
fn and_then<F>(self, _fun: F) -> AndThen<F> {
22+
unimplemented!()
23+
}
24+
}
25+
struct AndThen<F> {
26+
_marker: std::marker::PhantomData<F>,
27+
}
28+
pub async fn run<F>(_: F) {
29+
let _ = connect(&()).await;
30+
}
31+
fn main() {
32+
let _ = async {
33+
let server = Server;
34+
let verification_route = server.and_then(read);
35+
run(verification_route).await;
36+
};
37+
}

0 commit comments

Comments
 (0)