Files
rust/compiler/rustc_const_eval
Nicholas Nethercote d4503b017e Overhaul ensure_ok.
`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.
2026-03-08 09:39:39 +11:00
..
2026-03-08 09:39:39 +11:00