2
error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
   --> /home/wangchao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-1.0.56/src/wrapper.rs:476:33
    |
476 |                 let proc_macro::LineColumn { line, column } = s.start();
    |                                 ^^^^^^^^^^ not found in `proc_macro`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::LineColumn;
    |
help: if you import `LineColumn`, refer to it directly
    |
476 -                 let proc_macro::LineColumn { line, column } = s.start();
476 +                 let LineColumn { line, column } = s.start();
    |

error[E0422]: cannot find struct, variant or union type `LineColumn` in crate `proc_macro`
   --> /home/wangchao/.cargo/registry/src/mirrors.ustc.edu.cn-61ef6e0cd06fb9b8/proc-macro2-1.0.56/src/wrapper.rs:490:33
    |
490 |                 let proc_macro::LineColumn { line, column } = s.end();
    |                                 ^^^^^^^^^^ not found in `proc_macro`
    |
help: consider importing this struct through its public re-export
    |
1   + use crate::LineColumn;
    |
help: if you import `LineColumn`, refer to it directly
    |
490 -                 let proc_macro::LineColumn { line, column } = s.end();
490 +                 let LineColumn { line, column } = s.end();
    |

2 Answers 2

3

I was having the same issue in my GitHub actions and not locally.

Updating my crates using cargo update seemed to fix the dependency that was causing this issue.

Perhaps give this a try!

1
  • Had the same issue, cargo update -p "proc-macro2" solved it.
    – Errata
    Commented Jul 21, 2023 at 9:18
0

The error message indicates that the LineColumn struct or variant cannot be found in the proc_macro crate. The suggested solution is to import the struct through its public re-export or refer to it directly.

Here's an example of how you can resolve the error by importing the LineColumn struct directly:

use proc_macro::LineColumn;

// Rest of your code

Alternatively, you can use destructuring assignment to extract the line and column fields directly without mentioning the struct's name:

let LineColumn { line, column } = s.start();
let LineColumn { line, column } = s.end();

// Rest of your code

By using either of these approaches, the LineColumn struct should be accessible in your code, resolving the compilation error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.