Add separate feature gate for async fn track caller
This patch adds a feature gate `async_fn_track_caller` that is separate from `closure_track_caller`. This is to allow enabling `async_fn_track_caller` separately. Fixes #110009
This commit is contained in:
parent
20747af894
commit
673ab17c7f
20 changed files with 326 additions and 63 deletions
|
@ -657,14 +657,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
|||
}
|
||||
|
||||
/// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to
|
||||
/// `inner_hir_id` in case the `closure_track_caller` feature is enabled.
|
||||
/// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled.
|
||||
pub(super) fn maybe_forward_track_caller(
|
||||
&mut self,
|
||||
span: Span,
|
||||
outer_hir_id: hir::HirId,
|
||||
inner_hir_id: hir::HirId,
|
||||
) {
|
||||
if self.tcx.features().closure_track_caller
|
||||
if self.tcx.features().async_fn_track_caller
|
||||
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
|
||||
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
|
||||
{
|
||||
|
|
|
@ -56,6 +56,11 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
|||
owner: NodeId,
|
||||
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
|
||||
) {
|
||||
let allow_gen_future = Some(if self.tcx.features().async_fn_track_caller {
|
||||
[sym::gen_future, sym::closure_track_caller][..].into()
|
||||
} else {
|
||||
[sym::gen_future][..].into()
|
||||
});
|
||||
let mut lctx = LoweringContext {
|
||||
// Pseudo-globals.
|
||||
tcx: self.tcx,
|
||||
|
@ -83,7 +88,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
|||
impl_trait_defs: Vec::new(),
|
||||
impl_trait_bounds: Vec::new(),
|
||||
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()),
|
||||
allow_gen_future: Some([sym::gen_future, sym::closure_track_caller][..].into()),
|
||||
allow_gen_future,
|
||||
generics_def_id_map: Default::default(),
|
||||
};
|
||||
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue