3 ms·
Looking at examples of syntax for pre/post-conditions and invariants, it's all Rust expressions inside strings. Is there no other way for an attribute to have s
by int_19h 8y ago
Looking at examples of syntax for pre/post-conditions and invariants, it's all Rust expressions inside strings. Is there no other way for an attribute to have some associated inline code? Strings are not optimal for this, because they break tooling (syntax highlighting, code completion and navigation, refactoring etc).
- steveklabnik 8y agoUntil the release Thursday, it was not. As of the last release, it now is. This was probably written before that was available generally.
- int_19h 8y agoThanks! For the curious, more details here: https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#custom-attributes-accept-arbitrary-token-streams https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#custo... From tooling perspective, this isn't perfect, because there's still no guarantee that the token stream is a valid expression. So e.g. an IDE trying to highlight them or do a global rename refactor has to assume, which might not always be correct for token-based DSLs. It would be nice to have some metadata to distinguish those. Or perhaps there is an idiomatic way to express it in a contract on the macro itself, that tools could look at?
- steveklabnik 8y agoNot sure, to be honest.