Per @Centril's comment, we want to move async unsafe fn to its own feature gate:
I would also like to move
async unsafe fnout of the MVP into its own feature gate because I think a) it has seen little use, b) it is not particularly well tested, c) it ostensibly behaves weirdly because the.awaitpoint is not where you writeunsafe { ... }and this is understandable from "leaky implementation POV" but not so much from an effects POV, d) it has seen little discussion and was not included in the RFC nor this report, and e) we did this withconst fnand it worked fine. (I can write up the feature gating PR)
This issue has been assigned to @delan via this comment.
Mentoring instructions:
In libsyntax/parse/mod.rs there's a struct ParseSess. To it, you want to add: pub async_unsafe_spans: Lock<Vec<Span>>, and then modify fn with_span_handler as well in the same file.
In libsyntax/feature_gate.rs you want to add a new active feature gate to the bottom (see the async_closure example) and then modify check_crate (also see async_closure_spans example).
In parse_fn_front_matter inside libsyntax/parse/parser.rs you want to modify fn parse_fn_front_matter such that when asyncness.is_async() and unsafety == Unsafety::Unsafe coincide, you push the Span of the unsafe token to async_unsafe_spans.
In parse_item_implementation inside libsyntax/parse/parser.rs you want to modify the if self.check_keyword(kw::Async) { case analogously.
You then want to add a feature gate test to src/test/ui/async-await/feature-async-unsafe.rs which also checks that the feature gate is required even under #[cfg(FALSE)] on a function. Make sure you test both free functions and functions in implementations.
You will also need to edit various tests which will now fail due to feature gating. Make sure to also move out async unsafe fn tests into standalone test files.
For an example of splitting a feature gate see https://github.com/rust-lang/rust/pull/62292.
The tracking issue to use is https://github.com/rust-lang/rust/issues/62501.
@rustbot claim
I was convinced not to feature gate this after all (see https://github.com/rust-lang/rust/issues/62149#issuecomment-510541229). Sorry about the noise!
Most helpful comment
Mentoring instructions:
In
libsyntax/parse/mod.rsthere's astruct ParseSess. To it, you want to add:pub async_unsafe_spans: Lock<Vec<Span>>,and then modifyfn with_span_handleras well in the same file.In
libsyntax/feature_gate.rsyou want to add a newactivefeature gate to the bottom (see theasync_closureexample) and then modifycheck_crate(also seeasync_closure_spansexample).In
parse_fn_front_matterinsidelibsyntax/parse/parser.rsyou want to modifyfn parse_fn_front_mattersuch that whenasyncness.is_async()andunsafety == Unsafety::Unsafecoincide, you push theSpanof theunsafetoken toasync_unsafe_spans.In
parse_item_implementationinsidelibsyntax/parse/parser.rsyou want to modify theif self.check_keyword(kw::Async) {case analogously.You then want to add a feature gate test to
src/test/ui/async-await/feature-async-unsafe.rswhich also checks that the feature gate is required even under#[cfg(FALSE)]on a function. Make sure you test both free functions and functions in implementations.You will also need to edit various tests which will now fail due to feature gating. Make sure to also move out
async unsafe fntests into standalone test files.For an example of splitting a feature gate see https://github.com/rust-lang/rust/pull/62292.