mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
d4503b017e
`ensure_ok` provides a special, more efficient way of calling a query when its return value isn't needed. But there is a complication: if the query is marked with the `return_result_from_ensure_ok` modifier, then it will return `Result<(), ErrorGuaranteed`. This is clunky and feels tacked on. It's annoying to have to add a modifier to a query to declare information present in its return type, and it's confusing that queries called via `ensure_ok` have different return types depending on the modifier. This commit: - Eliminates the `return_result_from_ensure_ok` modifier. The proc macro now looks at the return type and detects if it matches `Result<_, ErrorGuarantee>`. If so, it adds the modifier `returns_error_guaranteed`. (Aside: We need better terminology to distinguish modifiers written by the user in a `query` declaration (e.g. `cycle_delayed_bug`) from modifiers added by the proc macro (e.g. `cycle_error_handling`.)) - Introduces `ensure_result`, which replaces the use of `ensure_ok` for queries that return `Result<_, ErrorGuarantee>`. As a result, `ensure_ok` can now only be used for the "ignore the return value" case.