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

Closed
matprec opened this issue Jan 17, 2019 · 11 comments
Assignees
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-NLL Area: Non Lexical Lifetimes (NLL) A-typesystem Area: The type system C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-arbitrary_self_types `#![feature(arbitrary_self_types)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ NLL-complete Working towards the "valid code works" goal P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matprec
Copy link
Contributor

matprec 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

@Centril Centril added A-typesystem Area: The type system I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. labels Jan 17, 2019
@dlrobertson
Copy link
Contributor

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

@matprec
Copy link
Contributor Author

matprec 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
Copy link
Contributor

dlrobertson commented Jan 20, 2019

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

@matprec
Copy link
Contributor Author

matprec commented Jan 21, 2019

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

@dlrobertson
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)].

@oli-obk oli-obk added A-NLL Area: Non Lexical Lifetimes (NLL) NLL-complete Working towards the "valid code works" goal labels Jan 25, 2019
@Arnavion
Copy link

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
Copy link
Contributor

@Arnavion good catch. I agree.

@pnkfelix
Copy link
Member

pnkfelix commented Mar 6, 2019

NLL triage. P-high, assigning to self for initial investigation.

@pnkfelix pnkfelix added the P-high High priority label Mar 6, 2019
@pnkfelix pnkfelix self-assigned this Mar 6, 2019
@pnkfelix
Copy link
Member

pnkfelix commented May 3, 2019

downgrading to P-medium under same reasoning as given in #53598

@pnkfelix pnkfelix added P-medium Medium priority and removed P-high High priority labels May 3, 2019
@Centril Centril added F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` F-arbitrary_self_types `#![feature(arbitrary_self_types)]` requires-nightly This issue requires a nightly compiler in some way. labels Jul 28, 2019
@Aaron1011
Copy link
Member

This now produces an error instead of an ICE on the latest nightly.

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 6, 2019
@adamAndMath
Copy link
Contributor

Fixing the compile error makes it compile successfully.
Playground

@Centril Centril added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Aug 10, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 12, 2019
bors added a commit that referenced this issue Aug 12, 2019
Rollup of 10 pull requests

Successful merges:

 - #62108 (Use sharded maps for queries)
 - #63297 (Improve pointer offset method docs)
 - #63306 (Adapt AddRetag for shallow retagging)
 - #63406 (Suggest using a qualified path in patterns with inconsistent bindings)
 - #63431 (Revert "Simplify MIR generation for logical ops")
 - #63449 (resolve: Remove remaining special cases from built-in macros)
 - #63461 (docs: add stdlib env::var(_os) panic)
 - #63473 (Regression test for #56870)
 - #63474 (Add tests for issue #53598 and #57700)
 - #63480 (Fixes #63477)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this issue Aug 12, 2019
bors added a commit that referenced this issue Aug 12, 2019
Rollup of 9 pull requests

Successful merges:

 - #62108 (Use sharded maps for queries)
 - #63297 (Improve pointer offset method docs)
 - #63406 (Suggest using a qualified path in patterns with inconsistent bindings)
 - #63431 (Revert "Simplify MIR generation for logical ops")
 - #63449 (resolve: Remove remaining special cases from built-in macros)
 - #63461 (docs: add stdlib env::var(_os) panic)
 - #63473 (Regression test for #56870)
 - #63474 (Add tests for issue #53598 and #57700)
 - #63480 (Fixes #63477)

Failed merges:

r? @ghost
@Centril Centril closed this as completed Aug 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-impl-trait Area: impl Trait. Universally / existentially quantified anonymous types with static dispatch. A-NLL Area: Non Lexical Lifetimes (NLL) A-typesystem Area: The type system C-bug Category: This is a bug. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-arbitrary_self_types `#![feature(arbitrary_self_types)]` F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ NLL-complete Working towards the "valid code works" goal P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

No branches or pull requests

9 participants