-
-
Notifications
You must be signed in to change notification settings - Fork 14.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
Code
use std::borrow::Borrow;
const F: for<'a> fn(&'a &'static String) -> &'a str = <&'static String as Borrow<str>>::borrow;Current output
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `&'static String: Borrow<str>` is not satisfied
--> src/lib.rs:2:55
|
2 | const F: for<'a> fn(&'a &'static String) -> &'a str = <&'static String as Borrow<str>>::borrow;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Borrow<str>` is not implemented for `&'static String`
|
help: consider borrowing here
|
2 | const F: for<'a> fn(&'a &'static String) -> &'a str = &<&'static String as Borrow<str>>::borrow;
| +
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` due to previous errorDesired output
Compiling playground v0.0.1 (/playground)
error[E0277]: the trait bound `&'static String: Borrow<str>` is not satisfied
--> src/lib.rs:2:55
|
2 | const F: for<'a> fn(&'a &'static String) -> &'a str = <&'static String as Borrow<str>>::borrow;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Borrow<str>` is not implemented for `&'static String`
For more information about this error, try `rustc --explain E0277`.
error: could not compile `playground` due to previous errorRationale and extra context
borrowing the Borrow::borrow function item won't ever fix the missing trait bound.
Other cases
No response
Anything else?
Reactions are currently unavailable
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.