diff options
Diffstat (limited to 'src/test/ui')
| -rw-r--r-- | src/test/ui/suggestions/dont-suggest-dereference-on-arg.rs | 18 | ||||
| -rw-r--r-- | src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr | 10 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/dont-suggest-dereference-on-arg.rs b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.rs new file mode 100644 index 00000000000..2a9ea464416 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.rs @@ -0,0 +1,18 @@ +// 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. + +fn foo(s: &str) -> bool { true } + +fn main() { + let x = vec![(String::new(), String::new())]; + x.iter() + .filter(|&(ref a, _)| foo(a)) + .collect(); +} diff --git a/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr new file mode 100644 index 00000000000..fc1eb335d05 --- /dev/null +++ b/src/test/ui/suggestions/dont-suggest-dereference-on-arg.stderr @@ -0,0 +1,10 @@ +error: non-reference pattern used to match a reference (see issue #42640) + --> dont-suggest-dereference-on-arg.rs:16:19 + | +16 | .filter(|&(ref a, _)| foo(a)) + | ^^^^^^^^^^^ help: consider using: `&&(ref k, _)` + | + = help: add #![feature(match_default_bindings)] to the crate attributes to enable + +error: aborting due to previous error + |
