Fix ui fulldeps tests

This commit is contained in:
Matthew Jasper 2020-07-04 16:20:24 +01:00
parent e46c58fa7e
commit 5cb4f4ed7d
12 changed files with 75 additions and 88 deletions

View File

@ -1,22 +0,0 @@
// run-pass
#![allow(dead_code)]
#![feature(rustc_private)]
#![no_std]
extern crate rustc_serialize;
#[derive(RustcEncodable)]
struct Bar {
x: u32,
}
#[derive(RustcDecodable)]
struct Baz {
x: u32,
}
fn main() {
Bar { x: 0 };
Baz { x: 0 };
}

View File

@ -1,16 +1,17 @@
// run-pass
#![allow(unused_imports)]
#![feature(box_syntax)]
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
use rustc_serialize::{Encodable, Decodable};
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::json;
use rustc_serialize::{Decodable, Encodable};
#[derive(RustcEncodable, RustcDecodable)]
#[derive(Encodable, Decodable)]
struct A {
foo: Box<[bool]>,
}

View File

@ -3,32 +3,29 @@
#![allow(unused_imports)]
// This briefly tests the capability of `Cell` and `RefCell` to implement the
// `Encodable` and `Decodable` traits via `#[derive(Encodable, Decodable)]`
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
use std::cell::{Cell, RefCell};
use rustc_serialize::{Encodable, Decodable};
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::json;
use rustc_serialize::{Decodable, Encodable};
use std::cell::{Cell, RefCell};
#[derive(RustcEncodable, RustcDecodable)]
#[derive(Encodable, Decodable)]
struct A {
baz: isize
baz: isize,
}
#[derive(RustcEncodable, RustcDecodable)]
#[derive(Encodable, Decodable)]
struct B {
foo: Cell<bool>,
bar: RefCell<A>,
}
fn main() {
let obj = B {
foo: Cell::new(true),
bar: RefCell::new( A { baz: 2 } )
};
let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) };
let s = json::encode(&obj).unwrap();
let obj2: B = json::decode(&s).unwrap();
assert_eq!(obj.foo.get(), obj2.foo.get());

View File

@ -2,33 +2,29 @@
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
mod submod {
use rustc_macros::{Decodable, Encodable};
// if any of these are implemented without global calls for any
// function calls, then being in a submodule will (correctly)
// cause errors about unrecognised module `std` (or `extra`)
#[derive(PartialEq, PartialOrd, Eq, Ord,
Hash,
Clone,
Debug,
RustcEncodable, RustcDecodable)]
enum A { A1(usize), A2(isize) }
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
enum A {
A1(usize),
A2(isize),
}
#[derive(PartialEq, PartialOrd, Eq, Ord,
Hash,
Clone,
Debug,
RustcEncodable, RustcDecodable)]
struct B { x: usize, y: isize }
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
struct B {
x: usize,
y: isize,
}
#[derive(PartialEq, PartialOrd, Eq, Ord,
Hash,
Clone,
Debug,
RustcEncodable, RustcDecodable)]
#[derive(PartialEq, PartialOrd, Eq, Ord, Hash, Clone, Debug, Encodable, Decodable)]
struct C(usize, isize);
}
pub fn main() {}

View File

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

View File

@ -3,18 +3,18 @@
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
Default, Debug, RustcEncodable, RustcDecodable)]
use rustc_macros::{Decodable, Encodable};
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug, Encodable, Decodable)]
struct S {}
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
Default, Debug, RustcEncodable, RustcDecodable)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default, Debug, Encodable, Decodable)]
struct Z();
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash,
Debug, RustcEncodable, RustcDecodable)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Encodable, Decodable)]
enum E {
V {},
U,

View File

@ -3,26 +3,27 @@
#![allow(unused_must_use)]
#![allow(dead_code)]
#![allow(unused_imports)]
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
use std::io::Cursor;
use std::io::prelude::*;
use std::fmt;
use std::io::prelude::*;
use std::io::Cursor;
use std::slice;
use rustc_serialize::{Encodable, Encoder};
use rustc_macros::Encodable;
use rustc_serialize::json;
use rustc_serialize::opaque;
use rustc_serialize::{Encodable, Encoder};
#[derive(RustcEncodable)]
#[derive(Encodable)]
struct Foo {
baz: bool,
}
#[derive(RustcEncodable)]
#[derive(Encodable)]
struct Bar {
froboz: usize,
}
@ -33,19 +34,19 @@ enum WireProtocol {
// ...
}
fn encode_json<T: Encodable>(val: &T, wr: &mut Cursor<Vec<u8>>) {
fn encode_json<T: for<'a> Encodable<json::Encoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) {
write!(wr, "{}", json::as_json(val));
}
fn encode_opaque<T: Encodable>(val: &T, wr: Vec<u8>) {
fn encode_opaque<T: Encodable<opaque::Encoder>>(val: &T, wr: Vec<u8>) {
let mut encoder = opaque::Encoder::new(wr);
val.encode(&mut encoder);
}
pub fn main() {
let target = Foo{baz: false,};
let target = Foo { baz: false };
let proto = WireProtocol::JSON;
match proto {
WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())),
WireProtocol::Opaque => encode_opaque(&target, Vec::new())
WireProtocol::Opaque => encode_opaque(&target, Vec::new()),
}
}

View File

@ -4,12 +4,14 @@
#![allow(unused_imports)]
#![feature(rustc_private)]
extern crate rustc_macros;
extern crate rustc_serialize;
use rustc_serialize::{Encodable, Decodable};
use rustc_macros::{Decodable, Encodable};
use rustc_serialize::json;
use rustc_serialize::{Decodable, Encodable};
#[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)]
#[derive(Encodable, Decodable, PartialEq, Debug)]
struct UnitLikeStruct;
pub fn main() {

View File

@ -3,20 +3,19 @@
#![allow(unused_imports)]
#![allow(unused_must_use)]
// pretty-expanded FIXME #23616
#![feature(rustc_private)]
extern crate rustc_serialize;
use std::fmt;
use rustc_serialize::{Encoder, Encodable};
use rustc_serialize::json;
use rustc_serialize::{Encodable, Encoder};
use std::fmt;
struct Foo<T: Encodable> {
struct Foo<T: for<'a> Encodable<json::Encoder<'a>>> {
v: T,
}
impl<T: Encodable> Drop for Foo<T> {
impl<T: for<'a> Encodable<json::Encoder<'a>>> Drop for Foo<T> {
fn drop(&mut self) {
json::encode(&self.v);
}

View File

@ -5,11 +5,18 @@
extern crate rustc_serialize;
use rustc_serialize::{Encodable, Decodable};
use rustc_serialize::{json, Decodable, Encodable};
use std::fmt::Display;
pub trait Entity : Decodable + Encodable + Sized {
type Key: Clone + Decodable + Encodable + ToString + Display + Eq + Ord + Sized;
pub trait Entity: Decodable<json::Decoder> + for<'a> Encodable<json::Encoder<'a>> + Sized {
type Key: Clone
+ Decodable<json::Decoder>
+ for<'a> Encodable<json::Encoder<'a>>
+ ToString
+ Display
+ Eq
+ Ord
+ Sized;
fn id(&self) -> Self::Key;
@ -20,7 +27,10 @@ pub struct DbRef<E: Entity> {
pub id: E::Key,
}
impl<E> DbRef<E> where E: Entity {
impl<E> DbRef<E>
where
E: Entity,
{
fn get(self) -> Option<E> {
E::find_by_id(self.id)
}

View File

@ -1,14 +1,13 @@
// run-pass
#![allow(dead_code)]
#![feature(rustc_private)]
extern crate rustc_serialize;
use rustc_serialize::{json, Decodable};
trait JD : Decodable {}
trait JD: Decodable<json::Decoder> {}
fn exec<T: JD>() {
let doc = json::from_str("").unwrap();

View File

@ -2,11 +2,13 @@
#![feature(rustc_private)]
extern crate rustc_macros;
#[allow(dead_code)]
extern crate rustc_serialize;
#[derive(RustcDecodable, RustcEncodable,Debug)]
use rustc_macros::{Decodable, Encodable};
#[derive(Decodable, Encodable, Debug)]
struct A {
a: String,
}