]> git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/from_over_into_unfixable.rs
New upstream version 1.74.1+dfsg1
[rustc.git] / src / tools / clippy / tests / ui / from_over_into_unfixable.rs
1 #![warn(clippy::from_over_into)]
2
3 struct InMacro(String);
4
5 macro_rules! in_macro {
6 () => {
7 Self::new()
8 };
9 }
10
11 impl Into<InMacro> for String {
12 //~^ ERROR: an implementation of `From` is preferred since it gives you `Into<_>` for free
13 fn into(self) -> InMacro {
14 InMacro(in_macro!())
15 }
16 }
17
18 struct WeirdUpperSelf;
19
20 impl Into<WeirdUpperSelf> for &'static [u8] {
21 //~^ ERROR: an implementation of `From` is preferred since it gives you `Into<_>` for free
22 fn into(self) -> WeirdUpperSelf {
23 let _ = Self::default();
24 WeirdUpperSelf
25 }
26 }
27
28 struct ContainsVal;
29
30 impl Into<u8> for ContainsVal {
31 //~^ ERROR: an implementation of `From` is preferred since it gives you `Into<_>` for free
32 fn into(self) -> u8 {
33 let val = 1;
34 val + 1
35 }
36 }
37
38 pub struct Lval<T>(T);
39
40 pub struct Rval<T>(T);
41
42 impl<T> Into<Rval<Self>> for Lval<T> {
43 //~^ ERROR: an implementation of `From` is preferred since it gives you `Into<_>` for free
44 fn into(self) -> Rval<Self> {
45 Rval(self)
46 }
47 }
48
49 fn main() {}