-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #109136 - compiler-errors:simplify-proc-macro-checkin…
…g, r=oli-obk Simplify proc macro signature validity check Use an `ObligationCtxt` instead of `normalize_erasing_regions` + `DeepRejectCtxt`. This should both give us a more accurate error message, and also avoid issues like not-well-formed proc macro signatures. Also, let's fall back on the regular type mismatch error reporting for making these diagnostic notes, instead of hard-coding a bunch of specific diagnostics. Fixes #109129
- Loading branch information
Showing
17 changed files
with
212 additions
and
275 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,15 @@ | ||
// force-host | ||
// no-prefer-dynamic | ||
|
||
#![crate_type = "proc-macro"] | ||
#![allow(warnings)] | ||
|
||
extern crate proc_macro; | ||
|
||
trait Project { | ||
type Assoc; | ||
} | ||
|
||
#[proc_macro] | ||
pub fn uwu() -> <() as Project>::Assoc {} | ||
//~^ ERROR the trait bound `(): Project` is not satisfied |
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,9 @@ | ||
error[E0277]: the trait bound `(): Project` is not satisfied | ||
--> $DIR/bad-projection.rs:14:17 | ||
| | ||
LL | pub fn uwu() -> <() as Project>::Assoc {} | ||
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
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 |
---|---|---|
@@ -1,20 +1,29 @@ | ||
error: proc macro functions may not be `extern "C"` | ||
error: function-like proc macro has incorrect signature | ||
--> $DIR/proc-macro-abi.rs:11:1 | ||
| | ||
LL | pub extern "C" fn abi(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn | ||
| | ||
= note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
|
||
error: proc macro functions may not be `extern "system"` | ||
error: function-like proc macro has incorrect signature | ||
--> $DIR/proc-macro-abi.rs:17:1 | ||
| | ||
LL | pub extern "system" fn abi2(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "system" fn | ||
| | ||
= note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
found signature `extern "system" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
|
||
error: proc macro functions may not be `extern "C"` | ||
error: function-like proc macro has incorrect signature | ||
--> $DIR/proc-macro-abi.rs:23:1 | ||
| | ||
LL | pub extern fn abi3(a: TokenStream) -> TokenStream { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn | ||
| | ||
= note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` | ||
|
||
error: aborting due to 3 previous errors | ||
|
Oops, something went wrong.