Skip to content

s/deriving/derives in Comments/Docs #20998

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2430,7 +2430,7 @@ There are three different types of inline attributes:
* `#[inline(always)]` asks the compiler to always perform an inline expansion.
* `#[inline(never)]` asks the compiler to never perform an inline expansion.

### Derive
### `derive`

The `derive` attribute allows certain traits to be automatically implemented
for data structures. For example, the following will create an `impl` for the
Expand Down
16 changes: 8 additions & 8 deletions src/etc/generate-deriving-span-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

"""
This script creates a pile of compile-fail tests check that all the
derivings have spans that point to the fields, rather than the
#[deriving(...)] line.
derives have spans that point to the fields, rather than the
#[derive(...)] line.

sample usage: src/etc/generate-deriving-span-tests.py
"""
Expand Down Expand Up @@ -46,29 +46,29 @@
"""

ENUM_STRING = """
#[deriving({traits})]
#[derive({traits})]
enum Enum {{
A(
Error {errors}
)
}}
"""
ENUM_STRUCT_VARIANT_STRING = """
#[deriving({traits})]
#[derive({traits})]
enum Enum {{
A {{
x: Error {errors}
}}
}}
"""
STRUCT_STRING = """
#[deriving({traits})]
#[derive({traits})]
struct Struct {{
x: Error {errors}
}}
"""
STRUCT_TUPLE_STRING = """
#[deriving({traits})]
#[derive({traits})]
struct Struct(
Error {errors}
);
Expand All @@ -80,14 +80,14 @@ def create_test_case(type, trait, super_traits, number_of_errors):
string = [ENUM_STRING, ENUM_STRUCT_VARIANT_STRING, STRUCT_STRING, STRUCT_TUPLE_STRING][type]
all_traits = ','.join([trait] + super_traits)
super_traits = ','.join(super_traits)
error_deriving = '#[deriving(%s)]' % super_traits if super_traits else ''
error_deriving = '#[derive(%s)]' % super_traits if super_traits else ''

errors = '\n'.join('//~%s ERROR' % ('^' * n) for n in range(error_count))
code = string.format(traits = all_traits, errors = errors)
return TEMPLATE.format(year = YEAR, error_deriving=error_deriving, code = code)

def write_file(name, string):
test_file = os.path.join(TEST_DIR, 'deriving-span-%s.rs' % name)
test_file = os.path.join(TEST_DIR, 'derives-span-%s.rs' % name)

# set write permission if file exists, so it can be changed
if os.path.exists(test_file):
Expand Down
2 changes: 1 addition & 1 deletion src/etc/unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def emit_grapheme_module(f, grapheme_table, grapheme_cats):
use core::slice;

#[allow(non_camel_case_types)]
#[deriving(Clone)]
#[derive(Clone)]
pub enum GraphemeCat {
""")
for cat in grapheme_cats + ["Any"]:
Expand Down
8 changes: 4 additions & 4 deletions src/libcollections/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ pub fn fixme_14344_be_sure_to_link_to_collections() {}
mod std {
pub use core::fmt; // necessary for panic!()
pub use core::option; // necessary for panic!()
pub use core::clone; // deriving(Clone)
pub use core::cmp; // deriving(Eq, Ord, etc.)
pub use core::marker; // deriving(Copy)
pub use core::hash; // deriving(Hash)
pub use core::clone; // derive(Clone)
pub use core::cmp; // derive(Eq, Ord, etc.)
pub use core::marker; // derive(Copy)
pub use core::hash; // derive(Hash)
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_back/svh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ mod svh_visitor {
StrictVersionHashVisitor { st: st }
}

// To off-load the bulk of the hash-computation on deriving(Hash),
// To off-load the bulk of the hash-computation on #[derive(Hash)],
// we define a set of enums corresponding to the content that our
// crate visitor will encounter as it traverses the ast.
//
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
//! - `fmt::Show` implementations should be implemented for **all** public types.
//! Output will typically represent the internal state as faithfully as possible.
//! The purpose of the `Show` trait is to facilitate debugging Rust code. In
//! most cases, using `#[deriving(Show)]` is sufficient and recommended.
//! most cases, using `#[derive(Show)]` is sufficient and recommended.
//!
//! Some examples of the output from both traits:
//!
Expand Down
6 changes: 3 additions & 3 deletions src/libsyntax/ext/deriving/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ fn cs_clone(
EnumNonMatchingCollapsed (..) => {
cx.span_bug(trait_span,
&format!("non-matching enum variants in \
`deriving({})`", name)[])
`derive({})`", name)[])
}
StaticEnum(..) | StaticStruct(..) => {
cx.span_bug(trait_span,
&format!("static method in `deriving({})`", name)[])
&format!("static method in `derive({})`", name)[])
}
}

Expand All @@ -101,7 +101,7 @@ fn cs_clone(
None => {
cx.span_bug(trait_span,
&format!("unnamed field in normal struct in \
`deriving({})`", name)[])
`derive({})`", name)[])
}
};
cx.field_imm(field.span, ident, subcall(field))
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/cmp/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt,
|cx, span, subexpr, self_f, other_fs| {
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialEq)`")
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
};

let eq = cx.expr_binary(span, ast::BiEq, self_f, other_f.clone());
Expand All @@ -49,7 +49,7 @@ pub fn expand_deriving_eq<F>(cx: &mut ExtCtxt,
|cx, span, subexpr, self_f, other_fs| {
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialEq)`")
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialEq)`")
};

let eq = cx.expr_binary(span, ast::BiNe, self_f, other_f.clone());
Expand Down
8 changes: 4 additions & 4 deletions src/libsyntax/ext/deriving/cmp/ord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
let new = {
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`"),
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
};

let args = vec![
Expand All @@ -176,7 +176,7 @@ pub fn cs_partial_cmp(cx: &mut ExtCtxt, span: Span,
equals_expr.clone(),
box |cx, span, (self_args, tag_tuple), _non_self_args| {
if self_args.len() != 2 {
cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`")
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
} else {
some_ordering_collapsed(cx, span, PartialCmpOp, tag_tuple)
}
Expand Down Expand Up @@ -210,7 +210,7 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
*/
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`")
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
};

let cmp = cx.expr_binary(span, op, self_f.clone(), other_f.clone());
Expand All @@ -224,7 +224,7 @@ fn cs_op(less: bool, equal: bool, cx: &mut ExtCtxt,
cx.expr_bool(span, equal),
box |cx, span, (self_args, tag_tuple), _non_self_args| {
if self_args.len() != 2 {
cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`")
cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`")
} else {
let op = match (less, equal) {
(true, true) => LeOp, (true, false) => LtOp,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/cmp/totaleq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn expand_deriving_totaleq<F>(cx: &mut ExtCtxt,
let block = cx.block(span, stmts, None);
cx.expr_block(block)
},
box |cx, sp, _, _| cx.span_bug(sp, "non matching enums in deriving(Eq)?"),
box |cx, sp, _, _| cx.span_bug(sp, "non matching enums in derive(Eq)?"),
cx,
span,
substr)
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/cmp/totalord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
let new = {
let other_f = match other_fs {
[ref o_f] => o_f,
_ => cx.span_bug(span, "not exactly 2 arguments in `deriving(PartialOrd)`"),
_ => cx.span_bug(span, "not exactly 2 arguments in `derive(PartialOrd)`"),
};

let args = vec![
Expand All @@ -132,7 +132,7 @@ pub fn cs_cmp(cx: &mut ExtCtxt, span: Span,
cx.expr_path(equals_path.clone()),
box |cx, span, (self_args, tag_tuple), _non_self_args| {
if self_args.len() != 2 {
cx.span_bug(span, "not exactly 2 arguments in `deriving(Ord)`")
cx.span_bug(span, "not exactly 2 arguments in `derives(Ord)`")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this seems wrong :o should be derive?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're write. I'll add another patch.

} else {
ordering_collapsed(cx, span, tag_tuple)
}
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/decodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn decodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
cx.lambda_expr_1(trait_span, result, blkarg)
))
}
_ => cx.bug("expected StaticEnum or StaticStruct in deriving(Decodable)")
_ => cx.bug("expected StaticEnum or StaticStruct in derive(Decodable)")
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ fn default_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructur
// let compilation continue
cx.expr_uint(trait_span, 0)
}
_ => cx.span_bug(trait_span, "Non-static method in `deriving(Default)`")
_ => cx.span_bug(trait_span, "Non-static method in `derive(Default)`")
};
}
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/encodable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,6 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
cx.expr_block(cx.block(trait_span, vec!(me), Some(ret)))
}

_ => cx.bug("expected Struct or EnumMatching in deriving(Encodable)")
_ => cx.bug("expected Struct or EnumMatching in derive(Encodable)")
};
}
2 changes: 1 addition & 1 deletion src/libsyntax/ext/deriving/generic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ impl<'a> TraitDef<'a> {
to_set.expn_id = cx.codemap().record_expansion(codemap::ExpnInfo {
call_site: to_set,
callee: codemap::NameAndSpan {
name: format!("deriving({})", trait_name),
name: format!("derive({})", trait_name),
format: codemap::MacroAttribute,
span: Some(self.span)
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/generic/ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ impl<'a> Ty<'a> {
Literal(ref p) => {
p.to_path(cx, span, self_ty, self_generics)
}
Ptr(..) => { cx.span_bug(span, "pointer in a path in generic `deriving`") }
Tuple(..) => { cx.span_bug(span, "tuple in a path in generic `deriving`") }
Ptr(..) => { cx.span_bug(span, "pointer in a path in generic `derive`") }
Tuple(..) => { cx.span_bug(span, "tuple in a path in generic `derive`") }
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn expand_deriving_from_primitive<F>(cx: &mut ExtCtxt,
fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
let n = match substr.nonself_args {
[ref n] => n,
_ => cx.span_bug(trait_span, "incorrect number of arguments in `deriving(FromPrimitive)`")
_ => cx.span_bug(trait_span, "incorrect number of arguments in `derive(FromPrimitive)`")
};

match *substr.fields {
Expand Down Expand Up @@ -144,6 +144,6 @@ fn cs_from(name: &str, cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure

cx.expr_match(trait_span, n.clone(), arms)
}
_ => cx.span_bug(trait_span, "expected StaticEnum in deriving(FromPrimitive)")
_ => cx.span_bug(trait_span, "expected StaticEnum in derive(FromPrimitive)")
}
}
4 changes: 2 additions & 2 deletions src/libsyntax/ext/deriving/rand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub fn expand_deriving_rand<F>(cx: &mut ExtCtxt,
fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure) -> P<Expr> {
let rng = match substr.nonself_args {
[ref rng] => rng,
_ => cx.bug("Incorrect number of arguments to `rand` in `deriving(Rand)`")
_ => cx.bug("Incorrect number of arguments to `rand` in `derive(Rand)`")
};
let rand_ident = vec!(
cx.ident_of("std"),
Expand Down Expand Up @@ -131,7 +131,7 @@ fn rand_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substructure)
let block = cx.block(trait_span, vec!( let_statement ), Some(match_expr));
cx.expr_block(block)
}
_ => cx.bug("Non-static method in `deriving(Rand)`")
_ => cx.bug("Non-static method in `derive(Rand)`")
};

fn rand_thing<F>(cx: &mut ExtCtxt,
Expand Down