I'm not the OP either, but since it's been a minute and conversation is moving on, here's what I think is a more useful presentation for the coder.
error[E0277]: the trait bound `&u8: Into<*const u8>` is not satisfied
--> src/main.rs:16:38
|
16 | let raw2 = Raw { data: reference.into() }; // error[E0277]: the trait bound `*const u8: From<&u8>` is not satisfied
| ^^^^ the trait `Into<*const u8>` is not implemented for `&u8`
|
= note: trait bound `*const u8: From<&u8>` is also not satisfied (which
would also result in `&u8` implementing `Into<*const u8>`)
help: '&u8' can coerce to '*const u8' without using `into`
- let raw2 = Raw { data: reference.into() };
+ let raw2 = Raw { data: reference };
help: `u8` implements trait `Into<T>` for some `T`:
u8: Into<u16>
u8: Into<char>
... and however many others
For more information about this error, try `rustc --explain E0277`.
(The diff would be proper rustc diff style of course.)
And the rest of this comment explains how I got there.
The first thing I noticed is that 2/3rds of the error message is noise. u8 is From<bool> and From<AsciiChar>... okay? Defined in a macro in their foreign crate..... great I guess? But so what?
The macro details can probably just be dropped if it's not in a local crate. When some From<_> details may be relevant or not is a harder call... but I think they're taking up an undue proportion of the space here. And they are in the middle of the more pertinent information, not just strictly before or after.
And I'm also not actually sure why the diagnostics made a leap from "need *const u8: From<&u8>" to "here's some u8: From<T>". If it was because the method receiver is reference and *reference is a u8, it should have been telling me about u8: Into<T> -- or T: From<u8> -- instead. (The list in my revised error is based on that assumption.)
Also "help: u8 implements trait From<T>" makes it sound like there's an implementation for all T, not some select Ts.
Into<*const u8> for &u8 could also be added.
Now, maybe that sounds like useless nitpicking in this case, where indeed From would be the correct choice... for whomever can implement it (in this case, the coder cannot). But there is a wider issue where error messages / suggestions prefer to tell you about the blanket implementation at the end of some chain, instead of the direct bound / trait the code needed (#22590, #87272).
I feel this particular message would have been clearer if it started talking about Into (the trait which was actually trying to be invoked) and then making the connection with From, instead of immediately talking about From while highlighting .into().
And as was already discussed, the error doesn't suggest just using coercion yet, but should.