vendored/contracts: fix overly verbose type annotations for enum results

This fixes issue #15.
This commit is contained in:
Alain Emilia Anna Zscheile 2024-09-28 00:38:16 +02:00
parent f414089521
commit c42eab0126
5 changed files with 24 additions and 21 deletions

View File

@ -253,7 +253,7 @@ impl<M: AccessMesadata> Invoker<M> {
#[debug_requires(self.ongoing_command.is_none())] #[debug_requires(self.ongoing_command.is_none())]
fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> { fn dispatch_command(&mut self, command: &Command) -> Result<Execute, InvokerError> {
match command { Ok(match command {
Command::Autoroute(selection, options) => { Command::Autoroute(selection, options) => {
let mut ratlines = self.autorouter.selected_ratlines(selection); let mut ratlines = self.autorouter.selected_ratlines(selection);
@ -271,23 +271,23 @@ impl<M: AccessMesadata> Invoker<M> {
}); });
} }
Ok::<Execute, InvokerError>(Execute::Autoroute( Execute::Autoroute(
self.autorouter.autoroute_ratlines(ratlines, *options)?, self.autorouter.autoroute_ratlines(ratlines, *options)?,
)) )
} }
Command::PlaceVia(weight) => { Command::PlaceVia(weight) => Execute::PlaceVia(
Ok::<Execute, InvokerError>(Execute::PlaceVia(self.autorouter.place_via(*weight)?)) self.autorouter.place_via(*weight)?
} ),
Command::RemoveBands(selection) => Ok::<Execute, InvokerError>(Execute::RemoveBands( Command::RemoveBands(selection) => Execute::RemoveBands(
self.autorouter.remove_bands(selection)?, self.autorouter.remove_bands(selection)?,
)),
Command::CompareDetours(selection, options) => Ok::<Execute, InvokerError>(
Execute::CompareDetours(self.autorouter.compare_detours(selection, *options)?),
), ),
Command::MeasureLength(selection) => Ok::<Execute, InvokerError>( Command::CompareDetours(selection, options) => Execute::CompareDetours(
Execute::MeasureLength(self.autorouter.measure_length(selection)?), self.autorouter.compare_detours(selection, *options)?,
), ),
} Command::MeasureLength(selection) => Execute::MeasureLength(
self.autorouter.measure_length(selection)?,
),
})
} }
#[debug_requires(self.ongoing_command.is_none())] #[debug_requires(self.ongoing_command.is_none())]
@ -308,7 +308,7 @@ impl<M: AccessMesadata> Invoker<M> {
Command::MeasureLength(..) => {} Command::MeasureLength(..) => {}
} }
Ok::<(), InvokerError>(self.history.undo()?) Ok(self.history.undo()?)
} }
//#[debug_requires(self.ongoing.is_none())] //#[debug_requires(self.ongoing.is_none())]

View File

@ -432,7 +432,7 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
return Err(collision.into()); return Err(collision.into());
} }
Ok::<Cane, DrawingException>(cane) Ok(cane)
} }
#[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))] #[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
@ -538,7 +538,7 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
maybe_rail = self.primitive(rail).outer(); maybe_rail = self.primitive(rail).outer();
} }
Ok::<(), DrawingException>(()) Ok(())
} }
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() + 4))] #[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() + 4))]
@ -606,7 +606,7 @@ impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
err err
})?; })?;
Ok::<Cane, DrawingException>(Cane { Ok(Cane {
seg, seg,
dot: seg_to, dot: seg_to,
bend, bend,

View File

@ -62,7 +62,7 @@ impl<'a, R: AccessRules> Draw<'a, R> {
let layer = head.face().primitive(self.layout.drawing()).layer(); let layer = head.face().primitive(self.layout.drawing()).layer();
let maybe_net = head.face().primitive(self.layout.drawing()).maybe_net(); let maybe_net = head.face().primitive(self.layout.drawing()).maybe_net();
Ok::<BandTermsegIndex, DrawException>(match head.face() { Ok(match head.face() {
DotIndex::Fixed(dot) => BandTermsegIndex::Straight( DotIndex::Fixed(dot) => BandTermsegIndex::Straight(
self.layout self.layout
.add_lone_loose_seg( .add_lone_loose_seg(
@ -210,7 +210,7 @@ impl<'a, R: AccessRules> Draw<'a, R> {
}, },
cw, cw,
)?; )?;
Ok::<CaneHead, DrawingException>(CaneHead { Ok(CaneHead {
face: self face: self
.layout .layout
.drawing() .drawing()

View File

@ -83,7 +83,7 @@ impl<'a, R: AccessRules> Tracer<'a, R> {
let length = trace.path.len(); let length = trace.path.len();
self.undo_path(trace, length - prefix_length); self.undo_path(trace, length - prefix_length);
Ok::<(), TracerException>(self.path(navmesh, trace, &path[prefix_length..], width)?) self.path(navmesh, trace, &path[prefix_length..], width)
} }
#[debug_ensures(ret.is_ok() -> trace.path.len() == old(trace.path.len() + path.len()))] #[debug_ensures(ret.is_ok() -> trace.path.len() == old(trace.path.len() + path.len()))]

View File

@ -345,7 +345,10 @@ pub(crate) fn generate(
syn::visit::visit_block(&mut try_detector, &mut block); syn::visit::visit_block(&mut try_detector, &mut block);
if try_detector.found_try { if try_detector.found_try {
break 'blk quote::quote! { let ret: #return_type = 'run: { try { #block? } }; }; break 'blk quote::quote! { let ret: #return_type = 'run: { try {
let ret2: #return_type = #block;
ret2?
} }; };
} else { } else {
break 'blk quote::quote! { let ret: #return_type = 'run: #block; }; break 'blk quote::quote! { let ret: #return_type = 'run: #block; };
} }