-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create a valid DefIdTable for proc macro crates
At least the incremental compilation code, and a few other places in the compiler, require the CrateMetadata for a loaded target crate to contain a valid DefIdTable for the DefIds in the target. Previously, the CrateMetadata for a proc macro contained the crate's "host" DefIdTable, which is of course incompatible with the "target" DefIdTable, causing ICEs. This creates a DefIdTable that properly refers to the "proc macro" DefIds. Fixes #49482.
- Loading branch information
Showing
9 changed files
with
198 additions
and
31 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,13 @@ | ||
-include ../tools.mk | ||
|
||
ifeq ($(findstring stage1,$(RUST_BUILD_STAGE)),stage1) | ||
# ignore stage1 | ||
all: | ||
|
||
else | ||
all: | ||
mkdir $(TMPDIR)/incremental-dir | ||
$(RUSTC) macro_def.rs | ||
$(RUSTC) reexport.rs | ||
$(RUSTC) main.rs -C incremental=$(TMPDIR)/incremental-dir | ||
endif |
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,47 @@ | ||
// 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_type="proc-macro"] | ||
#![allow(non_snake_case)] | ||
|
||
extern crate proc_macro; | ||
|
||
macro_rules! proc_macro_expr_impl { | ||
($( | ||
$( #[$attr:meta] )* | ||
pub fn $func:ident($input:ident: &str) -> String; | ||
)+) => { | ||
$( | ||
$( #[$attr] )* | ||
#[proc_macro_derive($func)] | ||
pub fn $func(_input: ::proc_macro::TokenStream) -> ::proc_macro::TokenStream { | ||
panic!() | ||
} | ||
)+ | ||
}; | ||
} | ||
|
||
proc_macro_expr_impl! { | ||
pub fn f1(input: &str) -> String; | ||
pub fn f2(input: &str) -> String; | ||
pub fn f3(input: &str) -> String; | ||
pub fn f4(input: &str) -> String; | ||
pub fn f5(input: &str) -> String; | ||
pub fn f6(input: &str) -> String; | ||
pub fn f7(input: &str) -> String; | ||
pub fn f8(input: &str) -> String; | ||
pub fn f9(input: &str) -> String; | ||
pub fn fA(input: &str) -> String; | ||
pub fn fB(input: &str) -> String; | ||
pub fn fC(input: &str) -> String; | ||
pub fn fD(input: &str) -> String; | ||
pub fn fE(input: &str) -> String; | ||
pub fn fF(input: &str) -> String; | ||
} |
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 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. | ||
|
||
extern crate reexport; | ||
|
||
pub trait KvStorage | ||
{ | ||
fn get(&self); | ||
} | ||
|
||
impl<K> KvStorage for Box<K> | ||
where | ||
K: KvStorage + ?Sized, | ||
{ | ||
fn get(&self) { | ||
(**self).get() | ||
} | ||
} | ||
|
||
impl KvStorage for u32 { | ||
fn get(&self) {} | ||
} | ||
|
||
fn main() { | ||
Box::new(2).get(); | ||
} |
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,16 @@ | ||
// 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_type="rlib"] | ||
|
||
#[macro_use] | ||
extern crate macro_def; | ||
|
||
pub use macro_def::*; |