-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
u32 has bad diagnostics with #[pg_extern]
#1577
base: develop
Are you sure you want to change the base?
u32 has bad diagnostics with #[pg_extern]
#1577
Conversation
@nyurik This is a bit indirect still, isn't it? The spans are all fucked up. |
Thx for working on it! But yeah, trait not satisfied error is a bit of a rabbit hole... Perhaps it might be better to handle it explicitly? I am sure there will be plenty of surprises for such a common use case of an incorrect data type - so juts look at the input/return params in the |
744784f
to
573eb54
Compare
nondet diagnostic output, adding cshim alters the hash I think |
Well, I'd rather not special-case the strings of any types (at least, any further than our code already does...), because given the sheer amount of FFI pgrx involves, people are very likely to do something like: #[pg_extern]
fn pg_fn(arg: ffi::c_uint) -> ffi::c_ulong { |
This is not to say I'm against adding more diagnostic code here, I'd just rather do so in a more underhanded / generic way, like e.g. emitting structs with the name of the error I would want to emit and embedding the argument and return types in the struct. |
Nope, last one didn't fix it. Guess I'm waiting for better test infra or finding a way to emit a better diagnostic or rustc being less random about ordering here. |
How about just handle the well known simple types, e.g. |
It feels like it lacks a satisfactory boundary. |
Well, it is not perfect, i agree, but if it will make the most common usecase more helpful... at least maybe give a warning? |
It isn't about perfection. The problem in this case is that there are three type systems involved (Rust's, C's, and Postgres's), and people are going to have different opinions about what is "obvious" and "common". Without usage statistics (and |
a883cd5
to
2470208
Compare
Check in a test that demonstrates this so that we are aware of improvements, and to prevent any regressions, as they used to be significantly worse.
I'm going to do some things that will significantly affect the diagnostics and might make them significantly worse or better, so this PR needs to serve its original purpose. |
Would the recently released diagnostics support help in this case? https://blog.rust-lang.org/2024/05/02/Rust-1.78.0.html#diagnostic-attributes |
Check in a test that demonstrates this so that we are aware of improvements, and to prevent any regressions, as they used to be significantly worse.
This is a step towards resolving these issues:
pg_extern
function returning u32 #951