Allow selective macro import
This commit is contained in:
parent
0816255c80
commit
aa69cbde82
19 changed files with 299 additions and 8 deletions
15
src/test/auxiliary/macro_reexport_2_no_use.rs
Normal file
15
src/test/auxiliary/macro_reexport_2_no_use.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
#![crate_type = "dylib"]
|
||||
|
||||
#[macro_reexport(reexported)]
|
||||
#[no_link]
|
||||
extern crate macro_reexport_1;
|
||||
19
src/test/auxiliary/two_macros.rs
Normal file
19
src/test/auxiliary/two_macros.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// force-host
|
||||
|
||||
#![feature(macro_rules)]
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! macro_one { () => ("one") }
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! macro_two { () => ("two") }
|
||||
19
src/test/compile-fail/empty-macro-use.rs
Normal file
19
src/test/compile-fail/empty-macro-use.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use()]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_two!(); //~ ERROR macro undefined
|
||||
}
|
||||
20
src/test/compile-fail/macro-reexport-not-locally-visible.rs
Normal file
20
src/test/compile-fail/macro-reexport-not-locally-visible.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:macro_reexport_1.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_reexport(reexported)]
|
||||
#[no_link]
|
||||
extern crate macro_reexport_1;
|
||||
|
||||
fn main() {
|
||||
assert_eq!(reexported!(), 3u); //~ ERROR macro undefined
|
||||
}
|
||||
15
src/test/compile-fail/macro-use-bad-args-1.rs
Normal file
15
src/test/compile-fail/macro-use-bad-args-1.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
#[macro_use(foo(bar))] //~ ERROR bad macro import
|
||||
extern crate std;
|
||||
|
||||
fn main() {
|
||||
}
|
||||
15
src/test/compile-fail/macro-use-bad-args-2.rs
Normal file
15
src/test/compile-fail/macro-use-bad-args-2.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
#[macro_use(foo="bar")] //~ ERROR bad macro import
|
||||
extern crate std;
|
||||
|
||||
fn main() {
|
||||
}
|
||||
19
src/test/compile-fail/macro-use-wrong-name.rs
Normal file
19
src/test/compile-fail/macro-use-wrong-name.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(macro_one)]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_two!(); //~ ERROR macro undefined
|
||||
}
|
||||
18
src/test/compile-fail/missing-macro-use.rs
Normal file
18
src/test/compile-fail/missing-macro-use.rs
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_two!(); //~ ERROR macro undefined
|
||||
}
|
||||
20
src/test/run-pass/macro-reexport-no-intermediate-use.rs
Normal file
20
src/test/run-pass/macro-reexport-no-intermediate-use.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:macro_reexport_1.rs
|
||||
// aux-build:macro_reexport_2_no_use.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use] #[no_link]
|
||||
extern crate macro_reexport_2_no_use;
|
||||
|
||||
fn main() {
|
||||
assert_eq!(reexported!(), 3u);
|
||||
}
|
||||
21
src/test/run-pass/macro-use-all-and-none.rs
Normal file
21
src/test/run-pass/macro-use-all-and-none.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use]
|
||||
#[macro_use()]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_one!();
|
||||
macro_two!();
|
||||
}
|
||||
20
src/test/run-pass/macro-use-all.rs
Normal file
20
src/test/run-pass/macro-use-all.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_one!();
|
||||
macro_two!();
|
||||
}
|
||||
20
src/test/run-pass/macro-use-both.rs
Normal file
20
src/test/run-pass/macro-use-both.rs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(macro_one, macro_two)]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_one!();
|
||||
macro_two!();
|
||||
}
|
||||
19
src/test/run-pass/macro-use-one.rs
Normal file
19
src/test/run-pass/macro-use-one.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(macro_two)]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_two!();
|
||||
}
|
||||
21
src/test/run-pass/two-macro-use.rs
Normal file
21
src/test/run-pass/two-macro-use.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2015 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.
|
||||
|
||||
// aux-build:two_macros.rs
|
||||
// ignore-stage1
|
||||
|
||||
#[macro_use(macro_one)]
|
||||
#[macro_use(macro_two)]
|
||||
extern crate two_macros;
|
||||
|
||||
pub fn main() {
|
||||
macro_one!();
|
||||
macro_two!();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue