obi1kenobi / cargo-semver-checks

Scan your Rust crate for semver violations.
Apache License 2.0
1.18k stars 75 forks source link

New lints: fn changed ABI #503

Open obi1kenobi opened 1 year ago

obi1kenobi commented 1 year ago

Lints:

obi1kenobi commented 8 months ago

The third checkbox was handled in #650.

qstommyshu commented 8 months ago

Hi, I would like to try the remaining task on this issue. I tried to understand the pattern from the PR for the two completed task from this issue, but there are still things I don't understand, like how to check what are the fields available to a baseline and when and why do we choose to write ... on Function {} at some point. Can you please give me some guidance on these? Thanks!

obi1kenobi commented 8 months ago

Thanks for looking into this.

Have you had a chance to check out the schema these queries are written against, or tried out some queries in the rustdoc query playground? If not, they are good to take a peek at. Note that the playground can only query one crate at a time — it can't compare two different versions at once.

The baseline edge points to type Crate, and Crate's item edge points to interface Item. We aren't looking for just about any Item, though, we want Function specifically — hence ... on Function.

Hope this helps! Let me know if you have any more questions!

qstommyshu commented 8 months ago

Thanks for the guide! I think I start to have an idea on how to add a new lint now. A little issue came up when I try to add a lint.

I followed the contribution guide to add a new lint. However, it failed along with many other lints with the error code: "Once instance has previously been poisoned"

image

Is there a fix for these lints? Many of them fails even in a freshly cloned repo.

image
obi1kenobi commented 8 months ago

That error message means there was another, earlier error that caused the Once data structure to not be set up correctly. Scroll up in the log and you should see the underlying error info.

If they fail in a freshly cloned repo, then my best guess is that you might not have the right version of Rust installed.

qstommyshu commented 8 months ago

Got it, thanks. It turns out the cause of my issue was I didn't generate the required rust doc JSON before running cargo test. I've fixed it and added a new lint in #683. Can you please review it when you have time? Thanks!

pksunkara commented 7 months ago

@obi1kenobi The second & third points in this are done, right? I am asking because they not ticked.

obi1kenobi commented 7 months ago

Yeah! So I guess this issue seems done -- nice!

pksunkara commented 7 months ago

I think I got confused yesterday. I haven't seen the 3rd one implemented. Can you please double check?

obi1kenobi commented 7 months ago

Agreed, not done yet. Reopening.

We probably want to do a review of the lints and test cases here, to ensure they are consistent and have minimal overlap. It looks like the lint that matches on #[export_name] uses the raw ABI string (e.g. "C-unwind") to compare, meaning it doesn't offer more granular feedback on the nature of the breakage: whether it's unwinding-related only, or something more.

It's also likely that if a function is both #[export_name] / #[no_mangle] and also public API, we might get duplicate lints specifically about ABI breakage. We should think through how we structure the lints (and write appropriate test cases) to do our best to avoid this.

pksunkara commented 7 months ago

Yup, agreed. That is one of the reasons I got super confused yesterday when looking at this group.