Skip to content

Compiler panic when trying to lock inner of Mutex #54062

Closed
@chrisduerr

Description

@chrisduerr

I've encountered a panic after refactoring my program and trying to compile in an incomplete state.

This is the error I've got:

   Compiling playground v0.0.1 (file:///playground)
error[E0616]: field `inner` of struct `std::sync::Mutex` is private
  --> src/main.rs:10:13
   |
10 |     let _ = test.comps.inner.lock().unwrap();
   |             ^^^^^^^^^^^^^^^^

error: internal compiler error: librustc/middle/stability.rs:708: encountered unmarked API: DefId(1/0:4014 ~ std[8250]::sys_common[0]::mutex[0]::{{impl}}[1]::lock[0])
  --> src/main.rs:10:30
   |
10 |     let _ = test.comps.inner.lock().unwrap();
   |                              ^^^^

thread 'main' panicked at 'Box<Any>', librustc_errors/lib.rs:499:9
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: aborting due to 2 previous errors

For more information about this error, try `rustc --explain E0616`.

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.28.0 (9634041f0 2018-07-30) running on x86_64-unknown-linux-gnu

note: compiler flags: -C codegen-units=1 -C debuginfo=2 --crate-type bin

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

error: Could not compile `playground`.

To learn more, run the command again with --verbose.

This is the minimal code example for reproduction:

use std::sync::Mutex;

struct Test {
    comps: Mutex<String>,
}

fn main() {}

fn testing(test: Test) {
    let _ = test.comps.inner.lock().unwrap();
}

playground

I've looked at a few other issues and haven't found anything similar, so hopefully this is not a duplicate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-stabilityArea: `#[stable]`, `#[unstable]` etc.C-bugCategory: This is a bug.E-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.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