]> git.lizzy.rs Git - rust.git/blob - tests/ui/suggestions/suggest-blanket-impl-local-trait.rs
Rollup merge of #106670 - albertlarsan68:check-docs-in-pr-ci, r=Mark-Simulacrum
[rust.git] / tests / ui / suggestions / suggest-blanket-impl-local-trait.rs
1 // Ensure that the compiler include the blanklet implementation suggestion
2 // when inside a `impl` statement are used two local traits.
3 //
4 // edition:2021
5 use std::fmt;
6
7 trait LocalTraitOne { }
8
9 trait LocalTraitTwo { }
10
11 trait GenericTrait<T> {}
12
13 impl LocalTraitTwo for LocalTraitOne {}
14 //~^ ERROR trait objects must include the `dyn` keyword
15 //~| HELP add `dyn` keyword before this trait
16 //~| HELP alternatively use a blanket implementation to implement `LocalTraitTwo` for all types that also implement `LocalTraitOne`
17
18 impl fmt::Display for LocalTraitOne {
19 //~^ ERROR trait objects must include the `dyn` keyword
20 //~| HELP add `dyn` keyword before this trait
21     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
22         todo!();
23     }
24 }
25
26 impl fmt::Display for LocalTraitTwo + Send {
27 //~^ ERROR trait objects must include the `dyn` keyword
28 //~| HELP add `dyn` keyword before this trait
29     fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result {
30         todo!();
31     }
32 }
33
34 impl LocalTraitOne for fmt::Display {}
35 //~^ ERROR trait objects must include the `dyn` keyword
36 //~| HELP add `dyn` keyword before this trait
37 //~| HELP alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display`
38
39
40 impl LocalTraitOne for fmt::Display + Send {}
41 //~^ ERROR trait objects must include the `dyn` keyword
42 //~| HELP add `dyn` keyword before this trait
43 //~| HELP alternatively use a blanket implementation to implement `LocalTraitOne` for all types that also implement `fmt::Display + Send`
44
45
46 impl<E> GenericTrait<E> for LocalTraitOne {}
47 //~^ ERROR trait objects must include the `dyn` keyword
48 //~| HELP add `dyn` keyword before this trait
49 //~| HELP alternatively use a blanket implementation to implement `GenericTrait<E>` for all types that also implement `LocalTraitOne`
50
51 trait GenericTraitTwo<T> {}
52
53 impl<T, E> GenericTraitTwo<E> for GenericTrait<T> {}
54 //~^ ERROR trait objects must include the `dyn` keyword
55 //~| HELP add `dyn` keyword before this trait
56 //~| HELP alternatively use a blanket implementation to implement `GenericTraitTwo<E>` for all types that also implement `GenericTrait<T>`
57
58 fn main() {}