From fa9e55faeb0b4fac282ed47f20780c05f4efc86d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 2 May 2018 08:43:15 -0700 Subject: test: Make a dedicated testsuite for rustfix This commit adds a dedicated mode to compiletest for running rustfix tests, adding a new `src/test/rustfix` directory which will execute all tests as a "rustfix" test, namely requiring that a `*.fixed` is next to the main file which is the result of the rustfix project's application of fixes. The `rustfix` crate is pulled in to actually perform the fixing, and the rustfix compiletest mode will assert a few properties about the fixing: * The expected fixed output must be the same as rustc's output suggestions applied to the original code. * The fixed code must compile successfully * The fixed code must have no further diagnostics emitted about it --- .../rustfix/closure-immutable-outer-variable.fixed | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/rustfix/closure-immutable-outer-variable.fixed (limited to 'src/test/rustfix/closure-immutable-outer-variable.fixed') 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 or the MIT license +// , 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) { + f(); +} + +fn main() { + let mut y = true; + foo(Box::new(move || y = false) as Box<_>); +} -- cgit 1.4.1-3-g733a5