about summary refs log tree commit diff
path: root/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-05-27 14:36:40 -0700
committerbors <bors@rust-lang.org>2014-05-27 14:36:40 -0700
commit1fc29ef0c8c35eacf7d72e5eb0e7c961009ab4c9 (patch)
tree61913cf89bfd68e5ccfe20e8753b461d4afb3063 /src/test/compile-fail/for-loop-refutable-pattern-error-message.rs
parent1e2bb09bbbbae4470fef295d245304fe08e1acab (diff)
parent0df221e993a1f7f1fc4d80c6a4fa0e43c05c30c7 (diff)
downloadrust-1fc29ef0c8c35eacf7d72e5eb0e7c961009ab4c9.tar.gz
rust-1fc29ef0c8c35eacf7d72e5eb0e7c961009ab4c9.zip
auto merge of #14444 : huonw/rust/nice-for-errors, r=alexcrichton
Change `for` desugaring & make refutable pattern errors more precise

This changes for to desugar to the `let`-based pattern match as described in #14390, and adjusts the compiler to use this information for error messages that even mention that it's in a `for` loop.

Also, it makes the compiler record the exact positions of refutable parts of a pattern, to point to exactly them in error messages.
Diffstat (limited to 'src/test/compile-fail/for-loop-refutable-pattern-error-message.rs')
-rw-r--r--src/test/compile-fail/for-loop-refutable-pattern-error-message.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs b/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs
new file mode 100644
index 00000000000..8b00b614909
--- /dev/null
+++ b/src/test/compile-fail/for-loop-refutable-pattern-error-message.rs
@@ -0,0 +1,16 @@
+// Copyright 2014 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 main() {
+    for
+        &1 //~ ERROR refutable pattern in `for` loop binding
+        in [1].iter() {}
+}