about summary refs log tree commit diff
path: root/src/test/rustfix/closure-immutable-outer-variable.fixed
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-05-04 23:15:00 +0000
committerbors <bors@rust-lang.org>2018-05-04 23:15:00 +0000
commit1d168261a1bc0031ef27de735992a4842fd62553 (patch)
treec53c956b4e906922c9de96ec644394b5c1114815 /src/test/rustfix/closure-immutable-outer-variable.fixed
parent91db9dcf3730207f63b3dfc33b2c438a769b7517 (diff)
parent6f2d023028bbd666be2c211b923b32faf10a41da (diff)
downloadrust-1d168261a1bc0031ef27de735992a4842fd62553.tar.gz
rust-1d168261a1bc0031ef27de735992a4842fd62553.zip
Auto merge of #50084 - killercup:compiletest-rustfix, r=Manishearth
First step towards rustfix compiletest mode

This is the first small step towards testing auto-fixable compiler
suggestions using compiletest. Currently, it only checks if next to a
UI test there also happens to a `*.rs.fixed` file, and then uses rustfix
(added as external crate) on the original file, and asserts that it
produces the fixed version.

To show that this works, I've included one such test. I picked this test
case at random (and because it was simple) -- It is not relevant to the
2018 edition. Indeed, in the near future, we want to be able to restrict
rustfix to edition-lints, so this test cast might go away soon.

In case you still think this is somewhat feature-complete, here's a
quick list of things currently missing that I want to add before telling
people they can use this:

- [x] Make this an actual compiletest mode, with `test [fix] …` output
  and everything
- [x] Assert that fixed files still compile
- [x] Assert that fixed files produce no (or a known set of) diagnostics
  output
- [x] Update `update-references.sh` to support rustfix
- [x] Use a published version of rustfix (i.e.: publish a new version
  rustfix that exposes a useful API for this)
Diffstat (limited to 'src/test/rustfix/closure-immutable-outer-variable.fixed')
-rw-r--r--src/test/rustfix/closure-immutable-outer-variable.fixed20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/test/rustfix/closure-immutable-outer-variable.fixed b/src/test/rustfix/closure-immutable-outer-variable.fixed
new file mode 100644
index 00000000000..bddc2eab16d
--- /dev/null
+++ b/src/test/rustfix/closure-immutable-outer-variable.fixed
@@ -0,0 +1,20 @@
+// 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.
+
+// Point at the captured immutable outer variable
+
+fn foo(mut f: Box<FnMut()>) {
+    f();
+}
+
+fn main() {
+    let mut y = true;
+    foo(Box::new(move || y = false) as Box<_>);
+}