Skip to content

Commit c1918fc

Browse files
committed
Auto merge of rust-lang#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`
2 parents 3e358a6 + 2c7f2c1 commit c1918fc

File tree

1 file changed

+4
-55
lines changed

1 file changed

+4
-55
lines changed

crates/proc-macro-srv/src/abis/abi_sysroot/ra_server.rs

Lines changed: 4 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -37,23 +37,6 @@ pub struct SourceFile {
3737
type Level = super::proc_macro::Level;
3838
type LineColumn = super::proc_macro::LineColumn;
3939

40-
/// A structure representing a diagnostic message and associated children
41-
/// messages.
42-
#[derive(Clone, Debug)]
43-
pub struct Diagnostic {
44-
level: Level,
45-
message: String,
46-
spans: Vec<Span>,
47-
children: Vec<Diagnostic>,
48-
}
49-
50-
impl Diagnostic {
51-
/// Creates a new diagnostic with the given `level` and `message`.
52-
pub fn new<T: Into<String>>(level: Level, message: T) -> Diagnostic {
53-
Diagnostic { level, message: message.into(), spans: vec![], children: vec![] }
54-
}
55-
}
56-
5740
pub struct FreeFunctions;
5841

5942
#[derive(Default)]
@@ -65,8 +48,6 @@ impl server::Types for RustAnalyzer {
6548
type FreeFunctions = FreeFunctions;
6649
type TokenStream = TokenStream;
6750
type SourceFile = SourceFile;
68-
type MultiSpan = Vec<Span>;
69-
type Diagnostic = Diagnostic;
7051
type Span = Span;
7152
type Symbol = Symbol;
7253
}
@@ -90,6 +71,10 @@ impl server::FreeFunctions for RustAnalyzer {
9071
span: tt::TokenId::unspecified(),
9172
})
9273
}
74+
75+
fn emit_diagnostic(&mut self, _: bridge::Diagnostic<Self::Span>) {
76+
// FIXME handle diagnostic
77+
}
9378
}
9479

9580
impl server::TokenStream for RustAnalyzer {
@@ -282,30 +267,6 @@ impl server::SourceFile for RustAnalyzer {
282267
}
283268
}
284269

285-
impl server::Diagnostic for RustAnalyzer {
286-
fn new(&mut self, level: Level, msg: &str, spans: Self::MultiSpan) -> Self::Diagnostic {
287-
let mut diag = Diagnostic::new(level, msg);
288-
diag.spans = spans;
289-
diag
290-
}
291-
292-
fn sub(
293-
&mut self,
294-
_diag: &mut Self::Diagnostic,
295-
_level: Level,
296-
_msg: &str,
297-
_spans: Self::MultiSpan,
298-
) {
299-
// FIXME handle diagnostic
300-
//
301-
}
302-
303-
fn emit(&mut self, _diag: Self::Diagnostic) {
304-
// FIXME handle diagnostic
305-
// diag.emit()
306-
}
307-
}
308-
309270
impl server::Span for RustAnalyzer {
310271
fn debug(&mut self, span: Self::Span) -> String {
311272
format!("{:?}", span.0)
@@ -372,18 +333,6 @@ impl server::Span for RustAnalyzer {
372333
}
373334
}
374335

375-
impl server::MultiSpan for RustAnalyzer {
376-
fn new(&mut self) -> Self::MultiSpan {
377-
// FIXME handle span
378-
vec![]
379-
}
380-
381-
fn push(&mut self, other: &mut Self::MultiSpan, span: Self::Span) {
382-
//TODP
383-
other.push(span)
384-
}
385-
}
386-
387336
impl server::Symbol for RustAnalyzer {
388337
fn normalize_and_validate_ident(&mut self, string: &str) -> Result<Self::Symbol, ()> {
389338
// FIXME: nfc-normalize and validate idents

0 commit comments

Comments
 (0)