fix(runtime): restore tooling coverage and allow atomic release ordering
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
Intrepid/Prometeu/Runtime/pipeline/head This commit looks good
This commit is contained in:
@@ -66,8 +66,8 @@ fn test_no_legacy_artifacts() {
|
||||
let stripped = strip_comments_and_strings(&content);
|
||||
let toks = tokenize_identifiers(&stripped);
|
||||
|
||||
for (tok, line, col) in toks {
|
||||
if is_forbidden_ident(&tok) {
|
||||
for (tok, line, col, offset) in toks {
|
||||
if is_forbidden_ident(&tok, &stripped[..offset]) {
|
||||
violations.insert(format!(
|
||||
"{}:{}:{} identifier '{}': legacy token",
|
||||
rel(&workspace_root, path),
|
||||
@@ -167,11 +167,21 @@ fn path_segment_violation(path: &Path) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
fn is_forbidden_ident(tok: &str) -> bool {
|
||||
fn is_forbidden_ident(tok: &str, prefix: &str) -> bool {
|
||||
// The standard atomic ordering is unrelated to the removed RC API.
|
||||
if tok == "Release" {
|
||||
if let Some(owner) = prefix.trim_end().strip_suffix("::") {
|
||||
if let Some(before_owner) = owner.trim_end().strip_suffix("Ordering") {
|
||||
if !before_owner.chars().last().is_some_and(is_ident_part) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FORBIDDEN_IDENT_TOKENS.contains(&tok)
|
||||
}
|
||||
|
||||
fn tokenize_identifiers(text: &str) -> Vec<(String, usize, usize)> {
|
||||
fn tokenize_identifiers(text: &str) -> Vec<(String, usize, usize, usize)> {
|
||||
let mut out = Vec::new();
|
||||
let mut line: usize = 1;
|
||||
let mut col: usize = 1;
|
||||
@@ -203,7 +213,7 @@ fn tokenize_identifiers(text: &str) -> Vec<(String, usize, usize)> {
|
||||
}
|
||||
}
|
||||
let tok = &text[start..i];
|
||||
out.push((tok.to_string(), start_line, start_col));
|
||||
out.push((tok.to_string(), start_line, start_col, start));
|
||||
} else {
|
||||
i += 1;
|
||||
col += 1;
|
||||
@@ -391,3 +401,41 @@ mod pathdiff {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn atomic_release_ordering_is_not_a_legacy_rc_identifier() {
|
||||
for source in [
|
||||
"flag.store(false, Ordering::Release);",
|
||||
"flag.store(false, std::sync::atomic::Ordering::Release);",
|
||||
"flag.store(false, Ordering /* comment */ ::\n Release);",
|
||||
] {
|
||||
let stripped = strip_comments_and_strings(source);
|
||||
assert!(
|
||||
tokenize_identifiers(&stripped)
|
||||
.iter()
|
||||
.all(|(tok, _, _, offset)| { !is_forbidden_ident(tok, &stripped[..*offset]) }),
|
||||
"{source}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn atomic_ordering_exception_does_not_admit_legacy_identifiers() {
|
||||
for source in [
|
||||
"fn release() {}",
|
||||
"enum Legacy { Release }",
|
||||
"CustomOrdering::Release",
|
||||
"Ordering; struct Release;",
|
||||
"Ordering::release()",
|
||||
"Ordering::HIP",
|
||||
"Ordering::enter_scope()",
|
||||
] {
|
||||
let stripped = strip_comments_and_strings(source);
|
||||
assert!(
|
||||
tokenize_identifiers(&stripped)
|
||||
.iter()
|
||||
.any(|(tok, _, _, offset)| { is_forbidden_ident(tok, &stripped[..*offset]) }),
|
||||
"{source}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user