[rustc] ICE: ADT containing no '&mut T' or 'T: Reborrow' fields must only have one lifetime to implement Reborrow
Open
Nobody has claimed this yet.
C-bug
F-min_generic_const_args
F-reborrow
I-ICE
needs-triage
T-compiler
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
The following code:
#![feature(reborrow)]
#![feature(min_adt_const_params, min_generic_const_args, macroless_generic_const_args)]
use std::marker::{CoerceShared, Reborrow};
#[derive(Reborrow, CoerceShared)]
struct S<const X: (u32, u32)>;
fn main() {
let _: S<{ (1, _) }> = S::<{ (1, 2) }>;
}
Resulted in this output:
error[E0802]: `derive(CoerceShared)` requires exactly one `#[coerce_shared(Target)]` attribute
--> /home/fuzz/WorkSpace/fusion-fuzz/output/bugs/rust/PANIC__compiler_rustc_borrowck_src_borrow_set.rs_402__mir_borrowck_/min.rs:4:20
|
4 | #[derive(Reborrow, CoerceShared)]
| ^^^^^^^^^^^^
warning: the feature `min_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /home/fuzz/WorkSpace/fusion-fuzz/output/bugs/rust/PANIC__compiler_rustc_borrowck_src_borrow_set.rs_402__mir_borrowck_/min.rs:2:34
|
2 | #![feature(min_adt_const_params, min_generic_const_args, macroless_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #132980 <https://github.com/rust-lang/rust/issues/132980> for more information
= note: `#[warn(incomplete_features)]` on by default
warning: the feature `macroless_generic_const_args` is incomplete and may not be safe to use and/or cause compiler crashes
--> /home/fuzz/WorkSpace/fusion-fuzz/output/bugs/rust/PANIC__compiler_rustc_borrowck_src_borrow_set.rs_402__mir_borrowck_/min.rs:2:58
|
2 | #![feature(min_adt_const_params, min_generic_const_args, macroless_generic_const_args)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: see issue #159006 <https://github.com/rust-lang/rust/issues/159006> for more information
error: implementing `Reborrow` requires that a single lifetime parameter is passed between source and target
--> /home/fuzz/WorkSpace/fusion-fuzz/output/bugs/rust/PANIC__compiler_rustc_borrowck_src_borrow_set.rs_402__mir_borrowck_/min.rs:4:10
|
4 | #[derive(Reborrow, CoerceShared)]
| ^^^^^^^^
error: internal compiler error: compiler/rustc_borrowck/src/borrow_set.rs:402:17: ADT containing no '&mut T' or 'T: Reborrow' fields must only have one lifetime to implement Reborrow
thread 'rustc' (564576) panicked at compiler/rustc_borrowck/src/borrow_set.rs:402:17:
Box<dyn Any>
stack backtrace:
0: std::panicking::begin_panic::<rustc_errors::ExplicitBug>
at /rustc/f47d5bb13648d5c859f5b438eb7dc834b9729961/library/std/src/panicking.rs:751:5
1: std::panic::panic_any::<rustc_errors::ExplicitBug>
at /rustc/f47d5bb13648d5c859f5b438eb7dc834b9729961/library/std/src/panic.rs:260:5
2: <rustc_errors::diagnostic::BugAbort as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_errors/src/diagnostic.rs:58:9
3: <rustc_errors::diagnostic::Diag<rustc_errors::diagnostic::BugAbort>>::emit
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_errors/src/diagnostic.rs:1319:9
4: <rustc_errors::DiagCtxtHandle>::bug::<alloc::string::String>
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_errors/src/lib.rs:968:30
5: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>::{closure#0}
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_middle/src/util/bug.rs:39:48
6: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_middle/src/ty/context/tls.rs:109:23
7: rustc_middle::ty::context::tls::with_context_opt::<rustc_middle::ty::context::tls::with_opt<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>::{closure#0}, !>
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_middle/src/ty/context/tls.rs:75:18
8: rustc_middle::ty::context::tls::with_opt::<rustc_middle::util::bug::opt_span_bug_fmt<rustc_span::span_encoding::Span>::{closure#0}, !>
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_middle/src/ty/context/tls.rs:107:5
9: rustc_middle::util::bug::opt_span_bug_fmt::<rustc_span::span_encoding::Span>
at /home/fuzz/WorkSpace/fusion-fuzz/projects/rust/rust-src/compiler/rustc_middle/src/util/bug.rs:33:5
... (backtrace truncated)
To reproduce:
rustc ./min.rs
Compiler version:
rustc 1.100.0-dev
Commit:
58ae2c4315128abc40be24b429dfb68bf27510b3
Build configuration:
./x.py build --stage 1 with bootstrap.toml:
rust.debug-assertions = true
rust.overflow-checks = true
llvm.assertions = true
llvm.download-ci-llvm = true
Operating System:
Ubuntu, x86_64-unknown-linux-gnu (Docker image fusionf-fuzz-rust:latest)
This bug was found by fusion-fuzz.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at compiler/rustc_borrowck/src/borrow_set.rs:402, where the internal compiler error is reported, and reproduce it with rustc ./min.rs using the issue's example. Trace how Reborrow derives handle an ADT with const generic parameters and compare the existing diagnostic paths. Done means the reproducer no longer causes an internal compiler error and produces an appropriate compiler result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100