Remove unused error messages

This commit is contained in:
Rob Knight 2026-04-30 17:00:05 +01:00
parent 2443f85520
commit 20204548b3
No known key found for this signature in database
2 changed files with 0 additions and 225 deletions

View file

@ -251,111 +251,6 @@ pub enum LoweringError {
ValidationErrors, ValidationErrors,
} }
/// Context information for split boundary failures
#[derive(Debug, Clone)]
pub struct SplitContext {
/// Index of the split boundary (0-based)
pub split_index: usize,
/// Range of statement indices in the segment before the split
pub statement_range: (usize, usize),
/// Public arguments coming into this segment
pub incoming_public: Vec<String>,
/// Wildcards that cross this boundary (need to be promoted)
pub crossing_wildcards: Vec<String>,
/// Total public arguments needed (incoming + crossing)
pub total_public: usize,
}
/// Suggestions for refactoring predicates that fail to split
#[derive(Debug, Clone)]
pub enum RefactorSuggestion {
/// A wildcard is used across too many statements
ReduceWildcardSpan {
wildcard: String,
first_use: usize,
last_use: usize,
span: usize,
},
/// Multiple wildcards should be grouped together
GroupWildcardUsages { wildcards: Vec<String> },
}
impl RefactorSuggestion {
pub fn format(&self) -> String {
match self {
RefactorSuggestion::ReduceWildcardSpan {
wildcard,
first_use,
last_use,
span,
} => {
format!(
"Wildcard '{}' is used across {} statements (statements {}-{}).\n\
Consider grouping all '{}' operations together, or split the wildcard\n\
into separate early/late variables.",
wildcard, span, first_use, last_use, wildcard
)
}
RefactorSuggestion::GroupWildcardUsages { wildcards } => {
format!(
"Group operations for wildcards: {}\n\
These wildcards are used across multiple segments. Try to complete\n\
all operations for each wildcard before moving to the next.",
wildcards.join(", ")
)
}
}
}
}
/// Formats a detailed error message for TooManyPublicArgsAtSplit
fn format_public_args_at_split_error(
predicate: &str,
context: &SplitContext,
max_allowed: usize,
suggestion: &Option<Box<RefactorSuggestion>>,
) -> String {
let mut msg = format!(
"Too many public arguments at split boundary {} in predicate '{}':\n",
context.split_index, predicate
);
msg.push_str(&format!(
" {} incoming public + {} crossing wildcards = {} total (exceeds max of {})\n",
context.incoming_public.len(),
context.crossing_wildcards.len(),
context.total_public,
max_allowed
));
msg.push_str(&format!(
" Statements {}-{} in this segment\n",
context.statement_range.0,
context.statement_range.1 - 1
));
if !context.incoming_public.is_empty() {
msg.push_str(&format!(
" Incoming public args: {}\n",
context.incoming_public.join(", ")
));
}
if !context.crossing_wildcards.is_empty() {
msg.push_str(&format!(
" Wildcards crossing this boundary: {}\n",
context.crossing_wildcards.join(", ")
));
}
if let Some(suggestion) = suggestion {
msg.push_str("\nSuggestion:\n");
msg.push_str(&suggestion.format());
}
msg
}
/// Batching errors from multi-batch packing /// Batching errors from multi-batch packing
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
pub enum BatchingError { pub enum BatchingError {
@ -374,32 +269,6 @@ pub enum SplittingError {
message: String, message: String,
}, },
#[error("Too many total arguments in predicate '{predicate}': {count} exceeds max of {max_allowed}. {message}")]
TooManyTotalArgs {
predicate: String,
count: usize,
max_allowed: usize,
message: String,
},
#[error("Too many total arguments in chain link {link_index} of predicate '{predicate}': {public_count} public + {private_count} private = {total_count} total (exceeds max of {max_allowed})")]
TooManyTotalArgsInChainLink {
predicate: String,
link_index: usize,
public_count: usize,
private_count: usize,
total_count: usize,
max_allowed: usize,
},
#[error("{}", format_public_args_at_split_error(.predicate, .context, *.max_allowed, .suggestion))]
TooManyPublicArgsAtSplit {
predicate: String,
context: Box<SplitContext>,
max_allowed: usize,
suggestion: Option<Box<RefactorSuggestion>>,
},
#[error("Could not split predicate '{predicate}' into a chain: no feasible partition exists with up to {max_links} links. \ #[error("Could not split predicate '{predicate}' into a chain: no feasible partition exists with up to {max_links} links. \
The predicate's wildcard structure may be too dense for any chain to fit within max_statement_args ({max_statement_args}) \ The predicate's wildcard structure may be too dense for any chain to fit within max_statement_args ({max_statement_args}) \
and max_custom_predicate_wildcards ({max_wildcards}) per link.")] and max_custom_predicate_wildcards ({max_wildcards}) per link.")]

View file

@ -907,100 +907,6 @@ mod tests {
); );
} }
#[test]
fn test_error_message_formatting() {
// Test that error messages format correctly with detailed context
// We'll manually construct the error to test the formatting
use crate::lang::error::{RefactorSuggestion, SplitContext};
let context = SplitContext {
split_index: 0,
statement_range: (0, 4),
incoming_public: vec!["A".to_string(), "B".to_string(), "C".to_string()],
crossing_wildcards: vec!["T1".to_string(), "T2".to_string(), "T3".to_string()],
total_public: 6,
};
let suggestion = Some(RefactorSuggestion::GroupWildcardUsages {
wildcards: vec!["T1".to_string(), "T2".to_string(), "T3".to_string()],
});
let error = SplittingError::TooManyPublicArgsAtSplit {
predicate: "test_pred".to_string(),
context: Box::new(context),
max_allowed: 5,
suggestion: suggestion.map(Box::new),
};
let error_msg = format!("{}", error);
// Verify the error message contains all the key information
assert!(error_msg.contains("test_pred"));
assert!(error_msg.contains("split boundary 0"));
assert!(error_msg.contains("3 incoming public"));
assert!(error_msg.contains("3 crossing wildcards"));
assert!(error_msg.contains("= 6 total"));
assert!(error_msg.contains("exceeds max of 5"));
assert!(error_msg.contains("Statements 0-3"));
assert!(error_msg.contains("Incoming public args: A, B, C"));
assert!(error_msg.contains("Wildcards crossing this boundary: T1, T2, T3"));
assert!(error_msg.contains("Suggestion:"));
assert!(error_msg.contains("Group operations for wildcards"));
eprintln!("\n=== Example Error Message ===\n{}\n", error_msg);
}
#[test]
fn test_error_too_many_total_args_formatting() {
// Test the TooManyTotalArgsInChainLink error message formatting
let error = SplittingError::TooManyTotalArgsInChainLink {
predicate: "huge_pred".to_string(),
link_index: 1,
public_count: 5,
private_count: 6,
total_count: 11,
max_allowed: 10,
};
let error_msg = format!("{}", error);
// Verify the error message includes breakdown
assert!(error_msg.contains("huge_pred"));
assert!(error_msg.contains("chain link 1"));
assert!(error_msg.contains("5 public"));
assert!(error_msg.contains("6 private"));
assert!(error_msg.contains("= 11 total"));
assert!(error_msg.contains("exceeds max of 10"));
eprintln!("\n=== Example TooManyTotalArgs Error ===\n{}\n", error_msg);
}
#[test]
fn test_refactor_suggestion_reduce_wildcard_span() {
// Test the "reduce wildcard span" suggestion formatting
use crate::lang::error::RefactorSuggestion;
let suggestion = RefactorSuggestion::ReduceWildcardSpan {
wildcard: "T".to_string(),
first_use: 0,
last_use: 7,
span: 7,
};
let suggestion_text = suggestion.format();
// Verify the suggestion formats correctly
assert!(suggestion_text.contains("'T'"));
assert!(suggestion_text.contains("used across 7 statements"));
assert!(suggestion_text.contains("statements 0-7"));
assert!(suggestion_text.contains("grouping all 'T' operations together"));
eprintln!(
"\n=== Example ReduceWildcardSpan Suggestion ===\n{}\n",
suggestion_text
);
}
// --- Regression tests --- // --- Regression tests ---
/// Statements that reference only public args should be deferred until private-wildcard /// Statements that reference only public args should be deferred until private-wildcard