auto merge of #20365 : nick29581/rust/mod, r=huonw

Part of #20361 and #20362
This commit is contained in:
bors 2015-01-02 16:31:26 +00:00
commit 4b40bc85cb
227 changed files with 383 additions and 365 deletions

View File

@ -551,7 +551,7 @@ impl LintPass for BoxPointers {
declare_lint! {
RAW_POINTER_DERIVING,
Warn,
"uses of #[deriving] with raw pointers are rarely correct"
"uses of #[derive] with raw pointers are rarely correct"
}
struct RawPtrDerivingVisitor<'a, 'tcx: 'a> {
@ -560,7 +560,7 @@ struct RawPtrDerivingVisitor<'a, 'tcx: 'a> {
impl<'a, 'tcx, 'v> Visitor<'v> for RawPtrDerivingVisitor<'a, 'tcx> {
fn visit_ty(&mut self, ty: &ast::Ty) {
static MSG: &'static str = "use of `#[deriving]` with a raw pointer";
static MSG: &'static str = "use of `#[derive]` with a raw pointer";
if let ast::TyPtr(..) = ty.node {
self.cx.span_lint(RAW_POINTER_DERIVING, ty.span, MSG);
}

View File

@ -681,9 +681,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
ViewPathSimple(binding, ref full_path, id) => {
let source_name =
full_path.segments.last().unwrap().identifier.name;
if token::get_name(source_name).get() == "mod" {
if token::get_name(source_name).get() == "mod" ||
token::get_name(source_name).get() == "self" {
self.resolve_error(view_path.span,
"`mod` imports are only allowed within a { } list");
"`self` imports are only allowed within a { } list");
}
let subclass = SingleImport(binding.name,
@ -704,10 +705,10 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
}).collect::<Vec<Span>>();
if mod_spans.len() > 1 {
self.resolve_error(mod_spans[0],
"`mod` import can only appear once in the list");
"`self` import can only appear once in the list");
for other_span in mod_spans.iter().skip(1) {
self.session.span_note(*other_span,
"another `mod` import appears here");
"another `self` import appears here");
}
}
@ -720,7 +721,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
Some(name) => *name,
None => {
self.resolve_error(source_item.span,
"`mod` import can only appear in an import list \
"`self` import can only appear in an import list \
with a non-empty prefix");
continue;
}

View File

@ -971,6 +971,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
}
}
// Import resolution
//
// This is a fixed-point algorithm. We resolve imports until our efforts

View File

@ -390,6 +390,8 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv {
syntax_expanders.insert(intern("log_syntax"),
builtin_normal_expander(
ext::log_syntax::expand_syntax_ext));
syntax_expanders.insert(intern("derive"),
Decorator(box ext::deriving::expand_meta_derive));
syntax_expanders.insert(intern("deriving"),
Decorator(box ext::deriving::expand_meta_deriving));

View File

@ -9,7 +9,7 @@
// except according to those terms.
//! Some code that abstracts away much of the boilerplate of writing
//! `deriving` instances for traits. Among other things it manages getting
//! `derive` instances for traits. Among other things it manages getting
//! access to the fields of the 4 different sorts of structs and enum
//! variants, as well as creating the method and impl ast instances.
//!
@ -26,7 +26,7 @@
//! moment. (`TraitDef.additional_bounds`)
//!
//! Unsupported: FIXME #6257: calling methods on reference fields,
//! e.g. deriving Eq/Ord/Clone don't work on `struct A(&int)`,
//! e.g. derive Eq/Ord/Clone don't work on `struct A(&int)`,
//! because of how the auto-dereferencing happens.
//!
//! The most important thing for implementers is the `Substructure` and
@ -209,7 +209,7 @@ use self::ty::{LifetimeBounds, Path, Ptr, PtrTy, Self, Ty};
pub mod ty;
pub struct TraitDef<'a> {
/// The span for the current #[deriving(Foo)] header.
/// The span for the current #[derive(Foo)] header.
pub span: Span,
pub attributes: Vec<ast::Attribute>,
@ -354,7 +354,7 @@ impl<'a> TraitDef<'a> {
generics)
}
_ => {
cx.span_err(mitem.span, "`deriving` may only be applied to structs and enums");
cx.span_err(mitem.span, "`derive` may only be applied to structs and enums");
return;
}
};
@ -718,7 +718,7 @@ impl<'a> MethodDef<'a> {
}
/// ```
/// #[deriving(PartialEq)]
/// #[derive(PartialEq)]
/// struct A { x: int, y: int }
///
/// // equivalent to:
@ -782,7 +782,7 @@ impl<'a> MethodDef<'a> {
} else {
cx.span_bug(trait_.span,
"no self arguments to non-static method in generic \
`deriving`")
`derive`")
};
// body of the inner most destructuring match
@ -822,7 +822,7 @@ impl<'a> MethodDef<'a> {
}
/// ```
/// #[deriving(PartialEq)]
/// #[derive(PartialEq)]
/// enum A {
/// A1,
/// A2(int)
@ -1185,7 +1185,7 @@ impl<'a> TraitDef<'a> {
cx: &mut ExtCtxt,
mut to_set: Span) -> Span {
let trait_name = match self.path.path.last() {
None => cx.span_bug(self.span, "trait with empty path in generic `deriving`"),
None => cx.span_bug(self.span, "trait with empty path in generic `derive`"),
Some(name) => *name
};
to_set.expn_id = cx.codemap().record_expansion(codemap::ExpnInfo {
@ -1215,7 +1215,7 @@ impl<'a> TraitDef<'a> {
match (just_spans.is_empty(), named_idents.is_empty()) {
(false, false) => cx.span_bug(self.span,
"a struct with named and unnamed \
fields in generic `deriving`"),
fields in generic `derive`"),
// named fields
(_, false) => Named(named_idents),
// tuple structs (includes empty structs)
@ -1263,7 +1263,7 @@ impl<'a> TraitDef<'a> {
None
}
_ => {
cx.span_bug(sp, "a struct with named and unnamed fields in `deriving`");
cx.span_bug(sp, "a struct with named and unnamed fields in `derive`");
}
};
let ident = cx.ident_of(format!("{}_{}", prefix, i)[]);
@ -1371,7 +1371,7 @@ pub fn cs_fold<F>(use_foldl: bool,
enum_nonmatch_f(cx, trait_span, (all_args[], tuple),
substructure.nonself_args),
StaticEnum(..) | StaticStruct(..) => {
cx.span_bug(trait_span, "static function in `deriving`")
cx.span_bug(trait_span, "static function in `derive`")
}
}
}
@ -1411,7 +1411,7 @@ pub fn cs_same_method<F>(f: F,
enum_nonmatch_f(cx, trait_span, (all_self_args[], tuple),
substructure.nonself_args),
StaticEnum(..) | StaticStruct(..) => {
cx.span_bug(trait_span, "static function in `deriving`")
cx.span_bug(trait_span, "static function in `derive`")
}
}
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
//! The compiler code necessary to implement the `#[deriving]` extensions.
//! The compiler code necessary to implement the `#[derive]` extensions.
//!
//! FIXME (#2810): hygiene. Search for "__" strings (in other files too). We also assume "extra" is
//! the standard library, and "std" is the core library.
@ -45,16 +45,26 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
_span: Span,
mitem: &MetaItem,
item: &Item,
mut push: Box<FnMut(P<Item>)>) {
push: Box<FnMut(P<Item>)>) {
cx.span_warn(mitem.span, "`deriving` is deprecated; use `derive`");
expand_meta_derive(cx, _span, mitem, item, push)
}
pub fn expand_meta_derive(cx: &mut ExtCtxt,
_span: Span,
mitem: &MetaItem,
item: &Item,
mut push: Box<FnMut(P<Item>)>) {
match mitem.node {
MetaNameValue(_, ref l) => {
cx.span_err(l.span, "unexpected value in `deriving`");
cx.span_err(l.span, "unexpected value in `derive`");
}
MetaWord(_) => {
cx.span_warn(mitem.span, "empty trait list in `deriving`");
cx.span_warn(mitem.span, "empty trait list in `derive`");
}
MetaList(_, ref titems) if titems.len() == 0 => {
cx.span_warn(mitem.span, "empty trait list in `deriving`");
cx.span_warn(mitem.span, "empty trait list in `derive`");
}
MetaList(_, ref titems) => {
for titem in titems.iter().rev() {
@ -78,15 +88,15 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
}
"Encodable" => {
cx.span_warn(titem.span,
"deriving(Encodable) is deprecated \
in favor of deriving(RustcEncodable)");
"derive(Encodable) is deprecated \
in favor of derive(RustcEncodable)");
expand!(encodable::expand_deriving_encodable)
}
"Decodable" => {
cx.span_warn(titem.span,
"deriving(Decodable) is deprecated \
in favor of deriving(RustcDecodable)");
"derive(Decodable) is deprecated \
in favor of derive(RustcDecodable)");
expand!(decodable::expand_deriving_decodable)
}
@ -111,7 +121,7 @@ pub fn expand_meta_deriving(cx: &mut ExtCtxt,
ref tname => {
cx.span_err(titem.span,
format!("unknown `deriving` \
format!("unknown `derive` \
trait: `{}`",
*tname)[]);
}

View File

@ -546,6 +546,10 @@ impl<'a> Parser<'a> {
pub fn parse_path_list_item(&mut self) -> ast::PathListItem {
let lo = self.span.lo;
let node = if self.eat_keyword(keywords::Mod) {
let span = self.last_span;
self.span_warn(span, "deprecated syntax; use the `self` keyword now");
ast::PathListMod { id: ast::DUMMY_NODE_ID }
} else if self.eat_keyword(keywords::Self) {
ast::PathListMod { id: ast::DUMMY_NODE_ID }
} else {
let ident = self.parse_ident();

View File

@ -2540,7 +2540,7 @@ impl<'a> State<'a> {
s.print_ident(name)
},
ast::PathListMod { .. } => {
word(&mut s.s, "mod")
word(&mut s.s, "self")
}
}
}));

View File

@ -13,7 +13,7 @@ use std::cmp::PartialEq;
pub trait MyNum : Add<Self,Self> + Sub<Self,Self> + Mul<Self,Self> + PartialEq + Clone {
}
#[deriving(Clone, Show)]
#[derive(Clone, Show)]
pub struct MyInt {
pub val: int
}

View File

@ -60,7 +60,7 @@ static OCCURRENCES: [&'static str;5] = [
// Code implementation
#[deriving(PartialEq, PartialOrd, Ord, Eq)]
#[derive(PartialEq, PartialOrd, Ord, Eq)]
struct Code(u64);
impl Copy for Code {}

View File

@ -14,7 +14,7 @@ use std::os;
use std::task;
use std::time::Duration;
#[deriving(Clone)]
#[derive(Clone)]
enum List<T> {
Nil, Cons(T, Box<List<T>>)
}

View File

@ -14,7 +14,7 @@
#![feature(associated_types)]
#![no_implicit_prelude]
use std::option::Option::{None, Some, mod};
use std::option::Option::{self, None, Some};
use std::vec::Vec;
trait Iterator {

View File

@ -8,4 +8,4 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)] //~ERROR expected item after attributes
#[derive(Show)] //~ERROR expected item after attributes

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Clone)]
#[derive(Clone)]
struct point {
x: int,
y: int,

View File

@ -9,7 +9,7 @@
// except according to those terms.
#[deriving(Clone)]
#[derive(Clone)]
struct foo(Box<uint>);
impl Add<foo, foo> for foo {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Copy)]
#[derive(Copy)]
struct Point {
x: int,
y: int,

View File

@ -10,7 +10,7 @@
// Test that we do not permit moves from &[] matched by a vec pattern.
#[deriving(Clone, Show)]
#[derive(Clone, Show)]
struct Foo {
string: String
}

View File

@ -24,7 +24,7 @@ impl<T> MyTrait<T> for T { //~ ERROR E0119
}
}
#[deriving(Clone)]
#[derive(Clone)]
struct MyType {
dummy: uint
}

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)]
#[derive(Show)]
struct foo {
i: int,
}

View File

@ -8,11 +8,11 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Copy(Bad))]
#[derive(Copy(Bad))]
//~^ ERROR unexpected value in deriving, expected a trait
struct Test;
#[deriving(Sync)]
#[derive(Sync)]
//~^ ERROR Sync is an unsafe trait and it should be implemented explicitly
struct Test1;

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Eqr)] //~ ERROR unknown `deriving` trait: `Eqr`
#[derive(Eqr)] //~ ERROR unknown `derive` trait: `Eqr`
struct Foo;
pub fn main() {}

View File

@ -10,12 +10,12 @@
struct NoCloneOrEq;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct E {
x: NoCloneOrEq //~ ERROR binary operation `==` cannot be applied to type `NoCloneOrEq`
//~^ ERROR binary operation `!=` cannot be applied to type `NoCloneOrEq`
}
#[deriving(Clone)]
#[derive(Clone)]
struct C {
x: NoCloneOrEq
//~^ ERROR the trait `core::clone::Clone` is not implemented for the type `NoCloneOrEq`

View File

@ -12,29 +12,29 @@
struct S;
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
trait T { }
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
impl S { }
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
impl T for S { }
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
static s: uint = 0u;
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
const c: uint = 0u;
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
mod m { }
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
extern "C" { }
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
type A = uint;
#[deriving(PartialEq)] //~ ERROR: `deriving` may only be applied to structs and enums
#[derive(PartialEq)] //~ ERROR: `derive` may only be applied to structs and enums
fn main() { }

View File

@ -11,22 +11,22 @@
use std::num::FromPrimitive;
use std::int;
#[deriving(FromPrimitive)]
#[derive(FromPrimitive)]
struct A { x: int }
//~^^ ERROR `FromPrimitive` cannot be derived for structs
//~^^^ ERROR `FromPrimitive` cannot be derived for structs
#[deriving(FromPrimitive)]
#[derive(FromPrimitive)]
struct B(int);
//~^^ ERROR `FromPrimitive` cannot be derived for structs
//~^^^ ERROR `FromPrimitive` cannot be derived for structs
#[deriving(FromPrimitive)]
#[derive(FromPrimitive)]
enum C { Foo(int), Bar(uint) }
//~^^ ERROR `FromPrimitive` cannot be derived for enum variants with arguments
//~^^^ ERROR `FromPrimitive` cannot be derived for enum variants with arguments
#[deriving(FromPrimitive)]
#[derive(FromPrimitive)]
enum D { Baz { x: int } }
//~^^ ERROR `FromPrimitive` cannot be derived for enums with struct variants
//~^^^ ERROR `FromPrimitive` cannot be derived for enums with struct variants

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Clone)]
#[derive(Clone)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Clone)]
#[derive(Clone)]
enum Enum {
A(
Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Clone)]
#[derive(Clone)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Clone)]
#[derive(Clone)]
struct Struct(
Error //~ ERROR
);

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Default)]
#[derive(Default)]
struct Struct {
x: Error //~ ERROR `core::default::Default` is not implemented
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Default)]
#[derive(Default)]
struct Struct(
Error //~ ERROR
);

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Hash)]
#[derive(Hash)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Hash)]
#[derive(Hash)]
enum Enum {
A(
Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Hash)]
#[derive(Hash)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Hash)]
#[derive(Hash)]
struct Struct(
Error //~ ERROR
);

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(PartialEq)]
#[derive(PartialEq)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(PartialEq)]
#[derive(PartialEq)]
enum Enum {
A(
Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Struct {
x: Error //~ ERROR
//~^ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Struct(
Error //~ ERROR
//~^ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(PartialOrd,PartialEq)]
#[derive(PartialOrd,PartialEq)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(PartialOrd,PartialEq)]
#[derive(PartialOrd,PartialEq)]
enum Enum {
A(
Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(PartialOrd,PartialEq)]
#[derive(PartialOrd,PartialEq)]
struct Struct {
x: Error //~ ERROR
//~^ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(PartialOrd,PartialEq)]
#[derive(PartialOrd,PartialEq)]
struct Struct(
Error //~ ERROR
//~^ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Rand)]
#[derive(Rand)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Rand)]
#[derive(Rand)]
enum Enum {
A(
Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Rand)]
#[derive(Rand)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Rand)]
#[derive(Rand)]
struct Struct(
Error //~ ERROR
);

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Show)]
#[derive(Show)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Show)]
#[derive(Show)]
enum Enum {
A(
Error //~ ERROR

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Show)]
#[derive(Show)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Show)]
#[derive(Show)]
struct Struct(
Error //~ ERROR
);

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(Eq,PartialEq)]
#[derive(Eq,PartialEq)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(Eq,PartialEq)]
#[derive(Eq,PartialEq)]
enum Enum {
A(
Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(Eq,PartialEq)]
#[derive(Eq,PartialEq)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct Error;
#[deriving(Eq,PartialEq)]
#[derive(Eq,PartialEq)]
struct Struct(
Error //~ ERROR
);

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(Eq,PartialOrd,PartialEq)]
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
#[derive(Ord,Eq,PartialOrd,PartialEq)]
enum Enum {
A {
x: Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(Eq,PartialOrd,PartialEq)]
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
#[derive(Ord,Eq,PartialOrd,PartialEq)]
enum Enum {
A(
Error //~ ERROR

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(Eq,PartialOrd,PartialEq)]
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
#[derive(Ord,Eq,PartialOrd,PartialEq)]
struct Struct {
x: Error //~ ERROR
}

View File

@ -12,10 +12,10 @@
extern crate rand;
#[deriving(Eq,PartialOrd,PartialEq)]
#[derive(Eq,PartialOrd,PartialEq)]
struct Error;
#[deriving(Ord,Eq,PartialOrd,PartialEq)]
#[derive(Ord,Eq,PartialOrd,PartialEq)]
struct Struct(
Error //~ ERROR
);

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Zero)] //~ ERROR not implemented
#[derive(Zero)] //~ ERROR not implemented
struct Struct {
x: Error
}

View File

@ -15,7 +15,7 @@ extern crate rand;
struct Error;
#[deriving(Zero)] //~ ERROR not implemented
#[derive(Zero)] //~ ERROR not implemented
struct Struct(
Error
);

View File

@ -9,4 +9,4 @@
// except according to those terms.
/// hi
#[deriving(Show)] //~ERROR expected item after attributes
#[derive(Show)] //~ERROR expected item after attributes

View File

@ -16,10 +16,10 @@ struct Fat<Sized? T> {
ptr: T
}
#[deriving(PartialEq,Eq)]
#[derive(PartialEq,Eq)]
struct Bar;
#[deriving(PartialEq,Eq)]
#[derive(PartialEq,Eq)]
struct Bar1 {
f: int
}

View File

@ -16,10 +16,10 @@ struct Fat<Sized? T> {
ptr: T
}
#[deriving(PartialEq,Eq)]
#[derive(PartialEq,Eq)]
struct Bar;
#[deriving(PartialEq,Eq)]
#[derive(PartialEq,Eq)]
struct Bar1 {
f: int
}

View File

@ -30,7 +30,7 @@ trait TraversesWorld {
}
#[deriving(Show, Eq, PartialEq, Hash)]
#[derive(Show, Eq, PartialEq, Hash)]
enum RoomDirection {
West,
East,

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)]
#[derive(Show)]
struct Pair<T, V> (T, V);
impl Pair<

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct thing(uint);
impl PartialOrd for thing { //~ ERROR not all trait items implemented, missing: `partial_cmp`
fn le(&self, other: &thing) -> bool { true }

View File

@ -11,7 +11,7 @@
fn main() {
let foo = 100;
#[deriving(Show)]
#[derive(Show)]
enum Stuff {
Bar = foo //~ ERROR attempt to use a non-constant value in a constant
}

View File

@ -11,24 +11,24 @@
#![allow(dead_code)]
#![deny(raw_pointer_deriving)]
#[deriving(Clone)]
#[derive(Clone)]
struct Foo {
x: *const int //~ ERROR use of `#[deriving]` with a raw pointer
x: *const int //~ ERROR use of `#[derive]` with a raw pointer
}
#[deriving(Clone)]
struct Bar(*mut int); //~ ERROR use of `#[deriving]` with a raw pointer
#[derive(Clone)]
struct Bar(*mut int); //~ ERROR use of `#[derive]` with a raw pointer
#[deriving(Clone)]
#[derive(Clone)]
enum Baz {
A(*const int), //~ ERROR use of `#[deriving]` with a raw pointer
B { x: *mut int } //~ ERROR use of `#[deriving]` with a raw pointer
A(*const int), //~ ERROR use of `#[derive]` with a raw pointer
B { x: *mut int } //~ ERROR use of `#[derive]` with a raw pointer
}
#[deriving(Clone)]
#[derive(Clone)]
struct Buzz {
x: (*const int, //~ ERROR use of `#[deriving]` with a raw pointer
*const uint) //~ ERROR use of `#[deriving]` with a raw pointer
x: (*const int, //~ ERROR use of `#[derive]` with a raw pointer
*const uint) //~ ERROR use of `#[derive]` with a raw pointer
}
fn main() {}

View File

@ -10,7 +10,7 @@
#![deny(unused_parens)]
#[deriving(Eq, PartialEq)]
#[derive(Eq, PartialEq)]
struct X { y: bool }
impl X {
fn foo(&self) -> bool { self.y }

View File

@ -14,7 +14,7 @@ fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) {
panic!();
}
#[deriving(Show)]
#[derive(Show)]
struct _chan<T>(int);
// Tests that "log(debug, message);" is flagged as using

View File

@ -14,7 +14,7 @@
#![feature(asm)]
#![feature(trace_macros, concat_idents)]
#[deriving(Default, //~ ERROR
#[derive(Default, //~ ERROR
Rand, //~ ERROR
Zero)] //~ ERROR
enum CantDeriveThose {}

View File

@ -13,11 +13,11 @@
use std::task;
use std::rc::Rc;
#[deriving(Show)]
#[derive(Show)]
struct Port<T>(Rc<T>);
fn main() {
#[deriving(Show)]
#[derive(Show)]
struct foo {
_x: Port<()>,
}

View File

@ -11,7 +11,7 @@
// Test that a class with a non-copyable field can't be
// copied
#[deriving(Show)]
#[derive(Show)]
struct bar {
x: int,
}
@ -26,7 +26,7 @@ fn bar(x:int) -> bar {
}
}
#[deriving(Show)]
#[derive(Show)]
struct foo {
i: int,
j: bar,

View File

@ -10,7 +10,7 @@
// error-pattern:non-scalar cast
#[deriving(Show)]
#[derive(Show)]
struct foo {
x: int
}

View File

@ -23,7 +23,7 @@ struct Foo {
baz: uint
}
#[deriving(Show)]
#[derive(Show)]
struct Oof {
rab: u8,
zab: uint

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)]
#[derive(Show)]
struct r {
b: bool,
}

View File

@ -12,7 +12,7 @@
use std::cell::Cell;
#[deriving(Show)]
#[derive(Show)]
struct r<'a> {
i: &'a Cell<int>,
}

View File

@ -9,10 +9,10 @@
// except according to those terms.
mod foo {
use self::{mod};
use self::{self};
//~^ ERROR unresolved import `self`. There is no `self` in `???`
use super::{mod};
use super::{self};
//~^ ERROR unresolved import `super`. There is no `super` in `???`
}

View File

@ -9,7 +9,7 @@
// except according to those terms.
use foo::bar::{
mod //~ ERROR module `bar` is private
self //~ ERROR module `bar` is private
};
use foo::bar::{
Bar //~ ERROR type `Bar` is inaccessible

View File

@ -9,18 +9,18 @@
// except according to those terms.
use foo::bar::{
mod,
//~^ ERROR `mod` import can only appear once in the list
self,
//~^ ERROR `self` import can only appear once in the list
Bar,
mod
//~^ NOTE another `mod` import appears here
self
//~^ NOTE another `self` import appears here
};
use {mod};
//~^ ERROR `mod` import can only appear in an import list with a non-empty prefix
use {self};
//~^ ERROR `self` import can only appear in an import list with a non-empty prefix
use foo::mod;
//~^ ERROR `mod` imports are only allowed within a { } list
use foo::self;
//~^ ERROR `self` imports are only allowed within a { } list
mod foo {
pub mod bar {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)]
#[derive(Show)]
struct r {
i:int
}

View File

@ -73,13 +73,13 @@
#![omit_gdb_pretty_printer_section]
#[deriving(Clone)]
#[derive(Clone)]
struct Struct {
a: int,
b: f64
}
#[deriving(Clone)]
#[derive(Clone)]
struct StructStruct {
a: Struct,
b: Struct

View File

@ -105,21 +105,21 @@ use self::AutoDiscriminant::{One, Two, Three};
use self::ManualDiscriminant::{OneHundred, OneThousand, OneMillion};
use self::SingleVariant::TheOnlyVariant;
#[deriving(Copy)]
#[derive(Copy)]
enum AutoDiscriminant {
One,
Two,
Three
}
#[deriving(Copy)]
#[derive(Copy)]
enum ManualDiscriminant {
OneHundred = 100,
OneThousand = 1000,
OneMillion = 1000000
}
#[deriving(Copy)]
#[derive(Copy)]
enum SingleVariant {
TheOnlyVariant
}

View File

@ -72,7 +72,7 @@
#![omit_gdb_pretty_printer_section]
#[deriving(Clone)]
#[derive(Clone)]
struct Struct {
a: int,
b: f64

View File

@ -9,7 +9,7 @@
// except according to those terms.
#[repr(packed)]
#[deriving(PartialEq, Show)]
#[derive(PartialEq, Show)]
struct Foo {
a: i8,
b: i16,

View File

@ -14,9 +14,9 @@
extern crate serialize;
#[deriving(Encodable)] pub struct A;
#[deriving(Encodable)] pub struct B(int);
#[deriving(Encodable)] pub struct C { x: int }
#[deriving(Encodable)] pub enum D {}
#[deriving(Encodable)] pub enum E { y }
#[deriving(Encodable)] pub enum F { z(int) }
#[derive(Encodable)] pub struct A;
#[derive(Encodable)] pub struct B(int);
#[derive(Encodable)] pub struct C { x: int }
#[derive(Encodable)] pub enum D {}
#[derive(Encodable)] pub enum E { y }
#[derive(Encodable)] pub enum F { z(int) }

View File

@ -10,16 +10,16 @@
#![crate_name="foo"]
/// The '# ' lines should be removed from the output, but the #[deriving] should be
/// The '# ' lines should be removed from the output, but the #[derive] should be
/// retained.
///
/// ```rust
/// mod to_make_deriving_work { // FIXME #4913
///
/// # #[deriving(PartialEq)] // invisible
/// # #[derive(PartialEq)] // invisible
/// # struct Foo; // invisible
///
/// #[deriving(PartialEq)] // Bar
/// #[derive(PartialEq)] // Bar
/// struct Bar(Foo);
///
/// fn test() {

View File

@ -3,6 +3,6 @@
file="$1/doc/foo/fn.foo.html"
grep -v 'invisible' $file &&
grep '#.*\[.*deriving.*(.*Eq.*).*\].*//.*Bar' $file
grep '#.*\[.*derive.*(.*Eq.*).*\].*//.*Bar' $file
exit $?

View File

@ -17,7 +17,7 @@
extern crate macro_crate_test;
#[into_foo]
#[deriving(PartialEq, Clone, Show)]
#[derive(PartialEq, Clone, Show)]
fn foo() -> AFakeTypeThatHadBetterGoAway {}
pub fn main() {

View File

@ -33,7 +33,7 @@ fn syntax_extension(cx: &ExtCtxt) {
let _g: P<syntax::ast::Expr> = quote_expr!(cx, true);
let _h: P<syntax::ast::Expr> = quote_expr!(cx, 'a');
let i: Option<P<syntax::ast::Item>> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
let i: Option<P<syntax::ast::Item>> = quote_item!(cx, #[derive(Eq)] struct Foo; );
assert!(i.is_some());
let _j: P<syntax::ast::Method> = quote_method!(cx, fn foo(&self) {});

View File

@ -9,7 +9,7 @@
// except according to those terms.
#[deriving(PartialEq, Show)]
#[derive(PartialEq, Show)]
struct Point { x : int }
pub fn main() {

View File

@ -41,7 +41,7 @@ fn test_rbml<'a, 'b, A:
assert!(*a1 == a2);
}
#[deriving(Decodable, Encodable)]
#[derive(Decodable, Encodable)]
enum Expr {
Val(uint),
Plus(@Expr, @Expr),
@ -108,26 +108,26 @@ impl cmp::Eq for CLike {
fn ne(&self, other: &CLike) -> bool { !self.eq(other) }
}
#[deriving(Decodable, Encodable, Eq)]
#[derive(Decodable, Encodable, Eq)]
struct Spanned<T> {
lo: uint,
hi: uint,
node: T,
}
#[deriving(Decodable, Encodable)]
#[derive(Decodable, Encodable)]
struct SomeStruct { v: Vec<uint> }
#[deriving(Decodable, Encodable)]
#[derive(Decodable, Encodable)]
struct Point {x: uint, y: uint}
#[deriving(Decodable, Encodable)]
#[derive(Decodable, Encodable)]
enum Quark<T> {
Top(T),
Bottom(T)
}
#[deriving(Decodable, Encodable)]
#[derive(Decodable, Encodable)]
enum CLike { A, B, C }
pub fn main() {

View File

@ -8,7 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#[deriving(Show)]
#[derive(Show)]
struct Pair<T, U> { a: T, b: U }
struct Triple { x: int, y: int, z: int }

View File

@ -59,7 +59,7 @@ fn test_ptr() {
}
}
#[deriving(PartialEq, Show)]
#[derive(PartialEq, Show)]
struct p {
x: int,
y: int,

View File

@ -10,7 +10,7 @@
use std::mem::swap;
#[deriving(Show)]
#[derive(Show)]
struct Ints {sum: Box<int>, values: Vec<int> }
fn add_int(x: &mut Ints, v: int) {

View File

@ -17,7 +17,7 @@
extern crate trait_superkinds_in_metadata;
use trait_superkinds_in_metadata::{RequiresRequiresShareAndSend, RequiresShare};
#[deriving(PartialEq)]
#[derive(PartialEq)]
struct X<T>(T);
impl <T: Sync> RequiresShare for X<T> { }

View File

@ -47,7 +47,7 @@ fn dog() -> dog {
}
}
#[deriving(Clone)]
#[derive(Clone)]
struct cat {
meows: uint,

View File

@ -11,7 +11,7 @@
use std::cmp;
#[deriving(Show)]
#[derive(Show)]
enum cat_type { tuxedo, tabby, tortoiseshell }
impl Copy for cat_type {}

View File

@ -13,7 +13,7 @@ trait noisy {
fn speak(&mut self);
}
#[deriving(Clone)]
#[derive(Clone)]
struct cat {
meows : uint,

View File

@ -14,10 +14,10 @@ fn id<T>(x: T) -> T {
x
}
#[deriving(PartialEq, Show)]
#[derive(PartialEq, Show)]
struct Foo<T>(T);
#[deriving(PartialEq, Show)]
#[derive(PartialEq, Show)]
enum Bar<T> {
Baz(T)
}

Some files were not shown because too many files have changed in this diff Show More