Rust Analyzer bugs out on some types involving the abi-stable crate

The abi-stable crate can generate structs (or a type alias for some other type, I'm not sure) for a given trait that represent a ffi-safe trait object (TO) implementing that trait. (This happens through the macro #[sabi_trait]).

The problem is, if i create a wrapper struct generic over a type parameter T (Wrapper<T>) and specialize it with one of the generated trait objects as T, rust analyzer stops working on variables of that type (Wrapper<TO>), it doesn't display methods on auto-completion nor recognize them and doesn't recognize any types resulting from the variable either, listing them as {unknown}.

The code still compiles. Here is some code that has this problem:

use abi_stable::{sabi_trait, StableAbi, std_types::RBox};

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////

struct Wrapper<T: StableAbi> {
    _marker: std::marker::PhantomData<T>,
}

impl<T: StableAbi> Wrapper<T> {
    /// I have docs.
    fn do_smt_1(&self) {
        println!("Wrapper did something!");
    }

    /// I do too.
    fn do_smt_2(&self) -> usize {
        8888
    }
}

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////

#[sabi_trait]
trait TraitINT: 'static {
    fn placehold(&self) -> u32;
}

type TraitTO = TraitINT_TO<RBox<()>>;
type WTraitTO = Wrapper<TraitTO>; // Wrapper has type param 'TraitINT_TO'.

//////////////////////////////////////////////////////
//////////////////////////////////////////////////////

fn faulty(wrapper: WTraitTO) { // Wrapper isn't fully recognized.
    wrapper.do_smt_1(); // No autocompletion or information on hover.

    let result = wrapper.do_smt_2(); // result is {unknown}.
    println!("result was: {result}");
}

fn main() { // Still compiles.
    let wrapper = WTraitTO {
        _marker: std::marker::PhantomData,
    };

    faulty(wrapper);
}

Does anybody know what the problem is? I've checked rust analyzer's issues on its repository but I'm not sure any of them are related, and abi-stable is too complicated for me to understand.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.