Rework rustc_serialize
- Move the type parameter from `encode` and `decode` methods to the trait. - Remove `UseSpecialized(En|De)codable` traits. - Remove blanket impls for references. - Add `RefDecodable` trait to allow deserializing to arena-allocated references safely. - Remove ability to (de)serialize HIR. - Create proc-macros `(Ty)?(En|De)codable` to help implement these new traits.
This commit is contained in:
parent
55b9adfafa
commit
cbcef3effc
116 changed files with 1933 additions and 1963 deletions
|
|
@ -13,6 +13,7 @@ doctest = false
|
|||
log = { package = "tracing", version = "0.1" }
|
||||
rustc_serialize = { path = "../librustc_serialize" }
|
||||
rustc_span = { path = "../librustc_span" }
|
||||
rustc_macros = { path = "../librustc_macros" }
|
||||
rustc_data_structures = { path = "../librustc_data_structures" }
|
||||
unicode-width = "0.1.4"
|
||||
atty = "0.2"
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use rustc_span::{MultiSpan, Span, DUMMY_SP};
|
|||
use std::fmt;
|
||||
|
||||
#[must_use]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub struct Diagnostic {
|
||||
pub level: Level,
|
||||
pub message: Vec<(String, Style)>,
|
||||
|
|
@ -24,14 +24,14 @@ pub struct Diagnostic {
|
|||
pub sort_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Hash, Encodable, Decodable)]
|
||||
pub enum DiagnosticId {
|
||||
Error(String),
|
||||
Lint(String),
|
||||
}
|
||||
|
||||
/// For example a note attached to an error.
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub struct SubDiagnostic {
|
||||
pub level: Level,
|
||||
pub message: Vec<(String, Style)>,
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ impl Emitter for JsonEmitter {
|
|||
|
||||
// The following data types are provided just for serialisation.
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct Diagnostic {
|
||||
/// The primary error message.
|
||||
message: String,
|
||||
|
|
@ -159,7 +159,7 @@ struct Diagnostic {
|
|||
rendered: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct DiagnosticSpan {
|
||||
file_name: String,
|
||||
byte_start: u32,
|
||||
|
|
@ -186,7 +186,7 @@ struct DiagnosticSpan {
|
|||
expansion: Option<Box<DiagnosticSpanMacroExpansion>>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct DiagnosticSpanLine {
|
||||
text: String,
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ struct DiagnosticSpanLine {
|
|||
highlight_end: usize,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct DiagnosticSpanMacroExpansion {
|
||||
/// span where macro was applied to generate this code; note that
|
||||
/// this may itself derive from a macro (if
|
||||
|
|
@ -210,7 +210,7 @@ struct DiagnosticSpanMacroExpansion {
|
|||
def_site_span: DiagnosticSpan,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct DiagnosticCode {
|
||||
/// The code itself.
|
||||
code: String,
|
||||
|
|
@ -218,7 +218,7 @@ struct DiagnosticCode {
|
|||
explanation: Option<&'static str>,
|
||||
}
|
||||
|
||||
#[derive(RustcEncodable)]
|
||||
#[derive(Encodable)]
|
||||
struct ArtifactNotification<'a> {
|
||||
/// The path of the artifact.
|
||||
artifact: &'a Path,
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ use rustc_span::{BytePos, Span};
|
|||
|
||||
use std::str;
|
||||
|
||||
#[derive(RustcDecodable, Debug, PartialEq, Eq)]
|
||||
#[derive(Decodable, Debug, PartialEq, Eq)]
|
||||
struct TestData {
|
||||
spans: Vec<SpanTestData>,
|
||||
}
|
||||
|
||||
#[derive(RustcDecodable, Debug, PartialEq, Eq)]
|
||||
#[derive(Decodable, Debug, PartialEq, Eq)]
|
||||
struct SpanTestData {
|
||||
pub byte_start: u32,
|
||||
pub byte_end: u32,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
#![feature(crate_visibility_modifier)]
|
||||
#![feature(nll)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate rustc_macros;
|
||||
|
||||
pub use emitter::ColorConfig;
|
||||
|
||||
use log::debug;
|
||||
|
|
@ -50,7 +53,7 @@ rustc_data_structures::static_assert_size!(PResult<'_, bool>, 16);
|
|||
/// All suggestions are marked with an `Applicability`. Tools use the applicability of a suggestion
|
||||
/// to determine whether it should be automatically applied or if the user should be consulted
|
||||
/// before applying the suggestion.
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub enum Applicability {
|
||||
/// The suggestion is definitely what the user intended. This suggestion should be
|
||||
/// automatically applied.
|
||||
|
|
@ -69,7 +72,7 @@ pub enum Applicability {
|
|||
Unspecified,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Encodable, Decodable)]
|
||||
pub enum SuggestionStyle {
|
||||
/// Hide the suggested code when displaying this suggestion inline.
|
||||
HideCodeInline,
|
||||
|
|
@ -94,7 +97,7 @@ impl SuggestionStyle {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub struct CodeSuggestion {
|
||||
/// Each substitute can have multiple variants due to multiple
|
||||
/// applicable suggestions
|
||||
|
|
@ -129,13 +132,13 @@ pub struct CodeSuggestion {
|
|||
pub applicability: Applicability,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
/// See the docs on `CodeSuggestion::substitutions`
|
||||
pub struct Substitution {
|
||||
pub parts: Vec<SubstitutionPart>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub struct SubstitutionPart {
|
||||
pub span: Span,
|
||||
pub snippet: String,
|
||||
|
|
@ -943,7 +946,7 @@ impl HandlerInner {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, PartialEq, Clone, Hash, Debug, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, PartialEq, Clone, Hash, Debug, Encodable, Decodable)]
|
||||
pub enum Level {
|
||||
Bug,
|
||||
Fatal,
|
||||
|
|
@ -1012,7 +1015,7 @@ macro_rules! pluralize {
|
|||
|
||||
// Useful type to use with `Result<>` indicate that an error has already
|
||||
// been reported to the user, so no need to continue checking.
|
||||
#[derive(Clone, Copy, Debug, RustcEncodable, RustcDecodable, Hash, PartialEq, Eq)]
|
||||
#[derive(Clone, Copy, Debug, Encodable, Decodable, Hash, PartialEq, Eq)]
|
||||
pub struct ErrorReported;
|
||||
|
||||
rustc_data_structures::impl_stable_hash_via_hash!(ErrorReported);
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ pub struct StyledString {
|
|||
pub style: Style,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Hash, Encodable, Decodable)]
|
||||
pub enum Style {
|
||||
MainHeaderMsg,
|
||||
HeaderMsg,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue