Rustdoc async method definition is more complicated than source

⚓ Rust    📅 2025-12-08    👤 surdeus    👁️ 1      

surdeus

Overview

While exploring the SeaORM crate, I noticed that the MigrationTrait definition generated by rustdoc is far more complicated than the type definition in the module's lib.rs. Namely, rustdoc appears to have added lifetimes and wrapped the return type in a Pin<Box<dyn Future<>>> in lieu of the async keyword.

Issue

Where this poses a direct concern for me is rust-analyzer quick-fix actions appear to utilize the generated docs rather than the source code. Thus, when I use the Implement missing members quick-fix action in VSCode, it generates the verbose definition found on docs.rs rather than the more streamlined one in the module's actual lib.rs file.

Starting State

use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

impl MigrationTrait for Migration {
    
}

Then, run the rust-analyzer Quick Fix: Implement missing members...

Desired Result

use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

impl MigrationTrait for Migration {
    #[doc = " Define actions to perform when applying the migration"]
    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
        todo!()
    }
}

Actual Result

use sea_orm_migration::prelude::*;

#[derive(DeriveMigrationName)]
pub struct Migration;

impl MigrationTrait for Migration {
    #[doc = " Define actions to perform when applying the migration"]
    #[must_use]
    #[allow(
        elided_named_lifetimes,
        clippy::type_complexity,
        clippy::type_repetition_in_bounds
    )]
    fn up<'life0, 'life1, 'async_trait>(
        &'life0 self,
        manager: &'life1 SchemaManager,
    ) -> ::core::pin::Pin<
        Box<
            dyn ::core::future::Future<Output = Result<(), DbErr>>
                + ::core::marker::Send
                + 'async_trait,
        >,
    >
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait,
    {
        todo!()
    }
}

Questions

This leads me to two questions:

  1. What is causing this additional information to be added, and is it intentional?
  2. Is there a way around this as far as the rust-analyzer quick fix is concerned?

Related Topics

2 posts - 2 participants

Read full topic

🏷️ Rust_feed