Skip to content

Commit

Permalink
Add ui test for include_file_outside_project lint
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 20, 2024
1 parent a6ab226 commit dcb5724
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/ui/include_file_outside_project.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#![deny(clippy::include_file_outside_project)]

// Should not lint.
include!("./auxiliary/external_consts.rs");

fn main() {
let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
//~^ include_file_outside_project
}
15 changes: 15 additions & 0 deletions tests/ui/include_file_outside_project.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: attempted to include a file outside of the project
--> tests/ui/include_file_outside_project.rs:7:13
|
LL | let x = include_str!(concat!(env!("CARGO_HOME"), "/.crates.toml"));
| ^
|
= note: file is located at `/home/imperio/.cargo/.crates.toml` which is outside of project folder (`/home/imperio/rust/clippy`)
note: the lint level is defined here
--> tests/ui/include_file_outside_project.rs:1:9
|
LL | #![deny(clippy::include_file_outside_project)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

0 comments on commit dcb5724

Please sign in to comment.