title: type annotations needed for `&Borrowed`
body: <p>I am trying to compile the LeetCode question 98's rust code in <a href="https://rustgym.com/leetcode/98" rel="nofollow noreferrer">https://rustgym.com/leetcode/98</a>
  However, I receive an error in this line: <code>let node = node.borrow();</code>:</p>
  <pre class="lang-none prettyprint-override"><code>type annotations needed for `&amp;Borrowed`
  type must be known at this point
  rustcE0282
  s0098_validate_binary_search_tree.rs(66, 17): consider giving `node` the explicit type `&amp;Borrowed`, where the type parameter `Borrowed` is specified
  </code></pre>
  <p>However, Leetcode has no problem to compile it. Here is the Code.</p>
  <pre><code>use std::rc::Rc;
  use std::cell::RefCell;
  type TreeLink = Option&lt;Rc&lt;RefCell&lt;TreeNode&gt;&gt;&gt;;
  trait Inorder {
      fn inorder(&amp;self, visit: &amp;mut dyn FnMut(i32));
  }
  impl Inorder for TreeLink {
      fn inorder(&amp;self, visit: &amp;mut dyn FnMut(i32)) {
          if let Some(node) = self {
              let node = node.borrow();
              Self::inorder(&amp;node.left, visit);
              visit(node.val);
              Self::inorder(&amp;node.right, visit);
          }    
      }
  }
  
  impl Solution {
      pub fn is_valid_bst(root: TreeLink) -&gt; bool {
          let mut prev: Option&lt;i32&gt; = None;
          let mut res = true;
          root.inorder(&amp;mut |x| {
              if let Some(y) = prev {
                  if x &lt;= y {
                      res = false;
                  }
              }
              prev = Some(x);
          });
          res
      }
  }
  </code></pre>
  <p>I am using rustc 1.55.0 (c8dfcfe04 2021-09-06). I think it may be a bug in compiler.</p>