Skip to content

Commit d6dc48d

Browse files
Add ui test for include_file_outside_project lint
1 parent a6ab226 commit d6dc48d

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ normalize-stderr-test: "located at `.+/.crates.toml`" -> "located at `$$DIR/.crates.toml`"
2+
//@ normalize-stderr-test: "folder \(`.+`" -> "folder (`$$CLIPPY_DIR`"
3+
4+
#![deny(clippy::include_file_outside_project)]
5+
6+
// Should not lint.
7+
include!("./auxiliary/external_consts.rs");
8+
9+
fn main() {
10+
let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
11+
//~^ include_file_outside_project
12+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: attempted to include a file outside of the project
2+
--> tests/ui/include_file_outside_project.rs:10:13
3+
|
4+
LL | let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
5+
| ^
6+
|
7+
= note: file is located at `$DIR/.crates.toml` which is outside of project folder (`$CLIPPY_DIR`)
8+
note: the lint level is defined here
9+
--> tests/ui/include_file_outside_project.rs:4:9
10+
|
11+
LL | #![deny(clippy::include_file_outside_project)]
12+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13+
14+
error: aborting due to 1 previous error
15+

0 commit comments

Comments
 (0)