-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Incomprehensible error message involving lifetimes adding extension methods to dyn Trait #71341
Copy link
Copy link
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`C-bugCategory: This is a bug.Category: This is a bug.D-confusingDiagnostics: Confusing error or lint that should be reworked.Diagnostics: Confusing error or lint that should be reworked.D-terseDiagnostics: An error or lint that doesn't give enough information about the problem at hand.Diagnostics: An error or lint that doesn't give enough information about the problem at hand.T-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
I'm defining a trait that adds extension methods to
dyn <another-trait>:Complete example: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=9918f3c4541601415f65606b4bfa0790
Rust stable and nightly both give
This is confusing. Obviously, adding a lifetime parameter identical to one already present doesn't seem sensible. Furthermore there is no clue here indicating what the error actually is. I spent over an hour thrashing around and ended up with https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=fda63d48e1652dcfd0923002f723163c --- i.e. I need to add a lifetime bound to the
dyntype I'm extending, not just the method(s) on the extension.I'm assuming that the compiler is correct here and it just needs a better error message. I'm not 100% sure about that though.