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 returning generic abitrary self type in defining function for existential associated type #57700

Open
MSleepyPanda opened this Issue Jan 17, 2019 · 7 comments

Comments

Projects
None yet
5 participants
@MSleepyPanda
Copy link

MSleepyPanda commented Jan 17, 2019

#![feature(arbitrary_self_types)]
#![feature(existential_type)]

use std::ops::Deref;

trait Route {
    type Extension: Route;

    fn extend(self: impl Deref<Target = Self>) -> Self::Extension;
}

impl<C> Route for C {
    existential type Extension: Route;

    fn extend(self: impl Deref<Target = Self>) -> Self::Extension {
        self
    }
}

Playground

   Compiling playground v0.0.1 (/playground)
error: internal compiler error: src/librustc/ty/subst.rs:480: Type parameter `impl Deref<Target = Self>/#1` (impl Deref<Target = Self>/1) out of range when substituting (root type=Some(impl Deref<Target = Self>)) substs=[C]

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:526:9
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:39
   1: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:70
   2: std::panicking::default_hook::{{closure}}
             at src/libstd/sys_common/backtrace.rs:58
             at src/libstd/panicking.rs:200
   3: std::panicking::default_hook
             at src/libstd/panicking.rs:215
   4: rustc::util::common::panic_hook
   5: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:482
   6: std::panicking::begin_panic
   7: rustc_errors::Handler::span_bug
   8: rustc::util::bug::opt_span_bug_fmt::{{closure}}
   9: rustc::ty::context::tls::with_opt::{{closure}}
  10: rustc::ty::context::tls::with_context_opt
  11: rustc::ty::context::tls::with_opt
  12: rustc::util::bug::opt_span_bug_fmt
  13: rustc::util::bug::span_bug_fmt
  14: <rustc::ty::subst::SubstFolder<'a, 'gcx, 'tcx> as rustc::ty::fold::TypeFolder<'gcx, 'tcx>>::fold_ty
  15: rustc::infer::InferCtxt::commit_if_ok
  16: <rustc::traits::query::type_op::custom::CustomTypeOp<F, G> as rustc::traits::query::type_op::TypeOp<'gcx, 'tcx>>::fully_perform
  17: rustc_mir::borrow_check::nll::type_check::TypeChecker::eq_opaque_type_and_type
  18: rustc_mir::borrow_check::nll::type_check::type_check
  19: rustc_mir::borrow_check::nll::compute_regions
  20: rustc_mir::borrow_check::do_mir_borrowck
  21: rustc::ty::context::GlobalCtxt::enter_local
  22: rustc_mir::borrow_check::mir_borrowck
  23: rustc::ty::query::__query_compute::mir_borrowck
  24: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors<'tcx> for rustc::ty::query::queries::mir_borrowck<'tcx>>::compute
  25: rustc::dep_graph::graph::DepGraph::with_task_impl
  26: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::try_get_with
  27: rustc::ty::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::par_body_owners
  28: rustc::util::common::time
  29: <std::thread::local::LocalKey<T>>::with
  30: rustc::ty::context::TyCtxt::create_and_enter
  31: rustc_driver::driver::compile_input
  32: rustc_driver::run_compiler_with_pool
  33: <scoped_tls::ScopedKey<T>>::set
  34: rustc_driver::run_compiler
  35: <scoped_tls::ScopedKey<T>>::set
query stack during panic:
#0 [mir_borrowck] processing `<C as Route>::extend`
end of query stack
error: aborting due to previous error

@dlrobertson

This comment has been minimized.

Copy link
Contributor

dlrobertson commented Jan 20, 2019

This doesn't panic on f001287 or nightly for me. Has it been fixed?

@MSleepyPanda

This comment has been minimized.

Copy link
Author

MSleepyPanda commented Jan 20, 2019

Can't confirm currently, because my toolchain is stuck on nightly 2019-01-18, because of the toolstate changes in that PR. On that toolchain, it ICEs. Will try to reproduce on new nightly once available.

@dlrobertson

This comment has been minimized.

Copy link
Contributor

dlrobertson commented Jan 20, 2019

👍 double checked on 0c0c585 and 846ea58. Still no ICE.

@MSleepyPanda

This comment has been minimized.

Copy link
Author

MSleepyPanda commented Jan 21, 2019

@dlrobertson If you run it on the playground, you see that it still ICEs

@dlrobertson

This comment has been minimized.

Copy link
Contributor

dlrobertson commented Jan 21, 2019

@MSleepyPanda Aha! Running rustc +nightly ./src/lib.rs doesn't ICE, but cargo +nightly build does.

EDIT: After some research I realized that in order to reproduce the ICE --edition=2018 must be set or you must use #![feature(nll)].

@Arnavion

This comment has been minimized.

Copy link

Arnavion commented Jan 29, 2019

This is the same as #53598 I believe, since the impl Deref<Target = Self> AST is essentially a trait method type parameter extend<S: Deref<Target = Self>>(self: S) being used to define the trait's assoc type.

@dlrobertson

This comment has been minimized.

Copy link
Contributor

dlrobertson commented Jan 30, 2019

@Arnavion good catch. I agree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment