Skip to content

Commit 1e98ef2

Browse files
BD103mrchantey
authored andcommitted
Fix compile_fail compile fail (bevyengine#16805)
# Objective - Fixes bevyengine#16802, part of bevyengine#16801, extracted from bevyengine#16770. ## Solution - Fix `compile_fail_utils`'s example test so that it now compiles. - Bless the results, which were outdated. ## Testing - `cd tools/compile_fail_utils && cargo check --all-targets` - `cd tools/compile_fail_utils && cargo test --test example`
1 parent 43a2d5d commit 1e98ef2

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
fn main() -> bevy_compile_test_utils::ui_test::Result<()> {
1+
fn main() -> compile_fail_utils::ui_test::Result<()> {
22
// Run all tests in the tests/example_tests folder.
33
// If we had more tests we could either call this function
44
// on everysingle one or use test_multiple and past it an array
55
// of paths.
66
//
77
// Don't forget that when running tests the working directory
88
// is set to the crate root.
9-
bevy_compile_test_utils::test("tests/example_tests")
9+
compile_fail_utils::test("example_tests", "tests/example_tests")
1010
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Compiler warnings also need to be annotated. We don't
2+
// want to annotate all the unused variables so let's instruct
3+
// the compiler to ignore them.
4+
#![allow(unused_variables)]
5+
6+
fn bad_moves() {
7+
let x = String::new();
8+
// Help diagnostics need to be annotated
9+
let y = x.clone();
10+
//~^ HELP: consider cloning
11+
12+
// We expect a failure on this line
13+
println!("{x}"); //~ ERROR: borrow
14+
15+
16+
let x = String::new();
17+
// We expect the help message to mention cloning.
18+
//~v HELP: consider cloning
19+
let y = x.clone();
20+
21+
// Check error message using a regex
22+
println!("{x}");
23+
//~^ ERROR: /(move)|(borrow)/
24+
}

tools/compile_fail_utils/tests/example_tests/import.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ error[E0599]: no function or associated item named `this_function_does_not_exist
77
note: if you're trying to build a new `Config` consider using one of the following associated functions:
88
Config::rustc
99
Config::cargo
10-
--> $RUSTUP_HOME/.cargo/git/checkouts/ui_test-2b82183a391bb05c/680bb08/src/config.rs:63:5
10+
--> $RUSTUP_HOME/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ui_test-0.23.0/src/config.rs:70:5
1111
|
12-
63 | pub fn rustc(root_dir: impl Into<PathBuf>) -> Self {
12+
70 | pub fn rustc(root_dir: impl Into<PathBuf>) -> Self {
1313
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1414
...
15-
108 | pub fn cargo(root_dir: impl Into<PathBuf>) -> Self {
15+
221 | pub fn cargo(root_dir: impl Into<PathBuf>) -> Self {
1616
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1717

1818
error: aborting due to 1 previous error

0 commit comments

Comments
 (0)