-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
rexim, cg-jl, vintium and 8dcc
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.