Add Rustc prefixes to derive(Decodable, Encodable).

As a bit of a hack, make `rustc_serialize` an alias of the private
`serialize` crate, just so the new derive continues working.

Fix #54287.
This commit is contained in:
Felix S. Klock II 2018-09-17 11:48:20 +02:00
parent 43061d3a78
commit 3a44115a72
6 changed files with 16 additions and 10 deletions

View file

@ -14,11 +14,12 @@
#![feature(rustc_private)]
extern crate serialize;
use serialize as rustc_serialize;
use serialize::{Encodable, Decodable};
use serialize::json;
#[derive(Encodable, Decodable)]
#[derive(RustcEncodable, RustcDecodable)]
struct A {
foo: Box<[bool]>,
}

View file

@ -16,17 +16,18 @@
#![feature(rustc_private)]
extern crate serialize;
use serialize as rustc_serialize;
use std::cell::{Cell, RefCell};
use serialize::{Encodable, Decodable};
use serialize::json;
#[derive(Encodable, Decodable)]
#[derive(RustcEncodable, RustcDecodable)]
struct A {
baz: isize
}
#[derive(Encodable, Decodable)]
#[derive(RustcEncodable, RustcDecodable)]
struct B {
foo: Cell<bool>,
bar: RefCell<A>,

View file

@ -11,6 +11,7 @@
#![feature(rustc_private)]
extern crate serialize;
use serialize as rustc_serialize;
mod submod {
// if any of these are implemented without global calls for any
@ -20,21 +21,21 @@ mod submod {
Hash,
Clone,
Debug,
Encodable, Decodable)]
RustcEncodable, RustcDecodable)]
enum A { A1(usize), A2(isize) }
#[derive(PartialEq, PartialOrd, Eq, Ord,
Hash,
Clone,
Debug,
Encodable, Decodable)]
RustcEncodable, RustcDecodable)]
struct B { x: usize, y: isize }
#[derive(PartialEq, PartialOrd, Eq, Ord,
Hash,
Clone,
Debug,
Encodable, Decodable)]
RustcEncodable, RustcDecodable)]
struct C(usize, isize);
}

View file

@ -11,6 +11,7 @@
#![allow(non_upper_case_globals)]
#![feature(rustc_private)]
extern crate serialize;
use serialize as rustc_serialize;
pub const other: u8 = 1;
pub const f: u8 = 1;
@ -19,7 +20,7 @@ pub const s: u8 = 1;
pub const state: u8 = 1;
pub const cmp: u8 = 1;
#[derive(Ord,Eq,PartialOrd,PartialEq,Debug,Decodable,Encodable,Hash)]
#[derive(Ord,Eq,PartialOrd,PartialEq,Debug,RustcDecodable,RustcEncodable,Hash)]
struct Foo {}
fn main() {

View file

@ -15,6 +15,7 @@
#![feature(rustc_private)]
extern crate serialize;
use serialize as rustc_serialize;
use std::io::Cursor;
use std::io::prelude::*;
@ -25,12 +26,12 @@ use serialize::{Encodable, Encoder};
use serialize::json;
use serialize::opaque;
#[derive(Encodable)]
#[derive(RustcEncodable)]
struct Foo {
baz: bool,
}
#[derive(Encodable)]
#[derive(RustcEncodable)]
struct Bar {
froboz: usize,
}

View file

@ -13,11 +13,12 @@
#![feature(rustc_private)]
extern crate serialize;
extern crate serialize as rustc_serialize;
use serialize::{Encodable, Decodable};
use serialize::json;
#[derive(Encodable, Decodable, PartialEq, Debug)]
#[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)]
struct UnitLikeStruct;
pub fn main() {