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: Implementing trait with associated constant and &Self bound #88599

Closed
madsmtm opened this issue Sep 2, 2021 · 4 comments · Fixed by #96806
Closed

ICE: Implementing trait with associated constant and &Self bound #88599

madsmtm opened this issue Sep 2, 2021 · 4 comments · Fixed by #96806
Labels
C-bug Category: This is a bug. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@madsmtm
Copy link
Contributor

madsmtm commented Sep 2, 2021

Code

pub trait First {
    const CONST: bool;
}
pub trait Second {}

impl<'a> First for dyn Second where &'a Self: First {
    const CONST: bool = <&Self>::CONST;
}

Playground link.

Meta

Tested on rust 1.54.0 and nightly 2021-08-31.

rustc --version --verbose:

rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-apple-darwin
release: 1.54.0
LLVM version: 12.0.1

Error output

error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<&dyn Second as First>, [])` during codegen
  |
  = note: delayed at compiler/rustc_trait_selection/src/traits/codegen.rs:68:32

error: internal compiler error: ty::ConstKind::Error constructed but no error reported.
  |
  = note: delayed at compiler/rustc_middle/src/ty/consts.rs:183:43

thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1166:13
Backtrace

stack backtrace:
   0: rust_begin_unwind
             at library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at library/std/src/panicking.rs:457:5
   2: rustc_errors::HandlerInner::flush_delayed
   3: <rustc_errors::HandlerInner as core::ops::drop::Drop>::drop
   4: core::ptr::drop_in_place<rustc_session::parse::ParseSess>
   5: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
   6: core::ptr::drop_in_place<rustc_interface::interface::Compiler>
   7: rustc_span::with_source_map
   8: rustc_interface::interface::create_compiler_and_run
   9: scoped_tls::ScopedKey<T>::set

@madsmtm madsmtm 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 Sep 2, 2021
@SNCPlay42
Copy link
Contributor

This version without dyn Trait also ICEs (playground):

pub trait Foo {
    const CONST: bool;
}

impl <'a> Foo for () where &'a Self: Foo {
    const CONST: bool = <&Self>::CONST;
}

@SNCPlay42
Copy link
Contributor

Both versions compile on Rust 1.43.0: godbolt

@rustbot label regression-from-stable-to-stable

@rustbot rustbot added regression-from-stable-to-stable Performance or correctness regression from one stable version to another. I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 2, 2021
@madsmtm madsmtm changed the title ICE: Implementing dyn Trait with Self bound and associated constant ICE: Implementing with &Self bound and associated constant Sep 2, 2021
@madsmtm madsmtm changed the title ICE: Implementing with &Self bound and associated constant ICE: Implementing trait with associated constant and &Self bound Sep 2, 2021
@apiraino
Copy link
Contributor

apiraino commented Sep 4, 2021

probably too old to bisect but it seems introduced in rollup #70371 on nightly-2020-03-26

matthiaskrgr added a commit to matthiaskrgr/glacier that referenced this issue Sep 5, 2021
@rust-lang-glacier-bot rust-lang-glacier-bot added the glacier ICE tracked in rust-lang/glacier. label Sep 5, 2021
@apiraino
Copy link
Contributor

apiraino commented Sep 8, 2021

Assigning priority as discussed in the Zulip thread of the Prioritization Working Group.

@rustbot label -I-prioritize +P-medium

@rustbot rustbot added P-medium Medium priority and removed I-prioritize Issue: Indicates that prioritization has been requested for this issue. labels Sep 8, 2021
@bors bors closed this as completed in cb9cb4d May 12, 2022
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. glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority regression-from-stable-to-stable Performance or correctness regression from one stable version to another. 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.

5 participants