Revert PRs for 0.99.1 patch (#14119)

# Description

Temporarily reverts PRs merged after the 0.99.1 bump.
This commit is contained in:
Ian Manske
2024-10-17 19:51:14 -07:00
committed by GitHub
parent e735bd475f
commit 28b6db115a
33 changed files with 287 additions and 782 deletions

View File

@ -115,8 +115,8 @@ impl Display for Operator {
Operator::Comparison(Comparison::NotEqual) => write!(f, "!="),
Operator::Comparison(Comparison::LessThan) => write!(f, "<"),
Operator::Comparison(Comparison::GreaterThan) => write!(f, ">"),
Operator::Comparison(Comparison::RegexMatch) => write!(f, "=~ or like"),
Operator::Comparison(Comparison::NotRegexMatch) => write!(f, "!~ or not-like"),
Operator::Comparison(Comparison::RegexMatch) => write!(f, "=~"),
Operator::Comparison(Comparison::NotRegexMatch) => write!(f, "!~"),
Operator::Comparison(Comparison::LessThanOrEqual) => write!(f, "<="),
Operator::Comparison(Comparison::GreaterThanOrEqual) => write!(f, ">="),
Operator::Comparison(Comparison::StartsWith) => write!(f, "starts-with"),

View File

@ -139,23 +139,6 @@ impl LabeledError {
self
}
pub fn render_error_to_string(diag: impl miette::Diagnostic, fancy_errors: bool) -> String {
let theme = if fancy_errors {
miette::GraphicalTheme::unicode()
} else {
miette::GraphicalTheme::none()
};
let mut out = String::new();
miette::GraphicalReportHandler::new()
.with_width(80)
.with_theme(theme)
.render_report(&mut out, &diag)
.unwrap_or_default();
out
}
/// Create a [`LabeledError`] from a type that implements [`miette::Diagnostic`].
///
/// # Example

View File

@ -1474,16 +1474,13 @@ impl ShellError {
self.external_exit_code().map(|e| e.item).unwrap_or(1)
}
pub fn into_value(self, span: Span, fancy_errors: bool) -> Value {
pub fn into_value(self, span: Span) -> Value {
let exit_code = self.external_exit_code();
let mut record = record! {
"msg" => Value::string(self.to_string(), span),
"debug" => Value::string(format!("{self:?}"), span),
"raw" => Value::error(self.clone(), span),
// "labeled_error" => Value::string(LabeledError::from_diagnostic_and_render(self.clone()), span),
"rendered" => Value::string(ShellError::render_error_to_string(self.clone(), fancy_errors), span),
"json" => Value::string(serde_json::to_string(&self).expect("Could not serialize error"), span),
"raw" => Value::error(self, span),
};
if let Some(code) = exit_code {
@ -1502,21 +1499,6 @@ impl ShellError {
span,
)
}
pub fn render_error_to_string(diag: impl miette::Diagnostic, fancy_errors: bool) -> String {
let theme = if fancy_errors {
miette::GraphicalTheme::unicode()
} else {
miette::GraphicalTheme::none()
};
let mut out = String::new();
miette::GraphicalReportHandler::new()
.with_width(80)
.with_theme(theme)
.render_report(&mut out, &diag)
.unwrap_or_default();
out
}
}
impl From<io::Error> for ShellError {

View File

@ -161,25 +161,20 @@ impl Module {
}
let span = self.span.unwrap_or(backup_span);
// only needs to bring `$module` with a record value if it defines any constants.
let constants = if const_rows.is_empty() {
vec![]
} else {
vec![(
final_name.clone(),
Value::record(
const_rows
.into_iter()
.map(|(name, val)| (String::from_utf8_lossy(&name).to_string(), val))
.collect(),
span,
),
)]
};
let const_record = Value::record(
const_rows
.into_iter()
.map(|(name, val)| (String::from_utf8_lossy(&name).to_string(), val))
.collect(),
span,
);
return (
ResolvedImportPattern::new(decls, vec![(final_name.clone(), self_id)], constants),
ResolvedImportPattern::new(
decls,
vec![(final_name.clone(), self_id)],
vec![(final_name, const_record)],
),
errors,
);
};