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

ICE when trying to use associated type's Self::Output as default (nightly/beta) #25339

Closed
Nercury opened this issue May 12, 2015 · 4 comments
Closed
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@Nercury
Copy link
Contributor

Nercury commented May 12, 2015

This kind of code:

use std::marker::PhantomData;

pub trait Routing<I> {
    type Output;

    fn resolve(&self, input: I);
}

pub trait ToRouting {
    type Input;
    type Routing = Routing<Self::Input>;

    fn to_routing(self) -> Self::Routing;
}

pub struct Mount<I, R: Routing<I>> {
    action: R,
    _marker: PhantomData<I>,
}

impl<I, R: Routing<I>> Mount<I, R> {
    pub fn create<T: ToRouting<Routing=R>>(mount: &str, input: T) {
        input.to_routing();
    }
}

fn main() {

}

Produces this output:

thread 'rustc' panicked at 'path not fully resolved: PathResolution { base_def: DefSelfTy(Some(DefId { krate: 0, node: 17 }), None), last_private: LastMod(AllPublic), depth: 1 }', /home/rustbuild/src/rust-buildbot/slave/beta-dist-rustc-linux/build/src/librustc/middle/def.rs:80

stack backtrace:
   1:     0x7fd5f5c01029 - sys::backtrace::write::hf53a0a0304290fee0Yr
   2:     0x7fd5f5c08cf6 - panicking::on_panic::h60c28f18db36901f8lw
   3:     0x7fd5f5bcc132 - rt::unwind::begin_unwind_inner::h5d1eccd17bdb1225i1v
   4:     0x7fd5f5bccddc - rt::unwind::begin_unwind_fmt::hb401ae9bbc90d7afWZv
   5:     0x7fd5f3a45c76 - middle::def::PathResolution::full_def::h1064d7767cb70c52vZl
   6:     0x7fd5f5075e1e - PrivacyVisitor<'a, 'tcx>::check_path::hc1d907c1eeb131a2X4a
   7:     0x7fd5f5076ea7 - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_path::h6d61d703c953fd3cctb
   8:     0x7fd5f5076fbf - visit::walk_path::h11482984534192114005
   9:     0x7fd5f5076d4f - PrivacyVisitor<'a, 'tcx>.Visitor<'v>::visit_item::h869cd287456a54ebxdb
  10:     0x7fd5f507d7cb - check_crate::h8a5c09d7eb2db25cEVb
  11:     0x7fd5f6141d63 - driver::phase_3_run_analysis_passes::h28f3c6bab4d32090nGa
  12:     0x7fd5f6122e05 - driver::compile_input::h5b445b50b3e18d59Qba
  13:     0x7fd5f61e34e1 - run_compiler::h96f97d4eb21ecd2cz4b
  14:     0x7fd5f61e1132 - boxed::F.FnBox<A>::call_box::h9787258653706413210
  15:     0x7fd5f61e0669 - rt::unwind::try::try_fn::h11878141054803929988
  16:     0x7fd5f5c7b518 - rust_try_inner
  17:     0x7fd5f5c7b505 - rust_try
  18:     0x7fd5f61e0918 - boxed::F.FnBox<A>::call_box::h8845320335913257549
  19:     0x7fd5f5c07be1 - sys::thread::create::thread_start::ha7b08762db72e408Zkv
  20:     0x7fd5f04a1181 - start_thread
  21:     0x7fd5f585247c - __clone
  22:                0x0 - <unknown>
rustc 1.0.0-beta.3 (5241bf9c3 2015-04-25) (built 2015-04-25)

Also reproducible on beta.4, nightly, windows/linux.

@Nercury Nercury changed the title ICE when mixing nested associated types and PhantomData ICE when mixing nested associated types and PhantomData (nightly/beta) May 12, 2015
@arielb1
Copy link
Contributor

arielb1 commented May 12, 2015

PhantomData is not needed:

pub trait Routing<I> {}

pub trait ToRouting {
    type Input;
    type Routing = Routing<Self::Input>;
}

fn main() {}

@apasel422
Copy link
Contributor

For what it's worth, defaulted associated types, as in

type Routing = Routing<Self::Input>;

aren't yet supported, and since the return type of to_routing must be Sized, I'm guessing the intended associated type is

type Routing: Routing<Self::Input>;

@Nercury Nercury changed the title ICE when mixing nested associated types and PhantomData (nightly/beta) ICE when trying to use associated type's Self::Output as default (nightly/beta) May 12, 2015
@Nercury
Copy link
Contributor Author

Nercury commented May 12, 2015

@apasel422 I wasn't aware I could do that, thanks!

@quantheory
Copy link
Contributor

Duplicate of #23073, I'm pretty sure.

@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label May 13, 2015
@bors bors closed this as completed in 65a3245 May 28, 2015
XMPPwocky pushed a commit to XMPPwocky/rust that referenced this issue May 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants