Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt;
- trait MyTrait { }
- /// warning: trait objects without an explicit `dyn` are deprecated
- /// --> traits.rs:5:23
- /// |
- /// 5 | impl fmt::Display for MyTrait {
- /// | ^^^^^^^
- /// |
- /// = note: `#[warn(bare_trait_objects)]` on by default
- /// = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
- /// = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
- /// help: use `dyn`
- /// |
- /// 5 - impl fmt::Display for MyTrait {
- /// 5 + impl fmt::Display for dyn MyTrait {
- /// |
- ///
- /// warning: 1 warning emitted
- /*impl fmt::Display for MyTrait {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- write!(f, "Hello here")
- }
- }*/
- /// error[E0210]: type parameter `T` must be used as the type parameter for some local type (e.g., `MyStruct<T>`)
- /// --> traits.rs:27:6
- /// |
- /// 27 | impl<T: MyTrait> fmt::Display for T {
- /// | ^ type parameter `T` must be used as the type parameter for some local type
- /// |
- /// = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
- /// = note: only traits defined in the current crate can be implemented for a type parameter
- ///
- /// error: aborting due to previous error
- /// For more information about this error, try `rustc --explain E0210`.
- impl<T: MyTrait> fmt::Display for T {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- todo!();
- }
- }
- fn main() { }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement