forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#53711 - arielb1:macro-table, r=michaelwoerister
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 rust-lang#49482. r? @michaelwoerister Should we beta-nominate this?
- Loading branch information
Showing
8 changed files
with
195 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
49 changes: 49 additions & 0 deletions
49
src/test/incremental-fulldeps/auxiliary/issue_49482_macro_def.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,49 @@ | ||
// 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. | ||
|
||
// no-prefer-dynamic | ||
|
||
#![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; | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/incremental-fulldeps/auxiliary/issue_49482_reexport.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,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. | ||
|
||
#[macro_use] | ||
extern crate issue_49482_macro_def; | ||
|
||
pub use issue_49482_macro_def::*; | ||
|
||
pub fn foo() {} |
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,41 @@ | ||
// 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. | ||
|
||
// aux-build:issue_49482_macro_def.rs | ||
// aux-build:issue_49482_reexport.rs | ||
// ignore-stage1 | ||
// revisions: rpass1 | ||
|
||
extern crate issue_49482_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() { | ||
/* force issue_49482_reexport to be loaded */ | ||
issue_49482_reexport::foo(); | ||
|
||
Box::new(2).get(); | ||
} |