diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index 01bc5cc761ca6..d2e233f67d7bf 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -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); 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>(); +}