Skip to content

BorrowMut can cause confusion with Rc<RefCell<X>> #39232

Closed
@mitsuhiko

Description

@mitsuhiko

When BorrowMut is in scope and one has a rc: Rc<RefCell<X>> a call to rc.borrow_mut() does not deref into the inner RefCell but uses the generic call returning a &mut Rc<...>.

Something like this:

   = note: expected type `&mut std::rc::Rc<std::cell::RefCell<X>>`
   = note:    found type `std::option::Option<_>`

The compiler should ideally give feedback that the trait was used instead of the deref and how to fix this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.D-newcomer-roadblockDiagnostics: Confusing error or lint; hard to understand for new users.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