forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rustc: Use a special filename for macros 1.1
This "special filename" is surrounded by `<>` to ensure that `FileMap::is_real_file` returns `false`. This way the "files" parsed here aren't emitted as dep info `.d` files and don't confuse Cargo about non-existent files. Closes rust-lang#36625
- Loading branch information
1 parent
ea65ab6
commit 20a71b2
Showing
4 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
-include ../tools.mk | ||
|
||
all: | ||
$(RUSTC) foo.rs | ||
$(RUSTC) bar.rs --emit dep-info | ||
grep "rustc-macro source" $(TMPDIR)/bar.d && exit 1 || exit 0 |
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,21 @@ | ||
// Copyright 2016 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. | ||
|
||
#![feature(rustc_macro)] | ||
|
||
#[macro_use] | ||
extern crate foo; | ||
|
||
#[derive(A)] | ||
struct A; | ||
|
||
fn main() { | ||
let _b = B; | ||
} |
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,24 @@ | ||
// Copyright 2016 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 = "rustc-macro"] | ||
#![feature(rustc_macro)] | ||
#![feature(rustc_macro_lib)] | ||
|
||
extern crate rustc_macro; | ||
|
||
use rustc_macro::TokenStream; | ||
|
||
#[rustc_macro_derive(A)] | ||
pub fn derive(input: TokenStream) -> TokenStream { | ||
let input = input.to_string(); | ||
assert!(input.contains("struct A;")); | ||
"struct B;".parse().unwrap() | ||
} |