mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Merge pull request #18674 from Veykril/push-lrxotqknvxvr
Show expansion errors in expand_macro feature
This commit is contained in:
commit
6aadbae022
7 changed files with 76 additions and 37 deletions
|
@ -28,6 +28,7 @@ use rustc_hash::FxHashMap;
|
|||
use stdx::TupleExt;
|
||||
use triomphe::Arc;
|
||||
|
||||
use core::fmt;
|
||||
use std::hash::Hash;
|
||||
|
||||
use base_db::{ra_salsa::InternValueTrivial, CrateId};
|
||||
|
@ -147,6 +148,10 @@ impl ExpandError {
|
|||
pub fn span(&self) -> Span {
|
||||
self.inner.1
|
||||
}
|
||||
|
||||
pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
|
||||
self.inner.0.render_to_string(db)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Hash)]
|
||||
|
@ -164,18 +169,18 @@ pub enum ExpandErrorKind {
|
|||
ProcMacroPanic(Box<str>),
|
||||
}
|
||||
|
||||
impl ExpandError {
|
||||
pub fn render_to_string(&self, db: &dyn ExpandDatabase) -> RenderedExpandError {
|
||||
self.inner.0.render_to_string(db)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct RenderedExpandError {
|
||||
pub message: String,
|
||||
pub error: bool,
|
||||
pub kind: &'static str,
|
||||
}
|
||||
|
||||
impl fmt::Display for RenderedExpandError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", self.message)
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderedExpandError {
|
||||
const GENERAL_KIND: &str = "macro-error";
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue