From 4314f8ee30ac7d458c46f8e1ad64f95b5b950582 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Wed, 23 Aug 2023 00:25:10 -0500 Subject: [PATCH] register.rs: store context in error after str::parse() --- src/parser/instruction/encoding/register.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/parser/instruction/encoding/register.rs b/src/parser/instruction/encoding/register.rs index 18fa297..387f504 100644 --- a/src/parser/instruction/encoding/register.rs +++ b/src/parser/instruction/encoding/register.rs @@ -4,7 +4,6 @@ use super::*; use std::str::FromStr; /// A [Register] epresents [one of the MSP430 processor's registers](https://mspgcc.sourceforge.net/manual/x82.html) - #[allow(non_camel_case_types)] #[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Register { @@ -33,7 +32,12 @@ pub enum Register { impl Parsable for Register { fn parse<'text, T>(_: &Parser, stream: &mut T) -> Result where T: crate::TokenStream<'text> { - stream.expect(Type::Register).map_err(|e| e.context(stream.context()))?.lexeme().parse() + stream + .expect(Type::Register) + .map_err(|e: Error| e.context(stream.context()))? + .lexeme() + .parse() + .map_err(|e: Error| e.context(stream.context())) } }