Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unresolved Import Error with Yew Framework #12401

Closed
jinseok9338 opened this issue May 27, 2022 · 10 comments
Closed

Unresolved Import Error with Yew Framework #12401

jinseok9338 opened this issue May 27, 2022 · 10 comments

Comments

@jinseok9338
Copy link

rust-analyzer version: (0.2.853)

rustc version: (rustc 1.61.0 (fe5b13d68 2022-05-18))

I have noticed that rust analyzer spit out an unresolved import error when importing function component in Yew framework.
When spinning up the yew project with trunk serve it works fine and rust is not complaining but the rust analyzer seems to be angry that you can't import function component

I have attached the picture
image

@Veykril
Copy link
Member

Veykril commented May 27, 2022

What does the theme module look like?

@jinseok9338
Copy link
Author

https://github.com/futursolo/stylist-rs/blob/master/examples/yew-theme-context/src/contexts/theme.rs

this is theme that I copied and tweaked but the structure is all the same
It's not just ThemeProvider. Rust-analyzer throws error when I import function component.
From above Rust-analyzer doesn't throw error when importing LandingPages. It's because LandingPages is a struct component, not a function component

@Veykril
Copy link
Member

Veykril commented May 27, 2022

Does the #[styled_component(ThemeProvider)] properly expand in your theme module? You can check by clicking on it and then running the command Expand Macros Recursively accessible by pressing ctrl + shift + p

@jinseok9338
Copy link
Author

No it does not... Can you tell me how to fix the problem??

@Veykril
Copy link
Member

Veykril commented May 27, 2022

If proc-macros don't expand you either have them disabled in your settings or something else is failing when we run the build scripts most likely, can you check your Rust Analyzer Language Server Logs logs for errors?

@jinseok9338
Copy link
Author

thread '<unnamed>' panicked at 'Bad offset: range 0..1811 offset 1814', /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/rowan-0.15.1/src/cursor.rs:751:9

stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: rowan::cursor::SyntaxNode::token_at_offset
   3: ide_assists::assist_context::AssistContext::new
   4: ide_assists::assists
   5: ide::Analysis::assists_with_fixes::{{closure}}
   6: std::panicking::try
   7: rust_analyzer::handlers::handle_code_action
   8: std::panicking::try
   9: <F as threadpool::FnBox>::call_box
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic context:
> 
version: db2a7087b 2021-12-13 stable
request: textDocument/codeAction CodeActionParams {
    text_document: TextDocumentIdentifier {
        uri: Url {
            scheme: "file",
            cannot_be_a_base: false,
            username: "",
            password: None,
            host: None,
            port: None,
            path: "/workspace/RustApi/yew-app/src/components/about_style.rs",
            query: None,
            fragment: None,
        },
    },
    range: Range {
        start: Position {
            line: 4,
            character: 34,
        },
        end: Position {
            line: 93,
            character: 4,
        },
    },
    context: CodeActionContext {
        diagnostics: [
            Diagnostic {
                range: Range {
                    start: Position {
                        line: 4,
                        character: 20,
                    },
                    end: Position {
                        line: 91,
                        character: 5,
                    },
                },
                severity: Some(
                    Hint,
                ),
                code: Some(
                    String(
                        "unresolved-proc-macro",
                    ),
                ),
                code_description: Some(
                    CodeDescription {
                        href: Url {
                            scheme: "https",
                            cannot_be_a_base: false,
                            username: "",
                            password: None,
                            host: Some(
                                Domain(
                                    "rust-analyzer.github.io",
                                ),
                            ),
                            port: None,
                            path: "/manual.html",
                            query: None,
                            fragment: Some(
                                "unresolved-proc-macro",
                            ),
                        },
                    },
                ),
                source: Some(
                    "rust-analyzer",
                ),
                message: "proc macro not expanded",
                related_information: None,
                tags: None,
                data: None,
            },
        ],
        only: Some(
            [
                CodeActionKind(
                    "quickfix",
                ),
            ],
        ),
    },
    work_done_progress_params: WorkDoneProgressParams {
        work_done_token: None,
    },
    partial_result_params: PartialResultParams {
        partial_result_token: None,
    },
}

this is the log

@Veykril
Copy link
Member

Veykril commented May 27, 2022

Hmm, that error is irrelevant unfortunately.

@jinseok9338
Copy link
Author

#10894

Thanks to your keen insight I was able to "what" the error was but unable to find the answer to the problem and upon looking up the problem, I am not the only one.

@jinseok9338 jinseok9338 closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2022
@Veykril
Copy link
Member

Veykril commented May 27, 2022

Oh actually I just realized your rust-analyzer version, that one is very much outdated. I'd recommend trying to reinstall it assuming it stopped auto-updating itself.

@jinseok9338
Copy link
Author

Thanks ... but since I am using gitpod. The one I am using is the most updated one... Thanks for your input. I am sure they will update the extension, but in the meantime ignoring the error message will do :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants