]> git.lizzy.rs Git - rust.git/blob - tests/ui/errors/issue-99572-impl-trait-on-pointer.rs
Auto merge of #106520 - ehuss:update-mdbook, r=Mark-Simulacrum
[rust.git] / tests / ui / errors / issue-99572-impl-trait-on-pointer.rs
1 // Emit additional suggestion to correct the trait implementation
2 // on a pointer
3 use std::{fmt, marker};
4
5 struct LocalType;
6
7 impl fmt::Display for *mut LocalType {
8 //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
9 //~| NOTE impl doesn't use only types from inside the current crate
10 //~| NOTE `*mut LocalType` is not defined in the current crate because raw pointers are always foreign
11 //~| NOTE define and implement a trait or new type instead
12 //~| HELP consider introducing a new wrapper type
13     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
14         write!(f, "This not compile")
15     }
16 }
17
18 impl<T> marker::Copy for *mut T {
19 //~^ ERROR only traits defined in the current crate can be implemented for arbitrary types
20 //~| NOTE impl doesn't use only types from inside the current crate
21 //~| NOTE `*mut T` is not defined in the current crate because raw pointers are always foreign
22 //~| NOTE define and implement a trait or new type instead
23 }
24
25 fn main() {}