Code
use std::borrow::Borrow;
struct S;
trait T: Sized {
fn foo(self) {}
}
impl T for S {}
impl T for &S {}
fn main() {
let s = S;
s.borrow().foo();
s.foo();
}
Current output
Compiling borrow v0.1.0 (/tmp/borrow)
warning: using `.borrow()` on a double reference, which returns `&S` instead of borrowing the inner type
--> src/main.rs:14:6
|
14 | s.borrow().foo();
| ^^^^^^^^^
|
= note: `#[warn(suspicious_double_ref_op)]` on by default
warning: `borrow` (bin "borrow") generated 1 warning
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
Desired output
Compiling borrow v0.1.0 (/tmp/borrow)
Finished dev [unoptimized + debuginfo] target(s) in 0.20s
Rationale and extra context
If I have a type S, and a trait T that is implemented for both S and &S, s.borrow() is a valid way to get a reference &S from an object of type S. But since beta 1.71, this emits a warning. I have no idea what the warning is trying to convey, what "double reference" is referring to, or what "the inner type" is.
Other cases
No response
Anything else?
$ rustc +beta --version
rustc 1.71.0-beta.3 (78a6ac0a8 2023-06-08)
Code
Current output
Desired output
Compiling borrow v0.1.0 (/tmp/borrow) Finished dev [unoptimized + debuginfo] target(s) in 0.20sRationale and extra context
If I have a type
S, and a traitTthat is implemented for bothSand&S,s.borrow()is a valid way to get a reference&Sfrom an object of typeS. But since beta 1.71, this emits a warning. I have no idea what the warning is trying to convey, what "double reference" is referring to, or what "the inner type" is.Other cases
No response
Anything else?