Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

benchmarking v2 syntax is confusingly lax about return types, leading to confusion #13278

@sam0x17

Description

@sam0x17

The benchmarking v2 syntax allows any return type on benchmark function definitions. We should probably only be allowing () (blank return type) or Result<(), BenchmarkError> in scenarios where the programmer wants to use the ? operator somewhere in the benchmark function body.

After talking about this with @ggwpez we thought it would make sense to require a return type of Result<(), BenchmarkError> in scenarios where the programmer uses the ? operator within the function body, and also allow a blank () return type. Any other return types on the benchmark function definitions would trigger a compiler error. Doing things this way will make the benchmark function defintion feel more like a real function and will make people more aware that they can use ? in these contexts (and avoid the confusing situation where someone writes ? and it compiles even though what appears to be the enclosing function def does not have a Result or Option return type).

Open to any thoughts people may have, though!

Metadata

Metadata

Assignees

Labels

U2-some_time_soonIssue is worth doing soon.Z1-easyCan be fixed primarily by duplicating and adapting code by an intermediate coder

Type

No type

Projects

Status

Done

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions