This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Expand file tree Collapse file tree 3 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ // force-host
2+ // no-prefer-dynamic
3+ #![ crate_type = "proc-macro" ]
4+ #![ feature( proc_macro_quote) ]
5+
6+ extern crate proc_macro;
7+
8+ use proc_macro:: { quote, TokenStream } ;
9+
10+ #[ proc_macro_attribute]
11+ pub fn hello ( _: TokenStream , _: TokenStream ) -> TokenStream {
12+ quote ! (
13+ fn f( _: & mut i32 ) { }
14+ fn g( ) {
15+ f( 123 ) ;
16+ }
17+ )
18+ }
Original file line number Diff line number Diff line change 1+ // run-check
2+ // aux-build:proc-macro-type-error.rs
3+
4+ extern crate proc_macro_type_error;
5+
6+ use proc_macro_type_error:: hello;
7+
8+ #[ hello] //~ERROR mismatched types
9+ fn abc ( ) { }
10+
11+ fn x ( _: & mut i32 ) { }
12+
13+ macro_rules! bla {
14+ ( ) => {
15+ x( 123 ) ;
16+ //~^ ERROR mismatched types
17+ //~| SUGGESTION &mut 123
18+ } ;
19+ ( $v: expr) => {
20+ x( $v)
21+ }
22+ }
23+
24+ fn main ( ) {
25+ bla ! ( ) ;
26+ bla ! ( 456 ) ;
27+ //~^ ERROR mismatched types
28+ //~| SUGGESTION &mut 456
29+ }
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/suggest-ref-macro.rs:8:1
3+ |
4+ LL | #[hello]
5+ | ^^^^^^^^ expected `&mut i32`, found integer
6+ |
7+ = note: this error originates in the attribute macro `hello` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+ error[E0308]: mismatched types
10+ --> $DIR/suggest-ref-macro.rs:15:11
11+ |
12+ LL | x(123);
13+ | ^^^
14+ | |
15+ | expected `&mut i32`, found integer
16+ | help: consider mutably borrowing here: `&mut 123`
17+ ...
18+ LL | bla!();
19+ | ------- in this macro invocation
20+ |
21+ = note: this error originates in the macro `bla` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+ error[E0308]: mismatched types
24+ --> $DIR/suggest-ref-macro.rs:26:10
25+ |
26+ LL | bla!(456);
27+ | ^^^
28+ | |
29+ | expected `&mut i32`, found integer
30+ | help: consider mutably borrowing here: `&mut 456`
31+
32+ error: aborting due to 3 previous errors
33+
34+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments