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

[nightly] ICE when using GATs with const generics #75415

Closed
Tracked by #44265
svenknobloch opened this issue Aug 11, 2020 · 2 comments · Fixed by #81911
Closed
Tracked by #44265

[nightly] ICE when using GATs with const generics #75415

svenknobloch opened this issue Aug 11, 2020 · 2 comments · Fixed by #81911
Assignees
Labels
A-const-generics Area: const generics (parameters and arguments) A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

@svenknobloch
Copy link

svenknobloch commented Aug 11, 2020

playground

Code

#![allow(incomplete_features)]
#![feature(generic_associated_types)]
#![feature(const_generics)]

pub trait Buffer<const T: usize> {}

pub trait Device {
    type Buffer<const T: usize>: Buffer<{ T }>;

    fn create_buffer<const T: usize>(&self) -> Option<Self::Buffer<{ T }>>;
}

fn main() {}

Meta

rustc --version --verbose:

rustc 1.47.0-nightly (6c8927b0c 2020-07-26)
binary: rustc
commit-hash: 6c8927b0cf80ceee19386026cf9d7fd4fd9d486f
commit-date: 2020-07-26
host: x86_64-apple-darwin
release: 1.47.0-nightly
LLVM version: 10.0

Error output

error: internal compiler error: src/librustc_typeck/collect/type_of.rs:82:26: unexpected const parent path Ty(Ty { hir_id: HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 8 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 10 }, kind: Path(Resolved(None, Path { span: src/main.rs:10:55: 10:74 (#0), res: SelfTy(Some(DefId(0:5 ~ playground[a09e]::Device[0])), None), segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 9 }), res: Some(SelfTy(Some(DefId(0:5 ~ playground[a09e]::Device[0])), None)), args: None, infer_args: false }] })), span: src/main.rs:10:55: 10:74 (#0) }, PathSegment { ident: Buffer#0, hir_id: Some(HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 16 }), res: Some(Err), args: Some(GenericArgs { args: [Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 11 }, body: BodyId { hir_id: HirId { owner: DefId(0:9 ~ playground[a09e]::Device[0]::create_buffer[0]), local_id: 15 } } }, span: src/main.rs:10:68: 10:73 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), span: src/main.rs:10:55: 10:74 (#0) }
Backtrace

error: internal compiler error: src/librustc_typeck/collect/type_of.rs:82:26: unexpected const parent path Ty(Ty { hir_id: HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 13 }, kind: Path(TypeRelative(Ty { hir_id: HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 15 }, kind: Path(Resolved(None, Path { span: gfx/src/device.rs:15:66: 15:91 (#0), res: SelfTy(Some(DefId(0:30 ~ gfx[85a5]::device[0]::Device[0])), None), segments: [PathSegment { ident: Self#0, hir_id: Some(HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 14 }), res: Some(SelfTy(Some(DefId(0:30 ~ gfx[85a5]::device[0]::Device[0])), None)), args: None, infer_args: false }] })), span: gfx/src/device.rs:15:66: 15:91 (#0) }, PathSegment { ident: Buffer#0, hir_id: Some(HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 23 }), res: Some(Err), args: Some(GenericArgs { args: [Type(Ty { hir_id: HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 16 }, kind: Path(Resolved(None, Path { span: gfx/src/device.rs:15:79: 15:80 (#0), res: Def(TyParam, DefId(0:38 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]::T[0])), segments: [PathSegment { ident: T#0, hir_id: Some(HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 17 }), res: Some(Def(TyParam, DefId(0:38 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]::T[0]))), args: None, infer_args: false }] })), span: gfx/src/device.rs:15:79: 15:80 (#0) }), Const(ConstArg { value: AnonConst { hir_id: HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 18 }, body: BodyId { hir_id: HirId { owner: DefId(0:37 ~ gfx[85a5]::device[0]::Device[0]::create_buffer[0]), local_id: 22 } } }, span: gfx/src/device.rs:15:82: 15:90 (#0) })], bindings: [], parenthesized: false }), infer_args: false })), span: gfx/src/device.rs:15:66: 15:91 (#0) })

thread 'rustc' panicked at 'Box<Any>', /rustc/6c8927b0cf80ceee19386026cf9d7fd4fd9d486f/src/libstd/macros.rs:13:23
stack backtrace:
   0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
   1: core::fmt::write
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: rustc_driver::report_ice
   6: std::panicking::rust_panic_with_hook
   7: std::panicking::begin_panic
   8: rustc_errors::HandlerInner::span_bug
   9: rustc_errors::Handler::span_bug
  10: rustc_middle::util::bug::opt_span_bug_fmt::{{closure}}
  11: rustc_middle::ty::context::tls::with_opt::{{closure}}
  12: rustc_middle::ty::context::tls::with_opt
  13: rustc_middle::util::bug::opt_span_bug_fmt
  14: rustc_middle::util::bug::span_bug_fmt
  15: rustc_typeck::collect::type_of::opt_const_param_of
  16: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::opt_const_param_of>::compute
  17: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  18: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  19: rustc_data_structures::stack::ensure_sufficient_stack
  20: rustc_query_system::query::plumbing::get_query_impl
  21: rustc_typeck::check::typeck
  22: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck>::compute
  23: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  24: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  25: rustc_data_structures::stack::ensure_sufficient_stack
  26: rustc_query_system::query::plumbing::get_query_impl
  27: rustc_query_system::query::plumbing::ensure_query_impl
  28: rustc_typeck::check::typeck_item_bodies
  29: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::typeck_item_bodies>::compute
  30: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  31: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  32: rustc_data_structures::stack::ensure_sufficient_stack
  33: rustc_query_system::query::plumbing::get_query_impl
  34: rustc_typeck::check_crate
  35: rustc_interface::passes::analysis
  36: rustc_middle::ty::query::<impl rustc_query_system::query::config::QueryAccessors<rustc_middle::ty::context::TyCtxt> for rustc_middle::ty::query::queries::analysis>::compute
  37: rustc_middle::dep_graph::<impl rustc_query_system::dep_graph::DepKind for rustc_middle::dep_graph::dep_node::DepKind>::with_deps
  38: rustc_query_system::dep_graph::graph::DepGraph<K>::with_task_impl
  39: rustc_query_system::query::plumbing::get_query_impl
  40: rustc_middle::ty::context::tls::enter_global
  41: rustc_interface::queries::<impl rustc_interface::interface::Compiler>::enter
  42: rustc_span::with_source_map
  43: rustc_interface::interface::create_compiler_and_run
  44: scoped_tls::ScopedKey<T>::set
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/issues/new?labels=C-bug%2C+I-ICE%2C+T-compiler&template=ice.md

note: rustc 1.47.0-nightly (6c8927b0c 2020-07-26) running on x86_64-apple-darwin

note: compiler flags: -C embed-bitcode=no -C debuginfo=2 -C incremental --crate-type lib

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

query stack during panic:
#0 [opt_const_param_of] computing the optional const parameter of `device::Device::create_buffer::{{constant}}#0`
#1 [typeck] type-checking `device::Device::create_buffer::{{constant}}#0`
#2 [typeck_item_bodies] type-checking all item bodies
#3 [analysis] running analysis passes on this crate
end of query stack
error: aborting due to previous error

@svenknobloch svenknobloch added C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 11, 2020
@svenknobloch svenknobloch changed the title ICE when using GATs with const generics [nightly] ICE when using GATs with const generics Aug 11, 2020
@jonas-schievink jonas-schievink added A-const-generics Area: const generics (parameters and arguments) F-const_generics `#![feature(const_generics)]` F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs requires-nightly This issue requires a nightly compiler in some way. labels Aug 11, 2020
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Aug 14, 2020
@matthewjasper matthewjasper removed the F-const_generics `#![feature(const_generics)]` label Feb 6, 2021
@matthewjasper
Copy link
Contributor

This no longer needs feature(const_generics) since min_const_generics has been stabilized. cc @lcnr

@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 6, 2021

@rustbot claim

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 11, 2021
…komatsakis

GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes rust-lang#75415
Fixes rust-lang#79666
cc `@lcnr`

I've absolutely no idea who to r?  for this...
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue Feb 12, 2021
…komatsakis

GAT/const_generics: Allow with_opt_const_param to return GAT param def_id

Fixes rust-lang#75415
Fixes rust-lang#79666
cc ``@lcnr``

I've absolutely no idea who to r?  for this...
@bors bors closed this as completed in b67be3a Feb 13, 2021
@fmease fmease added the A-GATs Area: Generic associated types (GATs) label Nov 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-generics Area: const generics (parameters and arguments) A-GATs Area: Generic associated types (GATs) C-bug Category: This is a bug. F-generic_associated_types `#![feature(generic_associated_types)]` a.k.a. GATs glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants