Skip to content

[ICE]: Res::Err but no error emitted #154427

@matthiaskrgr

Description

@matthiaskrgr

auto-reduced (treereduce-rust):

#![feature(fn_delegation)]


trait Trait {
    fn foo() {}
}

struct F;

struct S(F);

pub mod to_reuse {
    use crate::F;

    pub fn foo(_: &F) {}
}

impl Trait for S {
    
    
    reuse to_reuse::foo { self.0 }
    
}

fn main() {}

original:

#![feature(fn_delegation)]
#![allow(incomplete_features)]

trait Trait {
    fn foo() {}
}

struct F;
impl Trait for F {}
struct S(F);

pub mod to_reuse {
    use crate::F;

    pub fn foo(_: &F) {}
}

impl Trait for S {
    // Make sure that the method call is not generated if the path resolution
    // does not have a `self` parameter.
    reuse to_reuse::foo { self.0 }
    //~^ ERROR mismatched types
}

fn main() {}

Version information

rustc 1.96.0-nightly (3a933e5bf 2026-03-26)
binary: rustc
commit-hash: 3a933e5bf5b695faf9e09d47a263a20c6b85c26a
commit-date: 2026-03-26
host: x86_64-unknown-linux-gnu
release: 1.96.0-nightly
LLVM version: 22.1.2

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

Program output

warning: the feature `fn_delegation` is incomplete and may not be safe to use and/or cause compiler crashes
 --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:1:12
  |
1 | #![feature(fn_delegation)]
  |            ^^^^^^^^^^^^^
  |
  = note: see issue #118212 <https://github.com/rust-lang/rust/issues/118212> for more information
  = note: `#[warn(incomplete_features)]` on by default

warning: type `F` is more private than the item `foo`
  --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:15:5
   |
15 |     pub fn foo(_: &F) {}
   |     ^^^^^^^^^^^^^^^^^ function `foo` is reachable at visibility `pub`
   |
note: but type `F` is only usable at visibility `pub(crate)`
  --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:8:1
   |
 8 | struct F;
   | ^^^^^^^^
   = note: `#[warn(private_interfaces)]` on by default

warning: trait `Trait` is never used
 --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:4:7
  |
4 | trait Trait {
  |       ^^^^^
  |
  = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default

warning: struct `S` is never constructed
  --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:10:8
   |
10 | struct S(F);
   |        ^

warning: 4 warnings 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: `Res::Err` but no error emitted
  --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:21:27
   |
21 |     reuse to_reuse::foo { self.0 }
   |                           ^^^^
   |
note: delayed at /rustc-dev/3a933e5bf5b695faf9e09d47a263a20c6b85c26a/compiler/rustc_hir_typeck/src/expr.rs:607:32
         0: <rustc_errors::DiagCtxtInner>::emit_diagnostic
         1: <rustc_errors::DiagCtxtHandle>::emit_diagnostic
         2: <rustc_span::ErrorGuaranteed as rustc_errors::diagnostic::EmissionGuarantee>::emit_producing_guarantee
         3: <rustc_errors::DiagCtxtHandle>::span_delayed_bug::<rustc_span::span_encoding::Span, &str>
         4: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_path
         5: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         6: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_field
         7: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
         8: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_call
         9: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        10: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_block
        11: <rustc_hir_typeck::fn_ctxt::FnCtxt>::check_expr_with_expectation_and_args
        12: rustc_hir_typeck::check::check_fn
        13: rustc_hir_typeck::typeck_with_inspect::{closure#0}
        14: rustc_query_impl::query_impl::typeck::invoke_provider_fn::__rust_begin_short_backtrace
        15: rustc_query_impl::execution::try_execute_query::<rustc_data_structures::vec_cache::VecCache<rustc_span::def_id::LocalDefId, rustc_middle::query::erase::ErasedData<[u8; 8]>, rustc_middle::dep_graph::graph::DepNodeIndex>, false>
        16: rustc_query_impl::query_impl::typeck::execute_query_non_incr::__rust_end_short_backtrace
        17: <rustc_middle::ty::context::TyCtxt>::par_hir_body_owners::<rustc_hir_analysis::check_crate::{closure#2}>::{closure#0}
        18: rustc_hir_analysis::check_crate
        19: rustc_interface::passes::analysis
        20: rustc_query_impl::execution::try_execute_query::<rustc_middle::query::caches::SingleCache<rustc_middle::query::erase::ErasedData<[u8; 0]>>, false>
        21: rustc_query_impl::query_impl::analysis::execute_query_non_incr::__rust_end_short_backtrace
        22: rustc_interface::interface::run_compiler::<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
        23: std::sys::backtrace::__rust_begin_short_backtrace::<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>
        24: <std::thread::lifecycle::spawn_unchecked<rustc_interface::util::run_in_thread_with_globals<rustc_interface::util::run_in_thread_pool_with_globals<rustc_interface::interface::run_compiler<(), rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}, ()>::{closure#0}, ()>::{closure#0}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
        25: <std::sys::thread::unix::Thread>::new::thread_start
        26: <unknown>
        27: <unknown>
      
  --> /tmp/icemaker_global_tempdir.SVG4mvy25BsW/rustc_testrunner_tmpdir_reporting.1sncUFN3bGCd/mvce.rs:21:27
   |
21 |     reuse to_reuse::foo { self.0 }
   |                           ^^^^

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.96.0-nightly (3a933e5bf 2026-03-26) running on x86_64-unknown-linux-gnu

query stack during panic:
end of query stack

@rustbot label +F-fn_delegation

Metadata

Metadata

Assignees

Labels

C-bugCategory: This is a bug.F-fn_delegation`#![feature(fn_delegation)]`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.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions