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 on trait aliases without a flag #65673

Closed
wdanilo opened this issue Oct 21, 2019 · 4 comments · Fixed by #66392
Closed

ICE on trait aliases without a flag #65673

wdanilo opened this issue Oct 21, 2019 · 4 comments · Fixed by #66392
Labels
C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@wdanilo
Copy link

wdanilo commented Oct 21, 2019

The following code panics the compiler:

pub struct SharedRange<Ix, OnSet> {
    pub data: f32,
}

trait HasCtx {
    type Ctx;
}

trait Callback0 {}

trait Foo<Ix, OnSet> = where OnSet: Callback0;

impl<Ix, OnSet> HasCtx for SharedRange<Ix, OnSet> {
    type Ctx = Foo<Ix, OnSet>;
}
@memoryruins
Copy link
Contributor

playground

backtrace:

   Compiling playground v0.0.1 (/playground)
error[E0658]: trait aliases are experimental
  --> src/lib.rs:11:1
   |
11 | trait Foo<Ix, OnSet> = where OnSet: Callback0;
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: for more information, see https://github.com/rust-lang/rust/issues/41517
   = help: add `#![feature(trait_alias)]` to the crate attributes to enable

warning: trait objects without an explicit `dyn` are deprecated
  --> src/lib.rs:14:16
   |
14 |     type Ctx = Foo<Ix, OnSet>;
   |                ^^^^^^^^^^^^^^ help: use `dyn`: `dyn Foo<Ix, OnSet>`
   |
   = note: `#[warn(bare_trait_objects)]` on by default

error: internal compiler error: src/librustc_typeck/astconv.rs:1216: trait_ref_to_existential called on <OnSet as Callback0> with non-dummy Self

thread 'rustc' panicked at 'Box<Any>', src/librustc_errors/lib.rs:925:9
stack backtrace:
   0: backtrace::backtrace::libunwind::trace
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/libunwind.rs:88
   1: backtrace::backtrace::trace_unsynchronized
             at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.37/src/backtrace/mod.rs:66
   2: std::sys_common::backtrace::_print_fmt
             at src/libstd/sys_common/backtrace.rs:77
   3: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
             at src/libstd/sys_common/backtrace.rs:61
   4: core::fmt::write
             at src/libcore/fmt/mod.rs:1028
   5: std::io::Write::write_fmt
             at src/libstd/io/mod.rs:1412
   6: std::sys_common::backtrace::_print
             at src/libstd/sys_common/backtrace.rs:65
   7: std::sys_common::backtrace::print
             at src/libstd/sys_common/backtrace.rs:50
   8: std::panicking::default_hook::{{closure}}
             at src/libstd/panicking.rs:189
   9: std::panicking::default_hook
             at src/libstd/panicking.rs:206
  10: rustc_driver::report_ice
  11: std::panicking::rust_panic_with_hook
             at src/libstd/panicking.rs:473
  12: std::panicking::begin_panic
  13: rustc_errors::HandlerInner::bug
  14: rustc_errors::Handler::bug
  15: rustc::util::bug::opt_span_bug_fmt::{{closure}}
  16: rustc::ty::context::tls::with_opt::{{closure}}
  17: rustc::ty::context::tls::with_context_opt
  18: rustc::ty::context::tls::with_opt
  19: rustc::util::bug::opt_span_bug_fmt
  20: rustc::util::bug::bug_fmt
  21: <dyn rustc_typeck::astconv::AstConv>::trait_ref_to_existential
  22: <smallvec::SmallVec<A> as core::iter::traits::collect::FromIterator<<A as smallvec::Array>::Item>>::from_iter
  23: <dyn rustc_typeck::astconv::AstConv>::conv_object_ty_poly_trait_ref
  24: <dyn rustc_typeck::astconv::AstConv>::ast_ty_to_ty
  25: rustc_typeck::collect::checked_type_of
  26: rustc_typeck::collect::type_of
  27: rustc::ty::query::__query_compute::type_of
  28: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::type_of>::compute
  29: rustc::dep_graph::graph::DepGraph::with_task_impl
  30: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  31: <rustc_typeck::collect::CollectItemTypesVisitor as rustc::hir::intravisit::Visitor>::visit_impl_item
  32: rustc::hir::map::Map::visit_item_likes_in_module
  33: rustc_typeck::collect::collect_mod_item_types
  34: rustc::ty::query::__query_compute::collect_mod_item_types
  35: rustc::ty::query::<impl rustc::ty::query::config::QueryAccessors for rustc::ty::query::queries::collect_mod_item_types>::compute
  36: rustc::dep_graph::graph::DepGraph::with_task_impl
  37: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  38: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::ensure_query
  39: rustc_typeck::check_crate::{{closure}}::{{closure}}
  40: rustc::util::common::time
  41: rustc_typeck::check_crate
  42: rustc_interface::passes::analysis
  43: rustc::ty::query::__query_compute::analysis
  44: rustc::dep_graph::graph::DepGraph::with_task_impl
  45: rustc::ty::query::plumbing::<impl rustc::ty::context::TyCtxt>::get_query
  46: rustc_interface::passes::BoxedGlobalCtxt::access::{{closure}}
  47: rustc_interface::passes::create_global_ctxt::{{closure}}
  48: rustc_interface::passes::BoxedGlobalCtxt::enter
  49: rustc_interface::interface::run_compiler_in_existing_thread_pool
  50: std::thread::local::LocalKey<T>::with
  51: scoped_tls::ScopedKey<T>::set
  52: syntax::with_globals
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.40.0-nightly (7979016af 2019-10-20) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type lib

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [type_of] processing `<SharedRange<Ix, OnSet> as HasCtx>::Ctx`
#1 [collect_mod_item_types] collecting item types in top-level module
#2 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `playground`.

To learn more, run the command again with --verbose

rustc 1.40.0-nightly (7979016af 2019-10-20)

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 21, 2019
@estebank
Copy link
Contributor

estebank commented Oct 21, 2019

Likely diagnostic related :-/ Disregard that.

@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Oct 22, 2019
@hellow554
Copy link
Contributor

Slightly reduced:

trait Trait {}
trait WithType {
    type Ctx;
}
trait Alias<T> = where T: Trait;

impl<T> WithType for T {
    type Ctx = dyn Alias<T>;
}

impl<T> WithType for T can also be impl<T> WithType for (), but I though this will remove one more warning, so it's worth using T here ^^

@pnkfelix
Copy link
Member

triage: P-medium. removing nomination label.

reasoning: you get the feature flag diagnostic, including the span of the offending code and the suggestion of what to write. So this is reasonable for users to deal with, even with the ICE. (as opposed to cases where the ICE occurs without any useful output for the user.)

@pnkfelix pnkfelix added P-medium Medium priority and removed I-nominated labels Oct 24, 2019
@Centril Centril added the requires-nightly This issue requires a nightly compiler in some way. label Oct 24, 2019
@estebank estebank removed the requires-nightly This issue requires a nightly compiler in some way. label Nov 14, 2019
@bors bors closed this as completed in ea540b0 Nov 20, 2019
alexreg added a commit to alexreg/rust that referenced this issue Nov 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. F-trait_alias `#![feature(trait_alias)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants