-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix
compile_fail
compile fail (#16805)
# Objective - Fixes #16802, part of #16801, extracted from #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`
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
fn main() -> bevy_compile_test_utils::ui_test::Result<()> { | ||
fn main() -> compile_fail_utils::ui_test::Result<()> { | ||
// Run all tests in the tests/example_tests folder. | ||
// If we had more tests we could either call this function | ||
// on everysingle one or use test_multiple and past it an array | ||
// of paths. | ||
// | ||
// Don't forget that when running tests the working directory | ||
// is set to the crate root. | ||
bevy_compile_test_utils::test("tests/example_tests") | ||
compile_fail_utils::test("example_tests", "tests/example_tests") | ||
} |
24 changes: 24 additions & 0 deletions
24
tools/compile_fail_utils/tests/example_tests/basic_test.fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Compiler warnings also need to be annotated. We don't | ||
// want to annotate all the unused variables so let's instruct | ||
// the compiler to ignore them. | ||
#![allow(unused_variables)] | ||
|
||
fn bad_moves() { | ||
let x = String::new(); | ||
// Help diagnostics need to be annotated | ||
let y = x.clone(); | ||
//~^ HELP: consider cloning | ||
|
||
// We expect a failure on this line | ||
println!("{x}"); //~ ERROR: borrow | ||
|
||
|
||
let x = String::new(); | ||
// We expect the help message to mention cloning. | ||
//~v HELP: consider cloning | ||
let y = x.clone(); | ||
|
||
// Check error message using a regex | ||
println!("{x}"); | ||
//~^ ERROR: /(move)|(borrow)/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters