Skip to content

Commit 72e2cfd

Browse files
Remove serialization of diagnostics to files
This is no longer used by the index generator and was always an unstable compiler detail, so strip it out. This also leaves in RUSTC_ERROR_METADATA_DST since the stage0 compiler still needs it to be set.
1 parent 99ce39b commit 72e2cfd

File tree

6 files changed

+13
-132
lines changed

6 files changed

+13
-132
lines changed

src/bootstrap/doc.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -825,8 +825,7 @@ impl Step for ErrorIndex {
825825
index.arg(crate::channel::CFG_RELEASE_NUM);
826826

827827
// FIXME: shouldn't have to pass this env var
828-
index.env("CFG_BUILD", &builder.config.build)
829-
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
828+
index.env("CFG_BUILD", &builder.config.build);
830829

831830
builder.run(&mut index);
832831
}

src/bootstrap/test.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1535,8 +1535,7 @@ impl Step for ErrorIndex {
15351535
);
15361536
tool.arg("markdown")
15371537
.arg(&output)
1538-
.env("CFG_BUILD", &builder.config.build)
1539-
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
1538+
.env("CFG_BUILD", &builder.config.build);
15401539

15411540
builder.info(&format!("Testing error-index stage{}", compiler.stage));
15421541
let _time = util::timeit(&builder);

src/libsyntax/diagnostics/metadata.rs

-93
This file was deleted.

src/libsyntax/diagnostics/plugin.rs

+4-30
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use std::collections::BTreeMap;
2-
use std::env;
32

43
use crate::ast::{self, Ident, Name};
54
use crate::source_map;
@@ -12,8 +11,6 @@ use crate::tokenstream::{TokenTree};
1211
use smallvec::smallvec;
1312
use syntax_pos::Span;
1413

15-
use crate::diagnostics::metadata::output_metadata;
16-
1714
pub use errors::*;
1815

1916
// Maximum width of any line in an extended error description (inclusive).
@@ -127,36 +124,13 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt<'_>,
127124
token_tree: &[TokenTree])
128125
-> Box<dyn MacResult+'cx> {
129126
assert_eq!(token_tree.len(), 3);
130-
let (crate_name, ident) = match (&token_tree[0], &token_tree[2]) {
131-
(
132-
// Crate name.
133-
&TokenTree::Token(Token { kind: token::Ident(crate_name, _), .. }),
134-
// DIAGNOSTICS ident.
135-
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
136-
) => (crate_name, Ident::new(name, span)),
127+
let ident = match &token_tree[2] {
128+
// DIAGNOSTICS ident.
129+
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
130+
=> Ident::new(name, span),
137131
_ => unreachable!()
138132
};
139133

140-
// Output error metadata to `tmp/extended-errors/<target arch>/<crate name>.json`
141-
if let Ok(target_triple) = env::var("CFG_COMPILER_HOST_TRIPLE") {
142-
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {
143-
if let Err(e) = output_metadata(ecx,
144-
&target_triple,
145-
&crate_name.as_str(),
146-
diagnostics) {
147-
ecx.span_bug(span, &format!(
148-
"error writing metadata for triple `{}` and crate `{}`, error: {}, \
149-
cause: {:?}",
150-
target_triple, crate_name, e.description(), e.source()
151-
));
152-
}
153-
});
154-
} else {
155-
ecx.span_err(span, &format!(
156-
"failed to write metadata for crate `{}` because $CFG_COMPILER_HOST_TRIPLE is not set",
157-
crate_name));
158-
}
159-
160134
// Construct the output expression.
161135
let (count, expr) =
162136
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {

src/libsyntax/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ pub mod diagnostics {
124124
#[macro_use]
125125
pub mod macros;
126126
pub mod plugin;
127-
pub mod metadata;
128127
}
129128

130129
// N.B., this module needs to be declared first so diagnostics are

src/tools/error_index_generator/main.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,16 @@ use std::path::PathBuf;
1313
use std::cell::RefCell;
1414

1515
use syntax::edition::DEFAULT_EDITION;
16-
use syntax::diagnostics::metadata::{ErrorMetadataMap, ErrorMetadata};
1716

1817
use rustdoc::html::markdown::{Markdown, IdMap, ErrorCodes, Playground};
1918

19+
pub struct ErrorMetadata {
20+
pub description: Option<String>,
21+
}
22+
23+
/// Mapping from error codes to metadata that can be (de)serialized.
24+
pub type ErrorMetadataMap = BTreeMap<String, ErrorMetadata>;
25+
2026
enum OutputFormat {
2127
HTML(HTMLFormatter),
2228
Markdown(MarkdownFormatter),
@@ -214,9 +220,6 @@ fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<dyn Erro
214220
for (code, desc) in long_codes {
215221
err_map.insert(code.to_string(), ErrorMetadata {
216222
description: desc.map(String::from),
217-
// FIXME: this indicates that the error code is not used, which may not be true.
218-
// We currently do not use this information.
219-
use_site: None,
220223
});
221224
}
222225
match format {

0 commit comments

Comments
 (0)