Add constructor for Diagnostic
that takes Vec<(DiagnosticMessage, Style)>
This commit is contained in:
parent
0baac880fc
commit
39895b0716
@ -1787,8 +1787,7 @@ pub fn check(&self, sess: &Session, blocking: bool) {
|
||||
match message {
|
||||
Ok(SharedEmitterMessage::Diagnostic(diag)) => {
|
||||
let handler = sess.diagnostic();
|
||||
let mut d = rustc_errors::Diagnostic::new(diag.lvl, String::new());
|
||||
d.message = diag.msg;
|
||||
let mut d = rustc_errors::Diagnostic::new_with_messages(diag.lvl, diag.msg);
|
||||
if let Some(code) = diag.code {
|
||||
d.code(code);
|
||||
}
|
||||
|
@ -213,6 +213,21 @@ pub fn new<M: Into<DiagnosticMessage>>(level: Level, message: M) -> Self {
|
||||
Diagnostic::new_with_code(level, None, message)
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn new_with_messages(level: Level, messages: Vec<(DiagnosticMessage, Style)>) -> Self {
|
||||
Diagnostic {
|
||||
level,
|
||||
message: messages,
|
||||
code: None,
|
||||
span: MultiSpan::new(),
|
||||
children: vec![],
|
||||
suggestions: Ok(vec![]),
|
||||
args: Default::default(),
|
||||
sort_span: DUMMY_SP,
|
||||
is_lint: false,
|
||||
}
|
||||
}
|
||||
|
||||
#[track_caller]
|
||||
pub fn new_with_code<M: Into<DiagnosticMessage>>(
|
||||
level: Level,
|
||||
|
Loading…
Reference in New Issue
Block a user