Skip to content

Bug in fulfillment_errors.rs when compiling #135410

Closed
@DavideCanton

Description

@DavideCanton

Code

use cgroups_rs;
use nix::mount::{mount, MsFlags};

use std::path::Path;

fn main() {
    mount(None, Path::new("foo"), None, MsFlags::empty(), None).unwrap();
}

Meta

rustc --version --verbose:

rustc 1.84.0 (9fc6b4312 2025-01-07)
binary: rustc
commit-hash: 9fc6b43126469e3858e2fe86cafb4f0fd5068869
commit-date: 2025-01-07
host: x86_64-unknown-linux-gnu
release: 1.84.0
LLVM version: 19.1.5

Error output

thread 'rustc' panicked at compiler/rustc_trait_selection/src/error_reporting/traits/fulfillment_errors.rs:1824:44:
called `Option::unwrap()` on a `None` value
Backtrace

stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_similar_impl_candidates
   5: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_error
   6: <rustc_trait_selection::error_reporting::TypeErrCtxt>::report_fulfillment_errors
   7: rustc_hir_typeck::typeck
      [... omitted 1 frame ...]
   8: <rustc_middle::hir::map::Map>::par_body_owners::<rustc_hir_analysis::check_crate::{closure#4}>::{closure#0}
   9: rustc_hir_analysis::check_crate
  10: rustc_interface::passes::run_required_analyses
  11: rustc_interface::passes::analysis
      [... omitted 1 frame ...]
  12: rustc_interface::interface::run_compiler::<core::result::Result<(), rustc_span::ErrorGuaranteed>, rustc_driver_impl::run_compiler::{closure#0}>::{closure#1}
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

error: 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.84.0 (9fc6b4312 2025-01-07) running on x86_64-unknown-linux-gnu

note: compiler flags: --crate-type bin -C embed-bitcode=no -C debuginfo=2 -C incremental=[REDACTED]

note: some of the compiler flags provided by cargo are hidden

query stack during panic:
#0 [typeck] type-checking `main`
#1 [analysis] running analysis passes on this crate
end of query stack

Content of Cargo.toml

[package]
name = "rustc_bug"
version = "0.1.0"
edition = "2021"

[dependencies]
cgroups-rs = "0.3.4"
nix = { version = "0.29.0", features = ["mount"] }

Additional information

The bug seems related to the use cgroups_rs; line, if I remove it the bug goes away.

Compiling with cargo +nightly build works fine.

Please note that the code does not actually compile, with the following patch it does compile without panics.

-    mount(None, Path::new("foo"), None, MsFlags::empty(), None).unwrap();
+    mount::<Path, Path, Path, Path>(None, Path::new("foo"), None, MsFlags::empty(), None).unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️P-mediumMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.WG-diagnosticsWorking group: Diagnosticsregression-from-stable-to-stablePerformance or correctness regression from one stable version to another.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions