-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustdoc shows anonymous elided lifetimes in async fn signature #63037
Comments
I agree that this makes some function signatures unnecessarily verbose. For example: pub async fn identifiers(&self, context: &impl Context) -> impl Iterator<&Identifier> ... becomes ... pub async fn identifiers<'_, '_, '_>(&'_ self, context: &'_ impl Context) -> impl Iterator<&'_ Identifier> However, given the nuances of async functions (specifically: the referenced values must survive every state of the FSM), one could argue that showing these lifetimes in the docs might be useful(?). It's obviously not the worst problem on earth, but could someone at least shed some light on whether this behaviour is intended or not? Is this a feature or a bug? Maybe @GuillaumeGomez? |
I think it's the expected behaviour. However we can discuss about removing the elided lifetimes. In this case it's not really useful... |
It's especially visually disruptive with a |
We have several instances of |
So I don't forget, I got halfway through debugging this on Zulip and it has something to do with 'in band lifetimes': 749349f. Naively changing this to use the same mechanism as |
Funnily enough, this does work with 1.34 if you add enough #![feature(async_await)]
#![feature(futures_api)]
pub async fn asynchronous(foo: &str) -> String {
format!("{}{}", foo, bar)
}
pub fn not_asynchronous(foo: &str) -> String {
format!("{}{}", foo, bar)
} So in some sense this is a regression, although you needed nightly to use |
When run on an
async fn
with elided lifetimes,rustdoc
generates documentation containing the anonymous elided lifetimes in the function's signature. Runningrustdoc
on the blocking variant of the same function produces a correct signature.You can reproduce this issue by generating docs for the following code:
The asynchronous function's docs show the elided lifetimes, the blocking function's docs don't:
Meta
rustdoc --version --verbose
:The text was updated successfully, but these errors were encountered: