wasm-tools icon indicating copy to clipboard operation
wasm-tools copied to clipboard

wasmparser: `for_each_operator!` assumes specific name of the lifetime

Open nagisa opened this issue 1 year ago • 0 comments

for_each_operator! generates BrTable<'a> as an argument for one of the visitors. This in essence depends on the trait definition to specify 'a as the lifetime generic and implement specifically VisitOperator<'a>. Ideally macro could figure out and implicitly use the right lifetime without requiring the user to specify 'a specifically.

I tried a couple of things to remove this not-super-hygienic ambient-authority kinda thing:

  1. Generate BrTable<'_> instead – rustc wants to see 'a there;
  2. Add type BrTable = wasmparser::BrTable<'a> to the trait declaration and pass <Self as VisitOperand>::BrTable – associated type defaults are unstable.

Didn’t spend any time thinking if there are other approaches we could take here.

nagisa avatar Nov 09 '22 15:11 nagisa