-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prohibit using macro-expanded
macro_export
macros through module-re…
…lative paths
- Loading branch information
1 parent
e7ee6fb
commit dd0a766
Showing
7 changed files
with
98 additions
and
11 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright 2018 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-local macro expanded `macro_export` macros cannot be accessed with module-relative paths. | ||
|
||
#![feature(use_extern_macros)] | ||
|
||
macro_rules! define_exported { () => { | ||
#[macro_export] | ||
macro_rules! exported { | ||
() => () | ||
} | ||
}} | ||
|
||
define_exported!(); | ||
|
||
mod m { | ||
use exported; | ||
//~^ ERROR macro-expanded `macro_export` macros from the current crate cannot | ||
} | ||
|
||
fn main() { | ||
::exported!(); | ||
//~^ ERROR macro-expanded `macro_export` macros from the current crate cannot | ||
} |
36 changes: 36 additions & 0 deletions
36
src/test/ui/imports/local-modularized-tricky-fail-3.stderr
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,36 @@ | ||
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths | ||
--> $DIR/local-modularized-tricky-fail-3.rs:25:9 | ||
| | ||
LL | use exported; | ||
| ^^^^^^^^ | ||
| | ||
note: the macro is defined here | ||
--> $DIR/local-modularized-tricky-fail-3.rs:17:5 | ||
| | ||
LL | / macro_rules! exported { | ||
LL | | () => () | ||
LL | | } | ||
| |_____^ | ||
... | ||
LL | define_exported!(); | ||
| ------------------- in this macro invocation | ||
|
||
error: macro-expanded `macro_export` macros from the current crate cannot be referred to by absolute paths | ||
--> $DIR/local-modularized-tricky-fail-3.rs:30:5 | ||
| | ||
LL | ::exported!(); | ||
| ^^^^^^^^^^ | ||
| | ||
note: the macro is defined here | ||
--> $DIR/local-modularized-tricky-fail-3.rs:17:5 | ||
| | ||
LL | / macro_rules! exported { | ||
LL | | () => () | ||
LL | | } | ||
| |_____^ | ||
... | ||
LL | define_exported!(); | ||
| ------------------- in this macro invocation | ||
|
||
error: aborting due to 2 previous errors | ||
|