-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow syntax extensions to return multiple items, closes #16723.
This patch replaces `MacItem` with `MacItems`.
- Loading branch information
Showing
4 changed files
with
78 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/auxiliary/issue_16723_multiple_items_syntax_ext.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
// | ||
// ignore-stage1 | ||
#![feature(plugin_registrar, managed_boxes, quote)] | ||
#![crate_type = "dylib"] | ||
|
||
extern crate syntax; | ||
extern crate rustc; | ||
|
||
use syntax::ast; | ||
use syntax::codemap; | ||
use syntax::ext::base::{ExtCtxt, MacResult, MacItems}; | ||
use rustc::plugin::Registry; | ||
|
||
#[plugin_registrar] | ||
pub fn plugin_registrar(reg: &mut Registry) { | ||
reg.register_macro("multiple_items", expand) | ||
} | ||
|
||
fn expand(cx: &mut ExtCtxt, _: codemap::Span, _: &[ast::TokenTree]) -> Box<MacResult+'static> { | ||
MacItems::new(vec![ | ||
quote_item!(cx, struct Struct1;).unwrap(), | ||
quote_item!(cx, struct Struct2;).unwrap() | ||
].into_iter()) | ||
} |
30 changes: 30 additions & 0 deletions
30
src/test/run-pass-fulldeps/issue_16723_multiple_items_syntax_ext.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
// ignore-stage1 | ||
// aux-build:issue_16723_multiple_items_syntax_ext.rs | ||
#![feature(phase)] | ||
|
||
#[phase(plugin)] extern crate issue_16723_multiple_items_syntax_ext; | ||
|
||
multiple_items!() | ||
|
||
impl Struct1 { | ||
fn foo() {} | ||
} | ||
impl Struct2 { | ||
fn foo() {} | ||
} | ||
|
||
fn main() { | ||
Struct1::foo(); | ||
Struct2::foo(); | ||
println!("hallo"); | ||
} |
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at fhahn@89b0944
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging fhahn/rust/issue-16723-multiple-items = 89b0944 into auto
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fhahn/rust/issue-16723-multiple-items = 89b0944 merged ok, testing candidate = b5b72b75
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from alexcrichton
at fhahn@89b0944
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging fhahn/rust/issue-16723-multiple-items = 89b0944 into auto
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fhahn/rust/issue-16723-multiple-items = 89b0944 merged ok, testing candidate = c8ea5403
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1448
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1447
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1444
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1445
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1443
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1442
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1442
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1446
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1440
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1440
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1443
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-opt/builds/277
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-nopt-t/builds/277
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-nopt-c/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-opt/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-nopt-t/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-nopt-c/builds/277
89b0944
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/1448
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/1447
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1444
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1445
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/1443
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1442
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1442
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/1446
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1440
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1440
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android-t/builds/1443
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-opt/builds/277
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-nopt-t/builds/277
exception: http://buildbot.rust-lang.org/builders/auto-win32-32-nopt-c/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-opt/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-nopt-t/builds/278
exception: http://buildbot.rust-lang.org/builders/auto-win64-64-nopt-c/builds/277