From aa3bf7f44cbeecce2213f25f8949c69c54855116 Mon Sep 17 00:00:00 2001 From: Shunsuke Shibayama Date: Thu, 8 Dec 2022 14:55:55 +0900 Subject: [PATCH] Make `SubMessage::msg, hint` public members --- compiler/erg_common/error.rs | 12 ++++++++---- compiler/erg_compiler/context/inquire.rs | 4 ++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/compiler/erg_common/error.rs b/compiler/erg_common/error.rs index 0b04e524..1eae297e 100644 --- a/compiler/erg_common/error.rs +++ b/compiler/erg_common/error.rs @@ -392,8 +392,8 @@ fn format_context( #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct SubMessage { pub loc: Location, - msg: Vec, - hint: Option, + pub msg: Vec, + pub hint: Option, } impl SubMessage { @@ -459,8 +459,12 @@ impl SubMessage { self.hint = Some(hint.into()); } - pub fn get_hint(self) -> Option { - self.hint + pub fn get_hint(&self) -> Option<&str> { + self.hint.as_deref() + } + + pub fn get_msg(&self) -> &[String] { + self.msg.as_ref() } // Line breaks are not included except for line breaks that signify the end of a sentence. diff --git a/compiler/erg_compiler/context/inquire.rs b/compiler/erg_compiler/context/inquire.rs index a511a1c9..5837824b 100644 --- a/compiler/erg_compiler/context/inquire.rs +++ b/compiler/erg_compiler/context/inquire.rs @@ -838,7 +838,7 @@ impl Context { // HACK: dname.loc()はダミーLocationしか返さないので、エラーならop.loc()で上書きする bin.loc(), vec![], - sub_msg.get_hint(), + sub_msg.hint, )); } let core = ErrorCore::new( @@ -886,7 +886,7 @@ impl Context { sub_msges.push(SubMessage::ambiguous_new( unary.loc(), vec![], - sub_msg.get_hint(), + sub_msg.hint, )); } let core = ErrorCore::new(