rust/src/test/ui/deref-suggestion.rs

31 lines
549 B
Rust
Raw Normal View History

2017-08-14 17:21:36 -05:00
macro_rules! borrow {
2017-11-20 06:13:27 -06:00
($x:expr) => { &$x } //~ ERROR mismatched types
2017-08-14 17:21:36 -05:00
}
fn foo(_: String) {}
fn foo2(s: &String) {
2018-08-26 18:54:06 -05:00
foo(s);
//~^ ERROR mismatched types
2017-08-14 17:21:36 -05:00
}
fn foo3(_: u32) {}
fn foo4(u: &u32) {
2018-08-26 18:54:06 -05:00
foo3(u);
//~^ ERROR mismatched types
2017-08-14 17:21:36 -05:00
}
fn main() {
let s = String::new();
let r_s = &s;
foo2(r_s);
2018-08-26 18:54:06 -05:00
foo(&"aaa".to_owned());
//~^ ERROR mismatched types
foo(&mut "aaa".to_owned());
//~^ ERROR mismatched types
2017-08-14 17:21:36 -05:00
foo3(borrow!(0));
foo4(&0);
2018-08-26 18:54:06 -05:00
assert_eq!(3i32, &3i32);
//~^ ERROR mismatched types
2018-08-26 20:03:57 -05:00
}