Repository: rust
Issue: Error Message for Trait Use Declaration with Rc<RefCell>
Labels: A-diagnostics,T-compiler

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.

If you cannot produce a minimal reproduction case (something that would work in
isolation), please provide the steps or even link to a repository that causes
the problematic output to occur.
-->

Given the following code: <!-- Please provide a link to play.rust-lang.org -->

```rust
use std::cell::RefCell;
use std::rc::Rc;
use std::borrow::BorrowMut;

type NodeAlias = Option<Rc<RefCell<Node>>>;

#[derive(Clone, Debug, PartialEq)]
struct Node {
    value: String,
    next: NodeAlias,
}

#[derive(Clone, Debug, PartialEq)]
struct TransactionLog {
    head: NodeAlias,
    tail: NodeAlias,
    length: i32,
}

impl Node {
    fn new(value: String) -> Rc<RefCell<Node>> {
        Rc::new(RefCell::new(Node { value, next: None }))
    }
}

impl TransactionLog {
    pub fn empty_list() -> TransactionLog {
        TransactionLog {
            head: None,
            tail: None,
            length: 0,
        }
    }

    pub fn append(&mut self, value: String) {
        let node = Node::new(value);
        match self.tail.take() {
            Some(old_tail) => old_tail.borrow_mut().next = Some(node.clone()),
            None => self.head = Some(node.clone()),
        }
        self.length += 1;
        self.tail = Some(node);
    }
}

```

The current build output is:

```
error[[E0609]](https://doc.rust-lang.org/stable/error-index.html#E0609): no field `next` on type `&mut Rc<RefCell<Node>>`
  --> src/lib.rs:38:53
   |
38 |             Some(old_tail) => old_tail.borrow_mut().next = Some(node.clone()),
   |                                                     ^^^^ unknown field
```

<!-- The following is not always necessary. -->

I received this output because I somehow got my IDE to include the `use std::borrow::BorrowMut;` statement. When that statement is _removed_, the code is able to compile without errors. I'm working off of the book, [Data Structures with Rust from Packt.](https://github.com/PacktPublishing/Hands-On-Data-Structures-and-Algorithms-with-Rust/blob/master/Chapter04/src/singly_linked_list.rs) 

I'm still learning Rust so I don't know if this is necessarily not clear and that a more experienced Rustacean wouldn't recognize what the compiler is trying to tell them here. I was confused because I know the field `next` exists. And I did some manual tests so I knew the compiler also knew the field existed. I use VS Code, and one thing I noticed is that when I hover over `borrow_mut` when the trait is _not_ active,  the type suggests that it's using RefCell's implementation. When the trait is active, it's unclear. I _think_ there's something going on with [how the dot operator works](https://users.rust-lang.org/t/how-to-properly-use-dereferencing-mechanism/55033/2) as well, but since I'm just learning Rc and RefCell usage, it's a bit of a guessing game right now.

All in all, I guessed something was wrong when it seemed like it wasn't using RefCell's implementation, but I would not have thought it was due to a misplaced `use` declaration.

![image](https://user-images.githubusercontent.com/13903071/152717001-50f732b8-b993-4615-bb36-3d32c1cf813d.png)

![image](https://user-images.githubusercontent.com/13903071/152717171-5b2aa21f-c493-4acf-86c5-87a16a02f3b9.png)

This seems to persist between editions and stable/nightly toolchains.

First time submitting these, so open to feedback on how to do better next time as well! Thanks for your hard work -- the error messages have been a joy to work with as I solo learn my way through Rust!


<!--
If the problem is not self-explanatory, please provide a rationale for the
change.
-->

<!--
If dramatically different output is caused by small changes, consider also
adding them here.

If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions. The output might also be
different depending on the Edition.
-->