]> git.lizzy.rs Git - rust.git/blob - src/test/ui/span/coerce-suggestions.rs
Rollup merge of #41077 - petrochenkov:boundparen, r=nikomatsakis
[rust.git] / src / test / ui / span / coerce-suggestions.rs
1 // Copyright 2016 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(box_syntax)]
12
13 fn test(_x: &mut String) {}
14 fn test2(_x: &mut i32) {}
15
16 fn main() {
17     let x: usize = String::new();
18     //~^ ERROR E0308
19     //~| NOTE expected usize, found struct `std::string::String`
20     //~| NOTE expected type `usize`
21     //~| NOTE found type `std::string::String`
22     //~| HELP here are some functions which might fulfill your needs:
23     let x: &str = String::new();
24     //~^ ERROR E0308
25     //~| NOTE expected &str, found struct `std::string::String`
26     //~| NOTE expected type `&str`
27     //~| NOTE found type `std::string::String`
28     //~| HELP try with `&String::new()`
29     let y = String::new();
30     test(&y);
31     //~^ ERROR E0308
32     //~| NOTE types differ in mutability
33     //~| NOTE expected type `&mut std::string::String`
34     //~| NOTE found type `&std::string::String`
35     test2(&y);
36     //~^ ERROR E0308
37     //~| NOTE types differ in mutability
38     //~| NOTE expected type `&mut i32`
39     //~| NOTE found type `&std::string::String`
40     let f;
41     f = box f;
42     //~^ ERROR E0308
43     //~| NOTE cyclic type of infinite size
44     //~| NOTE expected type `_`
45     //~| NOTE found type `Box<_>`
46 }