fork/rust
git clone https://git.julia.blue/fork/rust
49cae55760d
1.44.0
1// run-rustfix 2 3#![allow(warnings)] 4 5// Test that suggestion to add `*` characters applies to implementations of `Deref` as well as 6// references. 7 8struct Foo(i32); 9 10struct Bar(String); 11 12impl std::ops::Deref for Foo { 13 type Target = i32; 14 fn deref(&self) -> &Self::Target { 15 &self.0 16 } 17} 18 19impl std::ops::Deref for Bar { 20 type Target = String; 21 fn deref(&self) -> &Self::Target { 22 &self.0 23 } 24} 25 26fn main() { 27 let x = Foo(42); 28 let y: i32 = *x; //~ ERROR mismatched types 29 let a = &42; 30 let b: i32 = *a; //~ ERROR mismatched types 31 32 // Do not make a suggestion when adding a `*` wouldn't actually fix the issue: 33 let f = Bar("bar".to_string()); 34 let g: String = f.to_string(); //~ ERROR mismatched types 35}