Remove --extern-location
and all associated code
`--extern-location` was an experiment to investigate the best way to generate useful diagnostics for unused dependency warnings by enabling a build system to identify the corresponding build config. While I did successfully use this, I've since been convinced the alternative `--json unused-externs` mechanism is the way to go, and there's no point in having two mechanisms with basically the same functionality. This effectively reverts https://github.com/rust-lang/rust/pull/72603
This commit is contained in:
parent
e7575f9670
commit
1be1157d75
36 changed files with 6 additions and 517 deletions
|
@ -14,7 +14,6 @@ use rustc_span::source_map::{FilePathMapping, SourceMap};
|
|||
use crate::emitter::{Emitter, HumanReadableErrorType};
|
||||
use crate::registry::Registry;
|
||||
use crate::DiagnosticId;
|
||||
use crate::ToolMetadata;
|
||||
use crate::{
|
||||
CodeSuggestion, FluentBundle, LazyFallbackBundle, MultiSpan, SpanLabel, SubDiagnostic,
|
||||
};
|
||||
|
@ -30,7 +29,6 @@ use std::sync::{Arc, Mutex};
|
|||
use std::vec;
|
||||
|
||||
use rustc_serialize::json::{as_json, as_pretty_json};
|
||||
use rustc_serialize::{Encodable, Encoder};
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -205,8 +203,7 @@ impl Emitter for JsonEmitter {
|
|||
|
||||
// The following data types are provided just for serialisation.
|
||||
|
||||
// NOTE: this has a manual implementation of Encodable which needs to be updated in
|
||||
// parallel.
|
||||
#[derive(Encodable)]
|
||||
struct Diagnostic {
|
||||
/// The primary error message.
|
||||
message: String,
|
||||
|
@ -218,65 +215,6 @@ struct Diagnostic {
|
|||
children: Vec<Diagnostic>,
|
||||
/// The message as rustc would render it.
|
||||
rendered: Option<String>,
|
||||
/// Extra tool metadata
|
||||
tool_metadata: ToolMetadata,
|
||||
}
|
||||
|
||||
macro_rules! encode_fields {
|
||||
(
|
||||
$enc:expr, // encoder
|
||||
$idx:expr, // starting field index
|
||||
$struct:expr, // struct we're serializing
|
||||
$struct_name:ident, // struct name
|
||||
[ $($name:ident),+$(,)? ], // fields to encode
|
||||
[ $($ignore:ident),+$(,)? ] // fields we're skipping
|
||||
) => {
|
||||
{
|
||||
// Pattern match to make sure all fields are accounted for
|
||||
let $struct_name { $($name,)+ $($ignore: _,)+ } = $struct;
|
||||
let mut idx = $idx;
|
||||
$(
|
||||
$enc.emit_struct_field(
|
||||
stringify!($name),
|
||||
idx == 0,
|
||||
|enc| $name.encode(enc),
|
||||
)?;
|
||||
idx += 1;
|
||||
)+
|
||||
idx
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Special-case encoder to skip tool_metadata if not set
|
||||
impl<E: Encoder> Encodable<E> for Diagnostic {
|
||||
fn encode(&self, s: &mut E) -> Result<(), E::Error> {
|
||||
s.emit_struct(false, |s| {
|
||||
let mut idx = 0;
|
||||
|
||||
idx = encode_fields!(
|
||||
s,
|
||||
idx,
|
||||
self,
|
||||
Self,
|
||||
[message, code, level, spans, children, rendered],
|
||||
[tool_metadata]
|
||||
);
|
||||
if self.tool_metadata.is_set() {
|
||||
idx = encode_fields!(
|
||||
s,
|
||||
idx,
|
||||
self,
|
||||
Self,
|
||||
[tool_metadata],
|
||||
[message, code, level, spans, children, rendered]
|
||||
);
|
||||
}
|
||||
|
||||
let _ = idx;
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Encodable)]
|
||||
|
@ -380,7 +318,6 @@ impl Diagnostic {
|
|||
spans: DiagnosticSpan::from_suggestion(sugg, &args, je),
|
||||
children: vec![],
|
||||
rendered: None,
|
||||
tool_metadata: sugg.tool_metadata.clone(),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -428,7 +365,6 @@ impl Diagnostic {
|
|||
.chain(sugg)
|
||||
.collect(),
|
||||
rendered: Some(output),
|
||||
tool_metadata: ToolMetadata::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -449,7 +385,6 @@ impl Diagnostic {
|
|||
.unwrap_or_else(|| DiagnosticSpan::from_multispan(&diag.span, args, je)),
|
||||
children: vec![],
|
||||
rendered: None,
|
||||
tool_metadata: ToolMetadata::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue