File tree 3 files changed +74
-0
lines changed
3 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ // edition: 2021
2
+
3
+ #[ macro_export]
4
+ macro_rules! macro_that_defines_a_function {
5
+ ( fn $name: ident ( ) $body: tt) => {
6
+ fn $name ( ) -> ( ) $body
7
+ }
8
+ }
9
+
10
+ // Non-executable comment.
Original file line number Diff line number Diff line change
1
+ $DIR/auxiliary/macro_name_span_helper.rs:
2
+ LL| |// edition: 2021
3
+ LL| |
4
+ LL| |#[macro_export]
5
+ LL| |macro_rules! macro_that_defines_a_function {
6
+ LL| | (fn $name:ident () $body:tt) => {
7
+ LL| 1| fn $name () -> () $body
8
+ LL| | }
9
+ LL| |}
10
+ LL| |
11
+ LL| |// Non-executable comment.
12
+
13
+ $DIR/macro_name_span.rs:
14
+ LL| |// edition: 2021
15
+ LL| |
16
+ LL| |// Regression test for <https://github.com/rust-lang/rust/issues/117788>.
17
+ LL| |// Under some circumstances, the heuristics that detect macro name spans can
18
+ LL| |// get confused and produce incorrect spans beyond the bounds of the span
19
+ LL| |// being processed.
20
+ LL| |
21
+ LL| |// aux-build: macro_name_span_helper.rs
22
+ LL| |extern crate macro_name_span_helper;
23
+ LL| |
24
+ LL| 1|fn main() {
25
+ LL| 1| affected_function();
26
+ LL| 1|}
27
+ LL| |
28
+ LL| |macro_rules! macro_with_an_unreasonably_and_egregiously_long_name {
29
+ LL| | () => {
30
+ LL| | println!("hello");
31
+ LL| | };
32
+ LL| |}
33
+ LL| |
34
+ LL| |macro_name_span_helper::macro_that_defines_a_function! {
35
+ LL| | fn affected_function() {
36
+ LL| | macro_with_an_unreasonably_and_egregiously_long_name!();
37
+ LL| | }
38
+ LL| |}
39
+
Original file line number Diff line number Diff line change
1
+ // edition: 2021
2
+
3
+ // Regression test for <https://github.com/rust-lang/rust/issues/117788>.
4
+ // Under some circumstances, the heuristics that detect macro name spans can
5
+ // get confused and produce incorrect spans beyond the bounds of the span
6
+ // being processed.
7
+
8
+ // aux-build: macro_name_span_helper.rs
9
+ extern crate macro_name_span_helper;
10
+
11
+ fn main ( ) {
12
+ affected_function ( ) ;
13
+ }
14
+
15
+ macro_rules! macro_with_an_unreasonably_and_egregiously_long_name {
16
+ ( ) => {
17
+ println!( "hello" ) ;
18
+ } ;
19
+ }
20
+
21
+ macro_name_span_helper:: macro_that_defines_a_function! {
22
+ fn affected_function( ) {
23
+ macro_with_an_unreasonably_and_egregiously_long_name!( ) ;
24
+ }
25
+ }
You can’t perform that action at this time.
0 commit comments