Skip to content

Cannot locate the impl of the trait from nested type parameter. #24972

Closed
@ghost

Description

When I used bound::typeparam as type, thread rustc panicked.

use rustc_serialize::{Encodable, Decodable};
use std::fmt::Display;


pub trait Entity : Decodable + Encodable + Sized {
    type Key: Clone + Decodable + Encodable + ToString + Display + Eq + Ord + Sized;

    fn id(&self) -> Self::Key;

    fn find_by_id(id: Self::Key) -> Option<Self>;
}

pub struct DbRef<E: Entity> {
    pub id: E::Key,
}

impl<E> DbRef<E>
 where E: Entity {
    fn get(self) -> Option<E> {
        E::find_by_id(self.id)
    }
} 

Source code: https://github.com/ceram1/appcore/blob/master/src/db/mod.rs
Build log: https://travis-ci.org/ceram1/appcore/builds/60641835

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-trait-systemArea: Trait systemA-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions