Skip to content

Commit 45493b0

Browse files
committed
store the node content in the problem struct
Signed-off-by: lucasew <lucas59356@gmail.com>
1 parent 522a96f commit 45493b0

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/files.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,17 @@ fn check_files_top_level_with_lib(
5151
nixpkgs_path: &Path,
5252
nix_file: &nix_file::NixFile,
5353
) -> RatchetState<ratchet::DoesNotIntroduceToplevelWiths> {
54-
if let Some(_open_scope_with_lib) = find_invalid_withs(nix_file.syntax_root.syntax()) {
54+
if let Some(open_scope_with_lib) = find_invalid_withs(nix_file.syntax_root.syntax()) {
5555
RatchetState::Loose(
56-
npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new(
57-
RelativePathBuf::from_path(
58-
nix_file.path.clone().strip_prefix(nixpkgs_path).unwrap(),
56+
{
57+
npv_169::TopLevelWithMayShadowVariablesAndBreakStaticChecks::new(
58+
RelativePathBuf::from_path(
59+
nix_file.path.clone().strip_prefix(nixpkgs_path).unwrap(),
60+
)
61+
.unwrap(),
62+
open_scope_with_lib.to_string(),
5963
)
60-
.unwrap(),
61-
)
64+
}
6265
.into(),
6366
)
6467
} else {

src/problem/npv_169.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
1-
use derive_new::new;
21
use relative_path::RelativePathBuf;
32
use std::fmt;
43

5-
#[derive(Clone, new)]
4+
#[derive(Clone)]
65
pub struct TopLevelWithMayShadowVariablesAndBreakStaticChecks {
7-
#[new(into)]
86
file: RelativePathBuf,
7+
node: String,
8+
}
9+
10+
impl TopLevelWithMayShadowVariablesAndBreakStaticChecks {
11+
pub fn new(file: RelativePathBuf, node: String) -> Self {
12+
Self { file, node }
13+
}
914
}
1015

1116
impl fmt::Display for TopLevelWithMayShadowVariablesAndBreakStaticChecks {
1217
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
13-
let Self { file } = self;
18+
let Self { file, node: _node } = self;
1419
write!(f, "- {file}: Top level with is discouraged as it may shadow variables and break static checks.")
1520
}
1621
}

0 commit comments

Comments
 (0)