Spurious 'help: store this in the heap' on error involving &Box<dyn SomeTrait>
#82446
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-bug
Category: This is a bug.
D-incorrect
Diagnostics: A diagnostic that is giving misleading or incorrect information.
D-invalid-suggestion
Diagnostics: A structured suggestion resulting in incorrect code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following code:
produces the following error:
val
is a&Box<dyn MyTrait>
, so writingBox::new(val)
would produce aBox<&Box<dyn MyTrait>>
. This is very unlikely to be what the user wants - and in this case, it won't even work, since there are no impls forMyTrait
.Meta
Tested on
rustc 1.52.0-nightly 2021-02-22
The text was updated successfully, but these errors were encountered: