tamer: pipeline: Remove explicit error specification in pipeline definition

It does not matter what the error of the source is as long as the caller is
able to deal with it, especially given that the particular error is a
property of the source, which is under control of the caller.

DEV-13162
main
Mike Gerwitz 2023-06-02 15:05:26 -04:00
parent 3800109530
commit 0e0f3e658d
3 changed files with 16 additions and 17 deletions

View File

@ -106,8 +106,9 @@ fn load_xmlo<P: AsRef<Path>, S: Escaper>(
let src = &mut lowerable(XmlXirReader::new(file, escaper, ctx));
let (mut state, mut air_ctx) =
pipeline::load_xmlo::<TameldError, _>(src, state, air_ctx, identity)?;
let (mut state, mut air_ctx) = pipeline::load_xmlo::<_, TameldError, _>(
src, state, air_ctx, identity,
)?;
let mut dir = path;
dir.pop();

View File

@ -40,8 +40,6 @@
//! For information on the lowering pipeline as an abstraction,
//! see [`Lower`].
use std::convert::Infallible;
use crate::{
asg::{air::AirAggregate, visit::TreeWalkRel, AsgTreeToXirf},
diagnose::Diagnostic,
@ -54,7 +52,7 @@ use crate::{
xir::{
autoclose::XirfAutoClose,
flat::{PartialXirToXirf, RefinedText, Text, XirToXirf, XirfToXir},
Error as XirError, Token as XirToken,
Token as XirToken,
},
};
@ -73,7 +71,7 @@ lower_pipeline! {
/// TODO: To re-use this in `tamec` we want to be able to ignore fragments.
///
/// TODO: More documentation once this has been further cleaned up.
pub load_xmlo(XirToken, XirError)
pub load_xmlo(XirToken)
|> PartialXirToXirf<4, Text>
|> XmloReader
|> XmloToAir[xmlo_ctx], until (XmloToken::Eoh(..))
@ -83,7 +81,7 @@ lower_pipeline! {
/// source language.
///
/// TODO: More documentation once this has been further cleaned up.
pub parse_package_xml(XirToken, XirError)
pub parse_package_xml(XirToken)
|> XirToXirf<64, RefinedText>
|> XirfToNir
|> TplShortDesugar
@ -95,7 +93,7 @@ lower_pipeline! {
/// `xmli` file.
///
/// TODO: More documentation once this has been further cleaned up.
pub lower_xmli<'a>(TreeWalkRel, Infallible)
pub lower_xmli<'a>(TreeWalkRel)
|> AsgTreeToXirf<'a>[asg]
|> XirfAutoClose
|> XirfToXir<Text>;

View File

@ -42,12 +42,12 @@
macro_rules! lower_pipeline {
($(
$(#[$meta:meta])*
$vis:vis $fn:ident$(<$l:lifetime>)?($srcobj:ty, $srcerr:ty)
$vis:vis $fn:ident$(<$l:lifetime>)?($srcobj:ty)
$(|> $lower:ty $([$ctx:ident])? $(, until ($until:pat))?)*;
)*) => {$(
$(#[$meta])*
$vis fn $fn<$($l,)? ER: Diagnostic, EU: Diagnostic>(
src: impl LowerSource<UnknownToken, $srcobj, $srcerr>,
$vis fn $fn<$($l,)? ES: Diagnostic, ER: Diagnostic, EU: Diagnostic>(
src: impl LowerSource<UnknownToken, $srcobj, ES>,
$(
// Each parser may optionally receive context from an
// earlier run.
@ -75,7 +75,7 @@ macro_rules! lower_pipeline {
// We need to support widening into this error type from every
// individual ParseState in this pipeline,
// plus the source.
ER: From<ParseError<UnknownToken, $srcerr>>
ER: From<ParseError<UnknownToken, ES>>
$(
+ From<ParseError<
<$lower as ParseState>::Token,
@ -93,7 +93,7 @@ macro_rules! lower_pipeline {
EU: From<FinalizeError>,
{
let lower_pipeline!(@ret_pat $($($ctx)?)*) = lower_pipeline!(
@body_head(src, $srcobj, $srcerr, sink)
@body_head(src, $srcobj, sink)
$((|> $lower $([$ctx])? $(, until ($until))?))*
)?;
@ -131,11 +131,11 @@ macro_rules! lower_pipeline {
// This doesn't support context or `until`;
// it can be added if ever it is needed.
(
@body_head($src:ident, $srcobj:ty, $srcerr:ty, $sink:ident)
@body_head($src:ident, $srcobj:ty, $sink:ident)
(|> $head:ty) $($rest:tt)*
) => {
Lower::<
ParsedObject<UnknownToken, $srcobj, $srcerr>,
ParsedObject<UnknownToken, $srcobj, ES>,
$head,
ER,
>::lower::<_, EU>(&mut $src.map(|result| result.map_err(ER::from)), |next| {
@ -148,11 +148,11 @@ macro_rules! lower_pipeline {
// TODO: Roll this into the above
(
@body_head($src:ident, $srcobj:ty, $srcerr:ty, $sink:ident)
@body_head($src:ident, $srcobj:ty, $sink:ident)
(|> $head:ty [$ctx:ident]) $($rest:tt)*
) => {
Lower::<
ParsedObject<UnknownToken, $srcobj, $srcerr>,
ParsedObject<UnknownToken, $srcobj, ES>,
$head,
ER,
>::lower_with_context::<_, EU>(