-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
Description
I am finding an ICE when splitting a single binary with #![feature(generic_const_exprs)] into a binary plus a library crate that implements the structs and traits. This only occurs when I fail to add #![feature(generic_const_exprs)] to the binary crate as well. (Am I using the terminology crate correctly? I am still new to the whole rust environment...)
I think it is reasonable to expect the feature to be marked in the binary as well, but I would not expect an ICE when it is left out.
Code
This code compiles correctly as a standalone binary:
#![feature(generic_const_exprs)]
pub trait TraitWithAssocConst {
const SIZE: usize;
}
pub struct Test;
impl TraitWithAssocConst for Test {
const SIZE: usize = 8;
}
pub trait TraitDependingOnAssocConst {
fn dummy<T>(&self, u: &T) -> ()
where T : TraitWithAssocConst,
[(); T::SIZE]: ;
}
pub struct Test2;
impl TraitDependingOnAssocConst for Test2 {
fn dummy<T>(&self, u: &T) -> ()
where T : TraitWithAssocConst,
[(); T::SIZE]:
{
}
}
fn main() -> () {
let t1 = Test;
let t2 = Test2;
t2.dummy(&t1);
}Now I split this into a library crate mylib and a binary depending on it, but fail to include #![feature(generic_const_exprs)] in the binary:
// Binary crate:
// I "forget" to enable the feature here.
// #![feature(generic_const_exprs)]
use mylib::*;
fn main() -> () {
let t1 = Test;
let t2 = Test2;
t2.dummy(&t1);
}// Library crate mylib:
// I do enable the feature here.
#![feature(generic_const_exprs)]
pub trait TraitWithAssocConst {
const SIZE: usize;
}
pub struct Test;
impl TraitWithAssocConst for Test {
const SIZE: usize = 8;
}
pub trait TraitDependingOnAssocConst {
fn dummy<T>(&self, u: &T) -> ()
where T : TraitWithAssocConst,
[(); T::SIZE]: ;
}
pub struct Test2;
impl TraitDependingOnAssocConst for Test2 {
fn dummy<T>(&self, u: &T) -> ()
where T : TraitWithAssocConst,
[(); T::SIZE]:
{
}
}The binary then fails to compile with the ICE trace given below.
Meta
rustc --version --verbose:
rustc 1.57.0-nightly (8c2b6ea37 2021-09-11)
binary: rustc
commit-hash: 8c2b6ea37d7719a0370bd404030eef9702c1752c
commit-date: 2021-09-11
host: x86_64-apple-darwin
release: 1.57.0-nightly
LLVM version: 13.0.0
Error output
Compiling tmp v0.1.0 (/Users/gkanwar/tmp)
warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes
--> src/lib/lib.rs:1:12
|
1 | #![feature(generic_const_exprs)]
| ^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(incomplete_features)]` on by default
= note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information
warning: unused variable: `u`
--> src/lib/lib.rs:20:22
|
20 | fn dummy<T>(&self, u: &T) -> ()
| ^ help: if this is intentional, prefix it with an underscore: `_u`
|
= note: `#[warn(unused_variables)]` on by default
warning: `tmp` (lib) generated 2 warnings
warning: Error finalizing incremental compilation session directory `/Users/gkanwar/tmp/target/debug/incremental/test-1wbxzdr6ui2on/s-g2aqzqcst1-1hgx4sl-working`: No such file or directory (os error 2)
error: internal compiler error: Encountered error `Unimplemented` selecting `Binder(<^0 as mylib::TraitWithAssocConst>, [Ty(Anon)])` 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 /rustc/8c2b6ea37d7719a0370bd404030eef9702c1752c/compiler/rustc_middle/src/ty/consts.rs:183:43
error: internal compiler error: `ErrorReported` without an error
--> src/bin/test.rs:9:6
|
9 | t2.dummy(&t1);
| ^^^^^
|
= note: delayed at compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs:843:31
thread 'rustc' panicked at 'no errors encountered even though `delay_span_bug` issued', compiler/rustc_errors/src/lib.rs:1165:13
stack backtrace:
0: _rust_begin_unwind
1: std::panicking::begin_panic_fmt
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: scoped_tls::ScopedKey<T>::set
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: internal compiler error: unexpected panic
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.57.0-nightly (8c2b6ea37 2021-09-11) running on x86_64-apple-darwin
note: compiler flags: -C embed-bitcode=no -C split-debuginfo=unpacked -C debuginfo=2 -C incremental --crate-type bin
note: some of the compiler flags provided by cargo are hidden
query stack during panic:
end of query stack
warning: `tmp` (bin "test") generated 1 warning
error: could not compile `tmp`; 1 warning emitted