-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Incorrect error "Expected 1 argument, 0 found" #5502
Comments
Calls to
Looks like the reason this is different might be that a non-static lifetime is involved? |
We ignore lifetimes completely, that's probably not the problem. Am I reading that right, it says "found 0" even though there is an argument? That's weird. Also, can you check what the method resolved to? |
That span looks very odd. It should encompass the entire call expression but seems to stop inside the generic arguments. Would it be possible to get a minimal reproduction of this issue? |
This is not enough to reproduce: use tokio_postgres::{Error, NoTls};
#[tokio::main]
async fn main() -> Result<(), Error> {
let (client, connection) =
tokio_postgres::connect("host=localhost user=postgres", NoTls).await?;
tokio::spawn(async move { connection.await.unwrap() });
let row = client
.query_one("SELECT $1::TEXT", &[&"hello world"])
.await?;
let foo = "hello".to_string();
let s = format!(
"https://this.will.make.for.a.very.very.very.long/url/to/append/to/{}/and/more/{}",
row.get::<_, &str>(0),
foo,
);
bar(&s);
Ok(())
}
fn bar(_: &str) -> bool {
true
} One other interesting thing I noticed: there seems to be a caching issue. If I reload my VS Code window, the error does not show up immediately. Only if I make some edits that result in incorrect syntax it starts showing up, and then doesn't go away again if I correct such errors. |
Hmm, this might not be a bug in the argument count mismatch diagnostic then |
I bisected this and it seems to have started with 63ce2c7. |
Did it have 0 arguments at one time? I wonder if the diagnostics are stale. |
I have the same issue with tokio postgress and the previous version of the rust analyzer seemed to work just fine |
If this happened over the last couple of days, then maybe it was caused by #5481? Which version did this break in? |
@jonas-schievink that's what I'm wondering... |
My guess is that we need to grab the file version before the diagnostics start computing because we're probably sending old diagnostics for a newer file version. Or maybe sending |
If you change the version to |
This does not fix the problem: diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index e95d4157c..2c7369ba3 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -315,7 +315,7 @@ impl GlobalState {
.unwrap_or_default();
self.send_notification::<lsp_types::notification::PublishDiagnostics>(
- lsp_types::PublishDiagnosticsParams { uri: url, diagnostics, version },
+ lsp_types::PublishDiagnosticsParams { uri: url, diagnostics, version: None },
);
}
} |
I've ran into this same issue. It gives the error in two places in the file if I call the function from within a macro ( #![cfg_attr(debug_assertions, allow(dead_code,))]
use std::{fmt::Debug, str::FromStr};
struct Foo {}
impl Foo {
fn something<'a, T, M>(&self, input: &str, data: M) -> Result<T, T::Err>
where
T: FromStr + Debug,
T::Err: Debug,
{
todo!()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_something() {
let foo = Foo {};
// let res = foo.something::<usize, _>("foo", ());
eprintln!("{:#?}", foo.something::<usize, _>("foo", ()));
}
} |
In the last update you can disable the warning by turning off |
@lnicola how and where exactly do i do that ? I am using vim-lsp am I supposed to set this in vim lsp settings or something ? |
apparently you guys broke everything. It doesnt show error messages doesnt suggest auto completion or anything anymore. I had to switch back to rls altough it is muchslower it at least works |
5682: Add an option to disable diagnostics r=matklad a=popzxc As far as I know, currently it's not possible to disable a selected type of diagnostics provided by `rust-analyzer`. This causes an inconvenient situation with a false-positive warnings: you either have to disable all the diagnostics, or you have to ignore these warnings. There are some open issues related to this problem, e.g.: #5412, #5502 This PR attempts to make it possible to selectively disable some diagnostics on per-project basis. Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
Yes, I think it's called |
@djc are you still encountering this? |
I haven't seen this in a while, but I can't say when exactly it stopped for me. |
Also haven't seen it in a while, but I haven't been using tokio-postgres that much recently (I no longer have access to the codebase I originally saw this in). |
Ok, I'll close this then. |
I have the same thing right now, using all the latest stuff. It is annoying that rust-analyzer complains but the code compiles just fine. impl<'a, Allocator, AllocatorError> Iterator for Structa, Allocator>
where
Allocator: CustomAllocator<Error = AllocatorError>,
{
// ....
} Compiles just fine, but rust-analyzer throws an error:
Also, it gets an incorrect understanding of the code:
Given that the code is: pub trait CustomAllocator {
/// The error type returned by the allocator methods.
type Error;
} |
I'm on the nightly channel, using VS Code. Since yesterday, I'm seeing this issue:
The
row
in question is aRow
. However,cargo c
on the command line thinks my code is fine.The text was updated successfully, but these errors were encountered: