Skip to content

Commit

Permalink
Fix pw3_padded_arg_duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
Eathox committed Nov 9, 2024
1 parent 7f055cd commit 0c2bca2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
12 changes: 9 additions & 3 deletions libs/preprocessor/src/processor/defines.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::HashMap, sync::Arc};

use hemtt_workspace::{
position::Position,
reporting::{Output, Symbol, Token},
reporting::{Code, Output, Symbol, Token},
};
use peekmore::{PeekMore, PeekMoreIterator};

Expand Down Expand Up @@ -238,12 +238,18 @@ impl Processor {
{
for token in [value.first(), value.last()] {
if token.map_or(false, |t| t.symbol().is_whitespace()) {
self.warnings.push(Arc::new(PaddedArg::new(
let warning = PaddedArg::new(
Box::new(
(**token.expect("token exists from map_or check")).clone(),
),
ident_string.clone(),
)));
);

if !self.warnings.iter().any(|w| {
w.ident() == warning.ident() && w.token() == warning.token()
}) {
self.warnings.push(Arc::new(warning));
}
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions libs/preprocessor/tests/warnings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ fn check(dir: &str) {
.unwrap();
let warning = config
.warnings()
.first()
.unwrap()
.diagnostic()
.unwrap()
.to_string(&WorkspaceFiles::new());
.iter()
.map(|w| w.diagnostic().unwrap().to_string(&WorkspaceFiles::new()))
.collect::<String>();
if expected.is_empty() {
std::fs::write(folder.join("stderr.ansi"), warning.replace('\r', "")).unwrap();
}
Expand All @@ -66,3 +64,4 @@ bootstrap!(pw1_redefine);
bootstrap!(pw1_redefine_stack);
bootstrap!(pw3_padded_arg);
bootstrap!(pw3_padded_arg_duplicates);
bootstrap!(pw3_padded_arg_inner);

0 comments on commit 0c2bca2

Please sign in to comment.