Skip to content

ICE: error: internal compiler error: expected use<..> to undercapture in an impl opaque #133425

Closed
@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

use std::fmt::Debug;

trait Foo<Item> {
    fn foo<'a>(&self) -> impl Debug
    where
        Item: 'a;
}

impl<Item, D: Debug + Clone> Foo<Item> for D {
    fn foo<'a>(&'a self) -> impl Debug
    where
        Item: 'a,
    {
    }
}

fn main() {}

original:

//@ check-pass
//@ edition: 2021

use std::fmt::Debug;

trait Foo<Item> {
    fn foo<'a>(&self) -> impl Debug
    where
        Item: 'a;
}

impl<Item, D: Debug + Clone> Foo<Item> for D {
    fn foo<'a>(&'a self) -> impl Debug
    where
        Item: 'a,
    {
        self.clone()
    }
}

fn main() {}

Version information

rustc 1.85.0-nightly (f5d185768 2024-11-24)
binary: rustc
commit-hash: f5d18576856ef45d1e47de79889ae7db9d1afa29
commit-date: 2024-11-24
host: x86_64-unknown-linux-gnu
release: 1.85.0-nightly
LLVM version: 19.1.4

Command:
/home/matthias/.rustup/toolchains/master/bin/rustc

Program output

warning: trait `Foo` is never used
 --> /tmp/icemaker_global_tempdir.fUFfMCUFx12v/rustc_testrunner_tmpdir_reporting.MvQjYfgfeIEJ/mvce.rs:3:7
  |
3 | trait Foo<Item> {
  |       ^^^
  |
  = note: `#[warn(dead_code)]` on by default

warning: 1 warning emitted

note: no errors encountered even though delayed bugs were created

note: those delayed bugs will now be shown as internal compiler errors

error: internal compiler error: expected use<..> to undercapture in an impl opaque
  |
  = note: delayed at compiler/rustc_hir_analysis/src/check/compare_impl_item/refine.rs:427:19 - disabled backtrace

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: please make sure that you have updated to the latest nightly

note: rustc 1.85.0-nightly (f5d185768 2024-11-24) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

Metadata

Metadata

Labels

C-bugCategory: This is a bug.I-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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions