flux-rs / flux

Refinement Types for Rust
MIT License
658 stars 21 forks source link

Add additional helpful spans to opaque struct field access diagnostics #862

Closed vrindisbacher closed 2 weeks ago

vrindisbacher commented 4 weeks ago

See here

vrindisbacher commented 4 weeks ago

Closes (#835).

vrindisbacher commented 2 weeks ago

@nilehmann, is there a straight forward way to get the span for the wrapping function? I only know how to get the struct's (and it's related impls) span, since it seems like the span for the field access in the function body has no parent.

nilehmann commented 2 weeks ago

no, there's no easy way right now. When we construct a CheckerError we only pass the Span of the current Statement being checked and I don't think you can go from that to the span of the containing function. However, I think we don't emit CheckerErrors in too many places so something we could try is not implement Diagnostic for CheckerError this will point to all the places where we emit it and hopefully we will have the DefId of the function at those places, for example, here https://github.com/flux-rs/flux/blob/main/crates/flux-refineck/src/lib.rs/#L154. At those places, we can call a helper function that takes a GlobalEnv, a CheckerError, and the DefId of the containing function, it then constructs the Diag and emits it.

vrindisbacher commented 2 weeks ago

Hmm, not sure why the CI stuff is failing. It builds fine locally, and the line it's complaining about is different than what the dialog points to...

nilehmann commented 2 weeks ago

@vrindisbacher I think you local branch is too old. The ci is failing because it runs on the code after being merged with main.