-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
auto_fix_errors.py: remove
Copy
from types that don't support it
- Loading branch information
1 parent
39b22cf
commit 2a24483
Showing
5 changed files
with
194 additions
and
2 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 |
---|---|---|
|
@@ -49,5 +49,6 @@ marks.*.json | |
# Outputs of `c2rust-analyze` | ||
inspect/ | ||
*.analysis.txt | ||
*.rs.fixed | ||
analysis.txt | ||
polonius_cache/ |
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,2 +1,3 @@ | ||
/inspect/ | ||
*.rlib | ||
/tests/auto_fix_errors/*.json |
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
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,82 @@ | ||
pub mod common; | ||
|
||
use crate::common::{check_for_missing_tests_for, test_dir_for}; | ||
use std::fs::{self, File}; | ||
use std::process::Command; | ||
|
||
#[test] | ||
fn check_for_missing_tests() { | ||
check_for_missing_tests_for(file!()); | ||
} | ||
|
||
fn test(file_name: &str) { | ||
let test_dir = test_dir_for(file!(), true); | ||
let path = test_dir.join(file_name); | ||
let fixed_path = path.with_extension("rs.fixed"); | ||
let json_path = path.with_extension("json"); | ||
let script_path = test_dir.join("../../scripts/auto_fix_errors.py"); | ||
|
||
fs::copy(&path, &fixed_path).unwrap(); | ||
|
||
// Run with `--error-format json` to produce JSON input for the script. | ||
let mut cmd = Command::new("rustc"); | ||
cmd.arg("-A") | ||
.arg("warnings") | ||
.arg("--crate-name") | ||
.arg(path.file_stem().unwrap()) | ||
.arg("--crate-type") | ||
.arg("rlib") | ||
.arg("--error-format") | ||
.arg("json") | ||
.arg(&fixed_path) | ||
.stderr(File::create(&json_path).unwrap()); | ||
let status = cmd.status().unwrap(); | ||
assert_eq!( | ||
status.code(), | ||
Some(1), | ||
"command {cmd:?} exited with code {status:?}" | ||
); | ||
|
||
// Run the script to fix errors. | ||
let mut cmd = Command::new("python3"); | ||
cmd.arg(&script_path).arg(&json_path); | ||
let status = cmd.status().unwrap(); | ||
assert!( | ||
status.success(), | ||
"command {cmd:?} exited with code {status:?}" | ||
); | ||
|
||
// There should be no more compile errors now. | ||
let mut cmd = Command::new("rustc"); | ||
cmd.arg("-A") | ||
.arg("warnings") | ||
.arg("--crate-name") | ||
.arg(path.file_stem().unwrap()) | ||
.arg("--crate-type") | ||
.arg("rlib") | ||
.arg(&fixed_path); | ||
let status = cmd.status().unwrap(); | ||
assert!( | ||
status.success(), | ||
"command {cmd:?} exited with code {status:?}" | ||
); | ||
} | ||
|
||
macro_rules! define_test { | ||
($name:ident) => { | ||
#[test] | ||
fn $name() { | ||
test(concat!(stringify!($name), ".rs")); | ||
} | ||
}; | ||
} | ||
|
||
macro_rules! define_tests { | ||
($($name:ident,)*) => { | ||
$(define_test! { $name })* | ||
} | ||
} | ||
|
||
define_tests! { | ||
derive_copy, | ||
} |
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,49 @@ | ||
#[derive(Clone, Copy)] | ||
struct S1 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
#[derive(Clone, Copy,)] | ||
struct S2 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
|
||
#[derive(Copy, Clone)] | ||
struct S3 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
|
||
#[derive(Copy, Clone,)] | ||
struct S4 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
|
||
#[derive(Copy)] | ||
struct S5 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
#[derive(Copy,)] | ||
struct S6 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} | ||
|
||
|
||
#[derive( | ||
Copy | ||
, | ||
Clone | ||
)] | ||
struct S7 { | ||
x: Box<i32>, | ||
y: &'static i32, | ||
} |