Skip to content

Commit

Permalink
Remove serialization of diagnostics to files
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mark-Simulacrum committed Aug 20, 2019
1 parent 99ce39b commit 72e2cfd
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 132 deletions.
3 changes: 1 addition & 2 deletions src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -825,8 +825,7 @@ impl Step for ErrorIndex {
index.arg(crate::channel::CFG_RELEASE_NUM);

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

builder.run(&mut index);
}
Expand Down
3 changes: 1 addition & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1535,8 +1535,7 @@ impl Step for ErrorIndex {
);
tool.arg("markdown")
.arg(&output)
.env("CFG_BUILD", &builder.config.build)
.env("RUSTC_ERROR_METADATA_DST", builder.extended_error_dir());
.env("CFG_BUILD", &builder.config.build);

builder.info(&format!("Testing error-index stage{}", compiler.stage));
let _time = util::timeit(&builder);
Expand Down
93 changes: 0 additions & 93 deletions src/libsyntax/diagnostics/metadata.rs

This file was deleted.

34 changes: 4 additions & 30 deletions src/libsyntax/diagnostics/plugin.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::collections::BTreeMap;
use std::env;

use crate::ast::{self, Ident, Name};
use crate::source_map;
Expand All @@ -12,8 +11,6 @@ use crate::tokenstream::{TokenTree};
use smallvec::smallvec;
use syntax_pos::Span;

use crate::diagnostics::metadata::output_metadata;

pub use errors::*;

// Maximum width of any line in an extended error description (inclusive).
Expand Down Expand Up @@ -127,36 +124,13 @@ pub fn expand_build_diagnostic_array<'cx>(ecx: &'cx mut ExtCtxt<'_>,
token_tree: &[TokenTree])
-> Box<dyn MacResult+'cx> {
assert_eq!(token_tree.len(), 3);
let (crate_name, ident) = match (&token_tree[0], &token_tree[2]) {
(
// Crate name.
&TokenTree::Token(Token { kind: token::Ident(crate_name, _), .. }),
// DIAGNOSTICS ident.
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
) => (crate_name, Ident::new(name, span)),
let ident = match &token_tree[2] {
// DIAGNOSTICS ident.
&TokenTree::Token(Token { kind: token::Ident(name, _), span })
=> Ident::new(name, span),
_ => unreachable!()
};

// Output error metadata to `tmp/extended-errors/<target arch>/<crate name>.json`
if let Ok(target_triple) = env::var("CFG_COMPILER_HOST_TRIPLE") {
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {
if let Err(e) = output_metadata(ecx,
&target_triple,
&crate_name.as_str(),
diagnostics) {
ecx.span_bug(span, &format!(
"error writing metadata for triple `{}` and crate `{}`, error: {}, \
cause: {:?}",
target_triple, crate_name, e.description(), e.source()
));
}
});
} else {
ecx.span_err(span, &format!(
"failed to write metadata for crate `{}` because $CFG_COMPILER_HOST_TRIPLE is not set",
crate_name));
}

// Construct the output expression.
let (count, expr) =
ecx.parse_sess.registered_diagnostics.with_lock(|diagnostics| {
Expand Down
1 change: 0 additions & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub mod diagnostics {
#[macro_use]
pub mod macros;
pub mod plugin;
pub mod metadata;
}

// N.B., this module needs to be declared first so diagnostics are
Expand Down
11 changes: 7 additions & 4 deletions src/tools/error_index_generator/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ use std::path::PathBuf;
use std::cell::RefCell;

use syntax::edition::DEFAULT_EDITION;
use syntax::diagnostics::metadata::{ErrorMetadataMap, ErrorMetadata};

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

pub struct ErrorMetadata {
pub description: Option<String>,
}

/// Mapping from error codes to metadata that can be (de)serialized.
pub type ErrorMetadataMap = BTreeMap<String, ErrorMetadata>;

enum OutputFormat {
HTML(HTMLFormatter),
Markdown(MarkdownFormatter),
Expand Down Expand Up @@ -214,9 +220,6 @@ fn main_with_result(format: OutputFormat, dst: &Path) -> Result<(), Box<dyn Erro
for (code, desc) in long_codes {
err_map.insert(code.to_string(), ErrorMetadata {
description: desc.map(String::from),
// FIXME: this indicates that the error code is not used, which may not be true.
// We currently do not use this information.
use_site: None,
});
}
match format {
Expand Down

0 comments on commit 72e2cfd

Please sign in to comment.