2017-08-14 17:21:36 -05:00
|
|
|
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
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) {
|
2017-11-20 06:13:27 -06:00
|
|
|
foo(s); //~ ERROR mismatched types
|
2017-08-14 17:21:36 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn foo3(_: u32) {}
|
|
|
|
fn foo4(u: &u32) {
|
2017-11-20 06:13:27 -06: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);
|
2017-11-20 06:13:27 -06: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);
|
|
|
|
}
|