Skip to content

[rustc] ICE: ADT containing no '&mut T' or 'T: Reborrow' fields must only have one lifetime to implement Reborrow #162108

Description

@YuanchengJiang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.F-min_generic_const_args`#![feature(min_generic_const_args)]`F-reborrow`#![feature(reborrow)]`; see #145612I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions