Closed
Description
Given the following code: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=ebe1fe6ca75fd88cba9aa3a77cb625bf
struct NotClone;
fn main() {
clone_thing(&NotClone);
}
fn clone_thing(nc: &NotClone) -> NotClone {
nc.clone()
}
The current output is:
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
--> src/main.rs:8:5
|
7 | fn clone_thing(nc: &NotClone) -> NotClone {
| -------- expected `NotClone` because of return type
8 | nc.clone()
| ^^^^^^^^^^ expected struct `NotClone`, found `&NotClone`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error
Ideally the output should look like:
error[[E0308]](https://doc.rust-lang.org/nightly/error-index.html#E0308): mismatched types
--> src/main.rs:8:5
|
7 | fn clone_thing(nc: &NotClone) -> NotClone {
| -------- expected `NotClone` because of return type
8 | nc.clone()
| ^^^^^^^^^^ expected struct `NotClone`, found `&NotClone`
| note: `NotClone` does not implement clone, consider implementing it.
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground` due to previous error