Skip to content

Fix example in the docs #4180

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

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6e38e33
Relate the module hierarchy to directory paths in the parser
brson Dec 11, 2012
7d556e1
Fix deriving for single-variant enums
brson Dec 11, 2012
bfb09ee
Merge pull request #4164 from brson/deriving
brson Dec 11, 2012
3ee1adb
libstd: teach workcache to check freshness.
graydon Dec 11, 2012
a55ea48
libstd: refactor future, remove with(), remove ~ indirection.
graydon Dec 11, 2012
76dc781
libstd: Implement read_managed_str for the JSON deserialiser.
huonw Dec 10, 2012
35209cb
fix long line, r=tidypolice.
graydon Dec 12, 2012
6439f2d
Avoid extra error for type mismatches in patterns
catamorphism Dec 11, 2012
a7159be
Remove old deriving
brson Dec 12, 2012
d42bdf1
Auto-deref when checking field and method privacy
catamorphism Dec 12, 2012
b0a01f2
re-fix typo
catamorphism Dec 11, 2012
38bd694
Reverse the order of the results of pipes::stream
catamorphism Dec 11, 2012
4ec658e
Merge pull request #4167 from catamorphism/issue-3637
catamorphism Dec 12, 2012
213773c
Fix tasks tutorial tests
catamorphism Dec 12, 2012
80d6bc8
Add Huon Wilson to AUTHORS.txt
graydon Dec 12, 2012
9cced55
syntax: remove all remaining uses of #ast, and #ast / qquote itself.
graydon Dec 12, 2012
e24ae85
syntax: remove most code handling old-style syntax extensions.
graydon Dec 12, 2012
0138d87
Document pub use foo::* in the reference manual
catamorphism Dec 13, 2012
9a4c669
syntax: remove remaining #syntaxext machinery. Close #3516.
graydon Dec 13, 2012
0494b07
Merge pull request #4172 from graydon/remove-old-syntax-ext
brson Dec 13, 2012
6047dd3
Fix vtable calculations when translating static methods. Closes #4165
brson Dec 13, 2012
948754b
Fix the test for transmute
brson Dec 13, 2012
0d59e86
core: Remove some uses of 'move'
brson Dec 12, 2012
3c8dca4
syntax: normalize paths when parsing, close #4173.
graydon Dec 13, 2012
4c2e4c3
librustc: Make `use` statements crate-relative by default. r=brson
pcwalton Dec 13, 2012
08b1c84
Rename "to_str" to "make_string" in the docs
andrew-d Dec 14, 2012
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
Prev Previous commit
Next Next commit
Fix deriving for single-variant enums
  • Loading branch information
brson committed Dec 11, 2012
commit 7d556e18b05dbac67d2c5d17c332b5d44afcb192
44 changes: 24 additions & 20 deletions src/libsyntax/ext/deriving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,26 +698,30 @@ fn expand_deriving_eq_enum_method(cx: ext_ctxt,
};
other_arms.push(move matching_arm);

// Create the nonmatching pattern.
let nonmatching_pat = @{
id: cx.next_id(),
node: pat_wild,
span: span
};

// Create the nonmatching pattern body.
let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
let nonmatching_body_block = build::mk_simple_block(cx,
span,
nonmatching_expr);

// Create the nonmatching arm.
let nonmatching_arm = {
pats: ~[ nonmatching_pat ],
guard: None,
body: move nonmatching_body_block
};
other_arms.push(move nonmatching_arm);
// Maybe generate a non-matching case. If there is only one
// variant then there will always be a match.
if enum_definition.variants.len() > 1 {
// Create the nonmatching pattern.
let nonmatching_pat = @{
id: cx.next_id(),
node: pat_wild,
span: span
};

// Create the nonmatching pattern body.
let nonmatching_expr = build::mk_bool(cx, span, !is_eq);
let nonmatching_body_block = build::mk_simple_block(cx,
span,
nonmatching_expr);

// Create the nonmatching arm.
let nonmatching_arm = {
pats: ~[ nonmatching_pat ],
guard: None,
body: move nonmatching_body_block
};
other_arms.push(move nonmatching_arm);
}

// Create the self pattern.
let self_pat = create_enum_variant_pattern(cx,
Expand Down
8 changes: 8 additions & 0 deletions src/test/run-pass/deriving-enum-single-variant.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type task_id = int;

#[deriving_eq]
pub enum Task {
TaskHandle(task_id)
}

fn main() { }