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

bug #10470

Closed
gipsyh opened this issue Oct 6, 2021 · 7 comments
Closed

bug #10470

gipsyh opened this issue Oct 6, 2021 · 7 comments

Comments

@gipsyh
Copy link

gipsyh commented Oct 6, 2021

Screenshot 2021-10-06 200039

but it can be compiled...

#[macro_use]
extern crate rocket;

use rocket::response::Redirect;
use rocket::uri;
use std::{fs::File, path::Path};

#[get("/image/<file>")]
fn image(file: &str) -> File {
    let path = Path::new("images").join(file);
    File::open(path).unwrap()
}

#[get("/image")]
fn random_image() -> Redirect {
    Redirect::to(uri!(image("aaa")))
}

#[rocket::launch]
fn rocket() -> _ {
    rocket::build().mount("/", routes![image, random_image])
}

rust-analyzer 88a214f 2021-09-23 dev

@Veykril
Copy link
Member

Veykril commented Oct 6, 2021

What exactly is the error being reported here?

@gipsyh
Copy link
Author

gipsyh commented Oct 6, 2021

What exactly is the error being reported here?

Screenshot 2021-10-06 201535

@bjorn3
Copy link
Member

bjorn3 commented Oct 6, 2021

Which version of rocket are you using? 0.4 or 0.5-rc?

@gipsyh
Copy link
Author

gipsyh commented Oct 6, 2021

hich version of rocket are you using? 0.4 or 0.5-rc?

0.5-rc.1

@bjorn3
Copy link
Member

bjorn3 commented Oct 6, 2021

Looks like this macro should be generated by the #[get] attribute: https://github.com/SergioBenitez/Rocket/blob/9177b20ff13a24807fdb3f22bcd869bb0df79cfb/core/codegen/src/attribute/route/mod.rs#L198-L228

Does adding "rust-analyzer.experimental.procAttrMacros": true to your vscode config file help? By default proc macro attributes are not expanded, so the macro uri!() expects won't be generated.

@gipsyh
Copy link
Author

gipsyh commented Oct 6, 2021

Does adding "rust-analyzer.experimental.procAttrMacros": true to your vscode config file help? By default proc macro attributes are not expanded, so the macro uri!() expects won't be generated.

it works 👍

@Veykril
Copy link
Member

Veykril commented Oct 6, 2021

Note that the procAttrMacros setting is enabled by default with the last stable rust-analyzer.

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

3 participants