Closed
Description
Given the following code
#[derive(Clone)]
struct S;
trait X {}
impl X for S {}
fn foo<T: X>(_: &T) {}
fn main() {
let s = &S;
foo(*s);
}
The current output is:
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
--> src/main.rs:12:9
|
12 | foo(*s);
| --- ^^
| | |
| | expected reference, found struct `S`
| | help: consider borrowing here: `&*s`
| arguments to this function are incorrect
|
= note: expected reference `&_`
found struct `S`
note: function defined here
--> src/main.rs:8:4
|
8 | fn foo<T: X>(_: &T) {}
| ^^^ -----
For more information about this error, try `rustc --explain E0308`.
Ideally the output should suggest remove the *
to this:
foo(s);