You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Compiler erroneously suggests inserting a syntax error in struct definition #71136
When defining a struct that derives Clone, that owns an instance of another struct, which is not Clone, an invalid suggestion is given to resolve the problem.
I expected any suggestions to at least be valid Rust. Instead, the compiler suggested "borrowing" but put the & in the wrong place, which is invalid syntax.
error[E0277]: the trait bound `Foo: std::clone::Clone` is not satisfied
--> src/main.rs:5:5
|
5 | the_foos: Vec<Foo>,
| ^^^^^^^^^^^^^^^^^^
| |
| expected an implementor of trait `std::clone::Clone`
| help: consider borrowing here: `&the_foos: Vec<Foo>`
|
= note: required because of the requirements on the impl of `std::clone::Clone` for `std::vec::Vec<Foo>`
= note: required by `std::clone::Clone::clone`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
I checked this in Stable 1.42.0 and "Nightly version: 1.44.0-nightly (2020-04-12 3712e11)" on Rust Playground
Activity
kper commentedon May 2, 2020
@rustbot claim
Adding if to prevent borrowing suggestion in structs rust-lang#71136
Adding new test rust-lang#71136
Rollup merge of rust-lang#71829 - kper:issue71136, r=matthewjasper
kper commentedon May 23, 2020
@gardrek can you close the issue? The PR has been merged