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

False Positive on Missing Comma #17463

Closed
wyatt-herkamp opened this issue Jun 20, 2024 · 6 comments · Fixed by #17464
Closed

False Positive on Missing Comma #17463

wyatt-herkamp opened this issue Jun 20, 2024 · 6 comments · Fixed by #17464
Labels
A-proc-macro proc macro Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug

Comments

@wyatt-herkamp
Copy link
Contributor

wyatt-herkamp commented Jun 20, 2024

rust-analyzer version:
rust-analyzer version: 0.0.0 (e08f795 2024-06-20) [/media/Other/ProgrammingProjects/RustProjects/rust-analyzer/target/release/rust-analyzer]
I built this based on the latest commit today.

rustc version: (eg. output of rustc -V)
rustc 1.79.0 (129f3b996 2024-06-10)

editor or extension: VSCode 1.90.1 OpenSuse Tumbleweed Linux 6.9.5

relevant settings: (eg. client settings, or environment variables like CARGO, RUSTC, RUSTUP_HOME or CARGO_HOME)
VS Code Settings
repository link (if public, optional): (eg. rust-analyzer)
Private Repository however I was able to make a simple reproduction.
code snippet to reproduce:

use actix_web::{
    post,
    web::{self, Data},
    HttpResponse,
};
use sea_orm::{prelude::*, ActiveValue, DatabaseConnection};

fn main() {
    println!("Hello, world!");
}

use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Eq, DeriveEntityModel, Deserialize, Serialize)]
#[sea_orm(table_name = "users")]
pub struct Model {
    #[sea_orm(primary_key)]
    pub id: i64,
    pub name: String,
    pub username: String,
    pub email: String,
    #[serde(skip_serializing)]
    pub password: String,
    pub admin: bool,
    #[sea_orm(default_expr = "Expr::current_timestamp()")]
    pub created: DateTimeWithTimeZone,
}
impl ActiveModelBehavior for ActiveModel {}
#[derive(Deserialize)]
pub struct NewUser {
    pub username: String,
    pub password: String,
    pub email: String,
    pub name: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}

#[post("/install")]
pub async fn install(
    post: web::Json<NewUser>,
    database: Data<DatabaseConnection>,
) -> Result<HttpResponse, actix_web::error::Error> {
    let post = post.into_inner();
    let user = ActiveModel {
        username: ActiveValue::Set(post.username),
        password: ActiveValue::Set(post.password),
        email: ActiveValue::Set(post.email),
        name: ActiveValue::Set(post.name),
        admin: ActiveValue::Set(true),
        ..Default::default()
    };
    Entity::insert(user).exec(database.as_ref()).await.unwrap();

    Ok(HttpResponse::Ok().finish())
}

image

So when I expand the post macro I get this.

image

I was going to try to fix it however, I have no idea where it is coming from. If someone has an idea where it is coming from let me know I will try to fix it myself.

If I move to the stable version of rust-analyzer so the release on 17th I have no issues. But the nightly release has issues.

@wyatt-herkamp wyatt-herkamp added the C-bug Category: bug label Jun 20, 2024
@lnicola lnicola added the A-proc-macro proc macro label Jun 20, 2024
@wyatt-herkamp
Copy link
Contributor Author

158626b

I think it is this commit

@wyatt-herkamp
Copy link
Contributor Author

158626b

I think it is this commit

It is. So I removed the added code and it works.

@Veykril
Copy link
Member

Veykril commented Jun 20, 2024

Right, 158626b#diff-f002869811628add2076bd19a6d7b800a0186e9fcc946e953afa8c981ce342b0R278-R289 is wrong, that also needs to check that the expression is missing

@Veykril
Copy link
Member

Veykril commented Jun 20, 2024

That is this test will currently result in that wrong expect when it shouldnt trigger there at all

    #[test]
    fn fixup_record_ctor_field() {
        check(
            r#"
fn foo() {
    R { f: a }
}
"#,
            expect![[r#"
fn foo () {R {f : a __ra_fixup}}
"#]],
        )
    }

@Veykril Veykril added the Broken Window Bugs / technical debt to be addressed immediately label Jun 20, 2024
@wyatt-herkamp
Copy link
Contributor Author

Right, 158626b#diff-f002869811628add2076bd19a6d7b800a0186e9fcc946e953afa8c981ce342b0R278-R289 is wrong, that also needs to check that the expression is missing

LOL, I was literally typing I figured out what the problem code was. So just check that it.expr().is_none()

@wyatt-herkamp
Copy link
Contributor Author

That is this test will currently result in that wrong expect when it shouldnt trigger there at all

    #[test]
    fn fixup_record_ctor_field() {
        check(
            r#"
fn foo() {
    R { f: a }
}
"#,
            expect![[r#"
fn foo () {R {f : a __ra_fixup}}
"#]],
        )
    }

I added the it.expr().is_none() and the tests past and my code runs fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-proc-macro proc macro Broken Window Bugs / technical debt to be addressed immediately C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants