Skip to content
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

Delegate trait impl assist: #[cfg] is not considered when enumerating impls #15198

Closed
pickx opened this issue Jul 2, 2023 · 0 comments · Fixed by #16766
Closed

Delegate trait impl assist: #[cfg] is not considered when enumerating impls #15198

pickx opened this issue Jul 2, 2023 · 0 comments · Fixed by #16766
Labels
A-assists C-bug Category: bug

Comments

@pickx
Copy link

pickx commented Jul 2, 2023

Following #14948, and using @Veykril's example

pub(crate) struct RibStack<R> {
    $0ribs: Vec<R>,
    used: usize,
}

choosing Delegate trait impl for field... and then Generate delegate impl clone::Clone for ribs will generate

impl<T: Clone, A: std::alloc::Allocator + Clone> Clone<T, A> for RibStack {
    fn clone(&self) -> Self {
        <Vec as Clone<T, A>>::clone( &self.ribs )
    }

    fn clone(&self) -> Self {
        <Vec as Clone<T, A>>::clone( &self.ribs )
    }

    fn clone_from(&mut self, other: &Self) {
        <Vec as Clone<T, A>>::clone_from( &mut self.ribs , other)
    }
}

note how clone(&self) is generated twice. I believe this is both this one and this one. It seems that although one is #[cfg(test)] and the other is #[cfg(not(test))], both are chosen.

I'm currently trying to look at how to solve this but I'm new and and would appreciate some guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants