mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 17:53:56 +00:00
Auto merge of #100210 - mystor:proc_macro_diag_struct, r=eddyb
proc_macro/bridge: send diagnostics over the bridge as a struct This removes some RPC when creating and emitting diagnostics, and simplifies the bridge slightly. After this change, there are no remaining methods which take advantage of the support for `&mut` references to objects in the store as arguments, meaning that support for them could technically be removed if we wanted. The only remaining uses of immutable references into the store are `TokenStream` and `SourceFile`. r? `@eddyb`
This commit is contained in:
commit
c1918fcb9a
@ -37,23 +37,6 @@ pub struct SourceFile {
|
|||||||
type Level = super::proc_macro::Level;
|
type Level = super::proc_macro::Level;
|
||||||
type LineColumn = super::proc_macro::LineColumn;
|
type LineColumn = super::proc_macro::LineColumn;
|
||||||
|
|
||||||
/// A structure representing a diagnostic message and associated children
|
|
||||||
/// messages.
|
|
||||||
#[derive(Clone, Debug)]
|
|
||||||
pub struct Diagnostic {
|
|
||||||
level: Level,
|
|
||||||
message: String,
|
|
||||||
spans: Vec<Span>,
|
|
||||||
children: Vec<Diagnostic>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Diagnostic {
|
|
||||||
/// Creates a new diagnostic with the given `level` and `message`.
|
|
||||||
pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
|
|
||||||
Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct FreeFunctions;
|
pub struct FreeFunctions;
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
@ -65,8 +48,6 @@ impl server::Types for RustAnalyzer {
|
|||||||
type FreeFunctions = FreeFunctions;
|
type FreeFunctions = FreeFunctions;
|
||||||
type TokenStream = TokenStream;
|
type TokenStream = TokenStream;
|
||||||
type SourceFile = SourceFile;
|
type SourceFile = SourceFile;
|
||||||
type MultiSpan = Vec<Span>;
|
|
||||||
type Diagnostic = Diagnostic;
|
|
||||||
type Span = Span;
|
type Span = Span;
|
||||||
type Symbol = Symbol;
|
type Symbol = Symbol;
|
||||||
}
|
}
|
||||||
@ -90,6 +71,10 @@ impl server::FreeFunctions for RustAnalyzer {
|
|||||||
span: tt::TokenId::unspecified(),
|
span: tt::TokenId::unspecified(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn emit_diagnostic(&mut self, _: bridge::Diagnostic<Self::Span>) {
|
||||||
|
// FIXME handle diagnostic
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl server::TokenStream for RustAnalyzer {
|
impl server::TokenStream for RustAnalyzer {
|
||||||
@ -282,30 +267,6 @@ impl server::SourceFile for RustAnalyzer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl server::Diagnostic for RustAnalyzer {
|
|
||||||
fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic {
|
|
||||||
let mut diag = Diagnostic::new(level, msg);
|
|
||||||
diag.spans = spans;
|
|
||||||
diag
|
|
||||||
}
|
|
||||||
|
|
||||||
fn sub(
|
|
||||||
&mut self,
|
|
||||||
_diag: &mut Self::Diagnostic,
|
|
||||||
_level: Level,
|
|
||||||
_msg: &str,
|
|
||||||
_spans: Self::MultiSpan,
|
|
||||||
) {
|
|
||||||
// FIXME handle diagnostic
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
fn emit(&mut self, _diag: Self::Diagnostic) {
|
|
||||||
// FIXME handle diagnostic
|
|
||||||
// diag.emit()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl server::Span for RustAnalyzer {
|
impl server::Span for RustAnalyzer {
|
||||||
fn debug(&mut self, span: Self::Span) -> String {
|
fn debug(&mut self, span: Self::Span) -> String {
|
||||||
format!("{:?}", span.0)
|
format!("{:?}", span.0)
|
||||||
@ -372,18 +333,6 @@ impl server::Span for RustAnalyzer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl server::MultiSpan for RustAnalyzer {
|
|
||||||
fn new(&mut self) -> Self::MultiSpan {
|
|
||||||
// FIXME handle span
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn push(&mut self, other: &mut Self::MultiSpan, span: Self::Span) {
|
|
||||||
//TODP
|
|
||||||
other.push(span)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl server::Symbol for RustAnalyzer {
|
impl server::Symbol for RustAnalyzer {
|
||||||
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
|
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
|
||||||
// FIXME: nfc-normalize and validate idents
|
// FIXME: nfc-normalize and validate idents
|
||||||
|
Loading…
Reference in New Issue
Block a user