Skip to content

Commit 5dc594a

Browse files
authored
Rollup merge of rust-lang#84653 - jackh726:erase-flags, r=nikomatsakis
Add HAS_RE_LATE_BOUND if there are bound vars Fixes rust-lang#83737 Fixes rust-lang#84604 I can rename `HAS_RE_LATE_BOUND`, to something like `HAS_LATE_BOUND_VARS`. r? ``@nikomatsakis``
2 parents 623ecb0 + c9fbaa6 commit 5dc594a

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

compiler/rustc_middle/src/ty/flags.rs

+7
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ impl FlagComputation {
5959
{
6060
let mut computation = FlagComputation::new();
6161

62+
// In some cases, there are binders with variables that are unused (e.g., `for<'a> fn(u32)`).
63+
// Set the flag to represent the `'a` in this example. Note that if there are late bound types
64+
// or consts, this flag will also get set.
65+
if !value.bound_vars().is_empty() {
66+
computation.flags = computation.flags | TypeFlags::HAS_RE_LATE_BOUND;
67+
}
68+
6269
f(&mut computation, value.skip_binder());
6370

6471
self.add_flags(computation.flags);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// build-pass
2+
// compile-flags: --edition 2018
3+
// compile-flags: --crate-type rlib
4+
5+
use std::future::Future;
6+
7+
async fn handle<F>(slf: &F)
8+
where
9+
F: Fn(&()) -> Box<dyn for<'a> Future<Output = ()> + Unpin>,
10+
{
11+
(slf)(&()).await;
12+
}
13+
14+
fn main() {}

src/test/ui/lifetimes/issue-84604.rs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// run-pass
2+
// compile-flags: -Zsymbol-mangling-version=v0
3+
4+
pub fn f<T: ?Sized>() {}
5+
pub trait Frob<T: ?Sized> {}
6+
fn main() {
7+
f::<dyn Frob<str>>();
8+
f::<dyn for<'a> Frob<str>>();
9+
}

0 commit comments

Comments
 (0)