From 31ae3b2bdb9376b749fc1d64b531e86806e03c73 Mon Sep 17 00:00:00 2001 From: Jack Huey Date: Wed, 28 Apr 2021 10:18:52 -0400 Subject: [PATCH 1/2] Add HAS_RE_LATE_BOUND if there are bound vars --- compiler/rustc_middle/src/ty/flags.rs | 4 ++++ .../ui/lifetimes/issue-83737-erasing-bound-vars.rs | 14 ++++++++++++++ src/test/ui/lifetimes/issue-84604.rs | 9 +++++++++ 3 files changed, 27 insertions(+) create mode 100644 src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs create mode 100644 src/test/ui/lifetimes/issue-84604.rs diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 01bc5cc761ca6..92288c8982744 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -59,6 +59,10 @@ impl FlagComputation { { let mut computation = FlagComputation::new(); + 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); diff --git a/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs new file mode 100644 index 0000000000000..c496a3556c84e --- /dev/null +++ b/src/test/ui/lifetimes/issue-83737-erasing-bound-vars.rs @@ -0,0 +1,14 @@ +// build-pass +// compile-flags: --edition 2018 +// compile-flags: --crate-type rlib + +use std::future::Future; + +async fn handle(slf: &F) +where + F: Fn(&()) -> Box Future + Unpin>, +{ + (slf)(&()).await; +} + +fn main() {} diff --git a/src/test/ui/lifetimes/issue-84604.rs b/src/test/ui/lifetimes/issue-84604.rs new file mode 100644 index 0000000000000..df8368da0a09a --- /dev/null +++ b/src/test/ui/lifetimes/issue-84604.rs @@ -0,0 +1,9 @@ +// run-pass +// compile-flags: -Zsymbol-mangling-version=v0 + +pub fn f() {} +pub trait Frob {} +fn main() { + f::>(); + f:: Frob>(); +} From c9fbaa6a9f68c74608324cc01e5985d9635cb021 Mon Sep 17 00:00:00 2001 From: Jack Huey <31162821+jackh726@users.noreply.github.com> Date: Wed, 28 Apr 2021 15:51:54 -0400 Subject: [PATCH 2/2] Add a comment --- compiler/rustc_middle/src/ty/flags.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 92288c8982744..d2e233f67d7bf 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -59,6 +59,9 @@ 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; }