viperproject / prusti-dev

A static verifier for Rust, based on the Viper verification infrastructure.
http://prusti.org
Other
1.55k stars 106 forks source link

Spans of quantified variables #190

Open fpoli opened 4 years ago

fpoli commented 4 years ago

The Spanned::get_spans method needs a MIR body to obtain the spans of variables stored in the ForAllVars<'tcx> type. Currently, the MIR body is passed as argument and is used to resolve all quantifiers in an assertion, but each quantifier should use its own MIR body: the one in which the quantified variables are declared.

https://github.com/viperproject/prusti-dev/blob/7ac30e86ecd31a8b766c1a50a719dd4302bc4d17/prusti-interface/src/specs/typed.rs#L54-L62

A solution:

  1. Add a definition: LocalDefId field to the typed::ForAllVars structure (this probably requires adding one more type parameter to common::ForAllVars`).
  2. Remove the mir_body: mir::Body argument from all Spanned::get_spans methods, using the precedently added definition field to resolve local variables in typed::ForAllVars.
Aurel300 commented 2 years ago

Spanned no longer exists in the codebase. Errors (parse and type) are reported at the correct location thanks to how the new preparser works. There are two potential problems still:

We should get the span of the qvar local from the MIR to report errors (make this change as part of #882).