Skip to content

Commit b437240

Browse files
Replace diagnostic plugins with macro_rules
1 parent 74563b4 commit b437240

File tree

32 files changed

+87
-351
lines changed

32 files changed

+87
-351
lines changed

src/librustc/error_codes.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,11 +2184,7 @@ Examples of erroneous code:
21842184
static X: u32 = 42;
21852185
```
21862186
"##,
2187-
2188-
}
2189-
2190-
2191-
register_diagnostics! {
2187+
;
21922188
// E0006, // merged with E0005
21932189
// E0101, // replaced with E0282
21942190
// E0102, // replaced with E0282

src/librustc/lib.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ mod tests;
8888
#[macro_use]
8989
mod macros;
9090

91-
// N.B., this module needs to be declared first so diagnostics are
92-
// registered before they are used.
9391
pub mod error_codes;
9492

9593
#[macro_use]
@@ -143,6 +141,3 @@ pub mod util {
143141

144142
// Allows macros to refer to this crate as `::rustc`
145143
extern crate self as rustc;
146-
147-
// Build the diagnostics array at the end so that the metadata includes error use sites.
148-
__build_diagnostic_array! { librustc, DIAGNOSTICS }

src/librustc_codegen_llvm/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
register_long_diagnostics! {
1+
register_diagnostics! {
22

33
E0511: r##"
44
Invalid monomorphization of an intrinsic function was used. Erroneous code

src/librustc_codegen_llvm/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ impl CodegenBackend for LlvmCodegenBackend {
256256
}
257257

258258
fn diagnostics(&self) -> &[(&'static str, &'static str)] {
259-
&DIAGNOSTICS
259+
&error_codes::DIAGNOSTICS
260260
}
261261

262262
fn target_features(&self, sess: &Session) -> Vec<Symbol> {
@@ -425,5 +425,3 @@ impl Drop for ModuleLlvm {
425425
}
426426
}
427427
}
428-
429-
__build_diagnostic_array! { librustc_codegen_llvm, DIAGNOSTICS }

src/librustc_codegen_ssa/error_codes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
register_long_diagnostics! {
1+
syntax::register_diagnostics! {
22

33
E0668: r##"
44
Malformed inline assembly rejected by LLVM.

src/librustc_codegen_ssa/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ use rustc_data_structures::svh::Svh;
3535
use rustc::middle::cstore::{LibSource, CrateSource, NativeLibrary};
3636
use syntax_pos::symbol::Symbol;
3737

38-
// N.B., this module needs to be declared first so diagnostics are
39-
// registered before they are used.
4038
mod error_codes;
4139

4240
pub mod common;
@@ -158,5 +156,3 @@ pub struct CodegenResults {
158156
pub linker_info: back::linker::LinkerInfo,
159157
pub crate_info: CrateInfo,
160158
}
161-
162-
__build_diagnostic_array! { librustc_codegen_ssa, DIAGNOSTICS }

src/librustc_interface/passes.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use rustc_privacy;
3434
use rustc_resolve::{Resolver, ResolverArenas};
3535
use rustc_traits;
3636
use rustc_typeck as typeck;
37-
use syntax::{self, ast, diagnostics, visit};
37+
use syntax::{self, ast, visit};
3838
use syntax::early_buffered_lints::BufferedEarlyLint;
3939
use syntax::ext::base::{NamedSyntaxExtension, ExtCtxt};
4040
use syntax::mut_visit::MutVisitor;
@@ -292,18 +292,7 @@ pub fn register_plugins<'a>(
292292

293293
time(sess, "plugin registration", || {
294294
if sess.features_untracked().rustc_diagnostic_macros {
295-
registry.register_macro(
296-
"__diagnostic_used",
297-
diagnostics::plugin::expand_diagnostic_used,
298-
);
299-
registry.register_macro(
300-
"__register_diagnostic",
301-
diagnostics::plugin::expand_register_diagnostic,
302-
);
303-
registry.register_macro(
304-
"__build_diagnostic_array",
305-
diagnostics::plugin::expand_build_diagnostic_array,
306-
);
295+
// FIXME: remove feature gate
307296
}
308297

309298
for registrar in registrars {

src/librustc_interface/util.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ use std::{thread, panic};
4343

4444
pub fn diagnostics_registry() -> Registry {
4545
let mut all_errors = Vec::new();
46-
all_errors.extend_from_slice(&rustc::DIAGNOSTICS);
47-
all_errors.extend_from_slice(&rustc_typeck::DIAGNOSTICS);
48-
all_errors.extend_from_slice(&rustc_resolve::DIAGNOSTICS);
49-
all_errors.extend_from_slice(&rustc_privacy::DIAGNOSTICS);
46+
all_errors.extend_from_slice(&rustc::error_codes::DIAGNOSTICS);
47+
all_errors.extend_from_slice(&rustc_typeck::error_codes::DIAGNOSTICS);
48+
all_errors.extend_from_slice(&rustc_resolve::error_codes::DIAGNOSTICS);
49+
all_errors.extend_from_slice(&rustc_privacy::error_codes::DIAGNOSTICS);
5050
// FIXME: need to figure out a way to get these back in here
5151
// all_errors.extend_from_slice(get_codegen_backend(sess).diagnostics());
52-
all_errors.extend_from_slice(&rustc_metadata::DIAGNOSTICS);
53-
all_errors.extend_from_slice(&rustc_passes::DIAGNOSTICS);
54-
all_errors.extend_from_slice(&rustc_plugin::DIAGNOSTICS);
55-
all_errors.extend_from_slice(&rustc_mir::DIAGNOSTICS);
56-
all_errors.extend_from_slice(&syntax::DIAGNOSTICS);
52+
all_errors.extend_from_slice(&rustc_metadata::error_codes::DIAGNOSTICS);
53+
all_errors.extend_from_slice(&rustc_passes::error_codes::DIAGNOSTICS);
54+
all_errors.extend_from_slice(&rustc_plugin::error_codes::DIAGNOSTICS);
55+
all_errors.extend_from_slice(&rustc_mir::error_codes::DIAGNOSTICS);
56+
all_errors.extend_from_slice(&syntax::error_codes::DIAGNOSTICS);
5757

5858
Registry::new(&all_errors)
5959
}

src/librustc_lint/error_codes.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use syntax::register_diagnostics;
2-
3-
register_diagnostics! {
1+
syntax::register_diagnostics! {
2+
;
43
E0721, // `await` keyword
54
}

src/librustc_metadata/error_codes.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
use syntax::{register_diagnostics, register_long_diagnostics};
2-
3-
register_long_diagnostics! {
1+
syntax::register_diagnostics! {
42
E0454: r##"
53
A link name was given with an empty name. Erroneous code example:
64
@@ -84,10 +82,7 @@ You need to link your code to the relevant crate in order to be able to use it
8482
(through Cargo or the `-L` option of rustc example). Plugins are crates as
8583
well, and you link to them the same way.
8684
"##,
87-
88-
}
89-
90-
register_diagnostics! {
85+
;
9186
E0456, // plugin `..` is not available for triple `..`
9287
E0457, // plugin `..` only found in rlib format, but must be available...
9388
E0514, // metadata version mismatch

0 commit comments

Comments
 (0)