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.
Rollup merge of rust-lang#106407 - mejrs:attr_check, r=compiler-errors
Improve proc macro attribute diagnostics Closes rust-lang#102923
- Loading branch information
Showing
16 changed files
with
528 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -287,6 +287,7 @@ symbols! { | |
Target, | ||
ToOwned, | ||
ToString, | ||
TokenStream, | ||
Try, | ||
TryCaptureGeneric, | ||
TryCapturePrintable, | ||
|
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,24 @@ | ||
// check-pass | ||
|
||
#![crate_type = "proc-macro"] | ||
#![allow(private_in_public)] | ||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro] | ||
pub fn foo<T>(t: T) -> TokenStream { | ||
TokenStream::new() | ||
} | ||
|
||
trait Project { | ||
type Assoc; | ||
} | ||
|
||
impl Project for () { | ||
type Assoc = TokenStream; | ||
} | ||
|
||
#[proc_macro] | ||
pub fn uwu(_input: <() as Project>::Assoc) -> <() as Project>::Assoc { | ||
TokenStream::new() | ||
} |
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,28 @@ | ||
#![crate_type = "proc-macro"] | ||
#![allow(warnings)] | ||
|
||
extern crate proc_macro; | ||
use proc_macro::TokenStream; | ||
|
||
#[proc_macro] | ||
pub extern "C" fn abi(a: TokenStream) -> TokenStream { | ||
//~^ ERROR proc macro functions may not be `extern "C"` | ||
a | ||
} | ||
|
||
#[proc_macro] | ||
pub extern "system" fn abi2(a: TokenStream) -> TokenStream { | ||
//~^ ERROR proc macro functions may not be `extern "system"` | ||
a | ||
} | ||
|
||
#[proc_macro] | ||
pub extern fn abi3(a: TokenStream) -> TokenStream { | ||
//~^ ERROR proc macro functions may not be `extern "C"` | ||
a | ||
} | ||
|
||
#[proc_macro] | ||
pub extern "Rust" fn abi4(a: TokenStream) -> TokenStream { | ||
a | ||
} |
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,20 @@ | ||
error: proc macro functions may not be `extern "C"` | ||
--> $DIR/proc-macro-abi.rs:8:1 | ||
| | ||
LL | pub extern "C" fn abi(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: proc macro functions may not be `extern "system"` | ||
--> $DIR/proc-macro-abi.rs:14:1 | ||
| | ||
LL | pub extern "system" fn abi2(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: proc macro functions may not be `extern "C"` | ||
--> $DIR/proc-macro-abi.rs:20:1 | ||
| | ||
LL | pub extern fn abi3(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors | ||
|
Oops, something went wrong.