]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/cmp_owned.rs
eb4070d8fd6c0cdcec6cc7645e27cd367079a35c
[rust.git] / tests / compile-fail / cmp_owned.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3
4 #[deny(cmp_owned)]
5 fn main() {
6     fn with_to_string(x : &str) {
7         x != "foo".to_string();
8         //~^ ERROR this creates an owned instance just for comparison. Consider using `x != "foo"` to compare without allocation
9
10         "foo".to_string() != x;
11         //~^ ERROR this creates an owned instance just for comparison. Consider using `"foo" != x` to compare without allocation
12     }
13
14     let x = "oh";
15
16     with_to_string(x);
17
18     x != "foo".to_owned(); //~ERROR this creates an owned instance
19
20     // removed String::from_str(..), as it has finally been removed in 1.4.0
21     // as of 2015-08-14
22
23     x != String::from("foo"); //~ERROR this creates an owned instance
24
25     42.to_string() == "42";
26 }