Rollup merge of #129034 - henryksloan:coroutine-must-use, r=joboet · patricklam/verify-rust-std@b4bfc21 (original) (raw)
Navigation Menu
- GitHub Copilot Write better code with AI
- GitHub Models New Manage and compare prompts
- GitHub Advanced Security Find and fix vulnerabilities
- Actions Automate any workflow
- Codespaces Instant dev environments
- Issues Plan and track work
- Code Review Manage code changes
- Discussions Collaborate outside of code
- Code Search Find more, search less
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Commit b4bfc21
Rollup merge of rust-lang#129034 - henryksloan:coroutine-must-use, r=joboet
Add `#[must_use]` attribute to `Coroutine` trait [Coroutines tracking issue](rust-lang#43122) Like closures (`FnOnce`, `AsyncFn`, etc.), coroutines are lazy and do nothing unless called (resumed). Closure traits like `FnOnce` have `#[must_use = "closures are lazy and do nothing unless called"]` to catch likely bugs for users of APIs that produce them. This PR adds such a `#[must_use]` attribute to `trait Coroutine`.
File tree
1 file changed
lines changed
1 file changed
lines changed
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -69,6 +69,7 @@ pub enum CoroutineState<Y, R> { | ||
69 | 69 | #[lang = "coroutine"] |
70 | 70 | #[unstable(feature = "coroutine_trait", issue = "43122")] |
71 | 71 | #[fundamental] |
72 | +#[must_use = "coroutines are lazy and do nothing unless resumed"] | |
72 | 73 | pub trait Coroutine<R = ()> { |
73 | 74 | /// The type of value this coroutine yields. |
74 | 75 | /// |