Skip to content

Commit

Permalink
Rollup merge of rust-lang#84653 - jackh726:erase-flags, r=nikomatsakis
Browse files Browse the repository at this point in the history
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```
  • Loading branch information
Dylan-DPC authored Apr 29, 2021
2 parents d9f48d1 + c9fbaa6 commit a3abe4f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_middle/src/ty/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ impl FlagComputation {
{
let mut computation = FlagComputation::new();

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

f(&mut computation, value.skip_binder());

self.add_flags(computation.flags);
Expand Down
14 changes: 14 additions & 0 deletions src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// build-pass
// compile-flags: --edition 2018
// compile-flags: --crate-type rlib

use std::future::Future;

async fn handle<F>(slf: &F)
where
F: Fn(&()) -> Box<dyn for<'a> Future<Output = ()> + Unpin>,
{
(slf)(&()).await;
}

fn main() {}
9 changes: 9 additions & 0 deletions src/test/ui/lifetimes/issue-84604.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-pass
// compile-flags: -Zsymbol-mangling-version=v0

pub fn f<T: ?Sized>() {}
pub trait Frob<T: ?Sized> {}
fn main() {
f::<dyn Frob<str>>();
f::<dyn for<'a> Frob<str>>();
}

0 comments on commit a3abe4f

Please sign in to comment.