Skip to content

Commit fa9f7d3

Browse files
committed
Port clippy away from compiletest to ui_test
1 parent 8b65632 commit fa9f7d3

File tree

1,562 files changed

+15015
-12484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,562 files changed

+15015
-12484
lines changed

Cargo.toml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tempfile = { version = "3.2", optional = true }
2828
termize = "0.1"
2929

3030
[dev-dependencies]
31-
compiletest_rs = { version = "0.9", features = ["tmp"] }
31+
ui_test = { path = "../ui_test" }
3232
tester = "0.9"
3333
regex = "1.5"
3434
toml = "0.5"
@@ -41,20 +41,6 @@ filetime = "0.2"
4141
# for more information.
4242
rustc-workspace-hack = "1.0"
4343

44-
# UI test dependencies
45-
clap = { version = "4.1.4", features = ["derive"] }
46-
clippy_utils = { path = "clippy_utils" }
47-
derive-new = "0.5"
48-
if_chain = "1.0"
49-
itertools = "0.10.1"
50-
quote = "1.0"
51-
serde = { version = "1.0.125", features = ["derive"] }
52-
syn = { version = "1.0", features = ["full"] }
53-
futures = "0.3"
54-
parking_lot = "0.12"
55-
tokio = { version = "1", features = ["io-util"] }
56-
rustc-semver = "1.1"
57-
5844
[build-dependencies]
5945
rustc_tools_util = "0.3.0"
6046

book/src/development/adding_lints.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ The process of generating the `.stderr` file is the same, and prepending the
163163
## Rustfix tests
164164

165165
If the lint you are working on is making use of structured suggestions, the test
166-
file should include a `// run-rustfix` comment at the top. This will
166+
file should include a `//@run-rustfix` comment at the top. This will
167167
additionally run [rustfix] for that test. Rustfix will apply the suggestions
168168
from the lint to the code of the test file and compare that to the contents of a
169169
`.fixed` file.

clippy_dev/src/new_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
8787

8888
path.push("src");
8989
fs::create_dir(&path)?;
90-
let header = format!("// compile-flags: --crate-name={lint_name}");
90+
let header = format!("//@compile-flags: --crate-name={lint_name}");
9191
write_file(path.join("main.rs"), get_test_file_contents(lint_name, Some(&header)))?;
9292

9393
Ok(())

clippy_dev/src/update_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ fn gen_deprecated_lints_test(lints: &[DeprecatedLint]) -> String {
745745
fn gen_renamed_lints_test(lints: &[RenamedLint]) -> String {
746746
let mut seen_lints = HashSet::new();
747747
let mut res: String = GENERATED_FILE_COMMENT.into();
748-
res.push_str("// run-rustfix\n\n");
748+
res.push_str("//@run-rustfix\n\n");
749749
for lint in lints {
750750
if seen_lints.insert(&lint.new_name) {
751751
writeln!(res, "#![allow({})]", lint.new_name).unwrap();

clippy_lints/src/methods/obfuscated_if_else.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// run-rustfix
1+
//@run-rustfix
22

33
use super::OBFUSCATED_IF_ELSE;
44
use clippy_utils::{diagnostics::span_lint_and_sugg, source::snippet_with_applicability};

clippy_test_deps/Cargo.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[package]
2+
name = "clippy_test_deps"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
clap = { version = "4.1.4", features = ["derive"] }
10+
clippy_utils = { path = "../clippy_utils" }
11+
derive-new = "0.5"
12+
if_chain = "1.0"
13+
itertools = "0.10.1"
14+
quote = "1.0"
15+
serde = { version = "1.0.125", features = ["derive"] }
16+
syn = { version = "1.0", features = ["full"] }
17+
futures = "0.3"
18+
parking_lot = "0.12"
19+
tokio = { version = "1", features = ["io-util"] }
20+
rustc-semver = "1.1"
21+
regex = "1.5"

clippy_test_deps/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: usize, right: usize) -> usize {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,7 @@ fn with_test_item_names(tcx: TyCtxt<'_>, module: LocalDefId, f: impl Fn(&[Symbol
23572357

23582358
/// Checks if the function containing the given `HirId` is a `#[test]` function
23592359
///
2360-
/// Note: Add `// compile-flags: --test` to UI tests with a `#[test]` function
2360+
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[test]` function
23612361
pub fn is_in_test_function(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
23622362
with_test_item_names(tcx, tcx.parent_module(id), |names| {
23632363
tcx.hir()
@@ -2379,7 +2379,7 @@ pub fn is_in_test_function(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
23792379

23802380
/// Checks if the item containing the given `HirId` has `#[cfg(test)]` attribute applied
23812381
///
2382-
/// Note: Add `// compile-flags: --test` to UI tests with a `#[cfg(test)]` function
2382+
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[cfg(test)]` function
23832383
pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
23842384
fn is_cfg_test(attr: &Attribute) -> bool {
23852385
if attr.has_name(sym::cfg)
@@ -2401,7 +2401,7 @@ pub fn is_in_cfg_test(tcx: TyCtxt<'_>, id: hir::HirId) -> bool {
24012401
/// Checks whether item either has `test` attribute applied, or
24022402
/// is a module with `test` in its name.
24032403
///
2404-
/// Note: Add `// compile-flags: --test` to UI tests with a `#[test]` function
2404+
/// Note: Add `//@compile-flags: --test` to UI tests with a `#[test]` function
24052405
pub fn is_test_module_or_function(tcx: TyCtxt<'_>, item: &Item<'_>) -> bool {
24062406
is_in_test_function(tcx, item.hir_id())
24072407
|| matches!(item.kind, ItemKind::Mod(..))

0 commit comments

Comments
 (0)