Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Why Deref/DerefMut without forward bounds T as Deref/DerefMut #114

Closed
kgv opened this issue Jan 16, 2020 · 3 comments
Closed

Why Deref/DerefMut without forward bounds T as Deref/DerefMut #114

kgv opened this issue Jan 16, 2020 · 3 comments
Milestone

Comments

@kgv
Copy link

kgv commented Jan 16, 2020

Hi.
This code:

#[derive(Deref, DerefMut)]
pub struct Has<T>(T)
where
    T: Clone + Send + Sync + 'static;

Expands to:

impl <T: ::core::ops::Deref> ::core::ops::Deref for Has<T> where T: Clone +
 Send + Sync + 'static {
    type
    Target
    =
    T;
    #[inline]
    fn deref(&self) -> &Self::Target { &self.0 }
}
impl <T: ::core::ops::DerefMut> ::core::ops::DerefMut for Has<T> where
 T: Clone + Send + Sync + 'static {
    #[inline]
    fn deref_mut(&mut self) -> &mut Self::Target { &mut self.0 }
}

But T need not be bounded ::core::ops::Deref.

@JelteF
Copy link
Owner

JelteF commented Jan 16, 2020

I don't understand what the problem is. Could you show the code that you would expect?

@kgv
Copy link
Author

kgv commented Jan 16, 2020

@JelteF
Change from impl <T: ::core::ops::Deref> to impl <T>

Expected:

impl <T> ::core::ops::Deref for Has<T>
where T: Clone + Send + Sync + 'static {
    type Target = T;
    #[inline]
    fn deref(&self) -> &Self::Target { &self.0 }
}

@JelteF JelteF added this to the 1.0.0 milestone Jan 16, 2020
@JelteF
Copy link
Owner

JelteF commented Jan 16, 2020

That seems like a bug indeed then. A PR would be much appreciated.

@JelteF JelteF closed this as completed in ca056fb Feb 19, 2020
zydou pushed a commit to zydou/arti that referenced this issue Nov 3, 2022
0.99.[012] have a bug JelteF/derive_more#114
which makes the Deref derive for bridgedesc::StateGuard not work
and therefore breaks minimal-versions CI.

It seems simpler to require the newer version everywhere.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants