Auto merge of #112117 - bryangarza:track-caller-feature-gate, r=compiler-errors
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:
commit
e173a8e663
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
|
/// 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(
|
pub(super) fn maybe_forward_track_caller(
|
||||||
&mut self,
|
&mut self,
|
||||||
span: Span,
|
span: Span,
|
||||||
outer_hir_id: hir::HirId,
|
outer_hir_id: hir::HirId,
|
||||||
inner_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)
|
&& let Some(attrs) = self.attrs.get(&outer_hir_id.local_id)
|
||||||
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
|
&& attrs.into_iter().any(|attr| attr.has_name(sym::track_caller))
|
||||||
{
|
{
|
||||||
|
|
|
@ -56,6 +56,11 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
||||||
owner: NodeId,
|
owner: NodeId,
|
||||||
f: impl FnOnce(&mut LoweringContext<'_, 'hir>) -> hir::OwnerNode<'hir>,
|
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 {
|
let mut lctx = LoweringContext {
|
||||||
// Pseudo-globals.
|
// Pseudo-globals.
|
||||||
tcx: self.tcx,
|
tcx: self.tcx,
|
||||||
|
@ -83,7 +88,7 @@ impl<'a, 'hir> ItemLowerer<'a, 'hir> {
|
||||||
impl_trait_defs: Vec::new(),
|
impl_trait_defs: Vec::new(),
|
||||||
impl_trait_bounds: Vec::new(),
|
impl_trait_bounds: Vec::new(),
|
||||||
allow_try_trait: Some([sym::try_trait_v2, sym::yeet_desugar_details][..].into()),
|
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(),
|
generics_def_id_map: Default::default(),
|
||||||
};
|
};
|
||||||
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
|
lctx.with_hir_id_owner(owner, |lctx| f(lctx));
|
||||||
|
|
|
@ -215,14 +215,19 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: LocalDefId) -> CodegenFnAttrs {
|
||||||
}
|
}
|
||||||
sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL,
|
sym::thread_local => codegen_fn_attrs.flags |= CodegenFnAttrFlags::THREAD_LOCAL,
|
||||||
sym::track_caller => {
|
sym::track_caller => {
|
||||||
if !tcx.is_closure(did.to_def_id())
|
let is_closure = tcx.is_closure(did.to_def_id());
|
||||||
|
|
||||||
|
if !is_closure
|
||||||
&& let Some(fn_sig) = fn_sig()
|
&& let Some(fn_sig) = fn_sig()
|
||||||
&& fn_sig.skip_binder().abi() != abi::Abi::Rust
|
&& fn_sig.skip_binder().abi() != abi::Abi::Rust
|
||||||
{
|
{
|
||||||
struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI")
|
struct_span_err!(tcx.sess, attr.span, E0737, "`#[track_caller]` requires Rust ABI")
|
||||||
.emit();
|
.emit();
|
||||||
}
|
}
|
||||||
if tcx.is_closure(did.to_def_id()) && !tcx.features().closure_track_caller {
|
if is_closure
|
||||||
|
&& !tcx.features().closure_track_caller
|
||||||
|
&& !attr.span.allows_unstable(sym::closure_track_caller)
|
||||||
|
{
|
||||||
feature_err(
|
feature_err(
|
||||||
&tcx.sess.parse_sess,
|
&tcx.sess.parse_sess,
|
||||||
sym::closure_track_caller,
|
sym::closure_track_caller,
|
||||||
|
|
|
@ -339,6 +339,8 @@ declare_features! (
|
||||||
(active, async_closure, "1.37.0", Some(62290), None),
|
(active, async_closure, "1.37.0", Some(62290), None),
|
||||||
/// Allows async functions to be declared, implemented, and used in traits.
|
/// Allows async functions to be declared, implemented, and used in traits.
|
||||||
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
|
(active, async_fn_in_trait, "1.66.0", Some(91611), None),
|
||||||
|
/// Allows `#[track_caller]` on async functions.
|
||||||
|
(active, async_fn_track_caller, "CURRENT_RUSTC_VERSION", Some(110011), None),
|
||||||
/// Allows builtin # foo() syntax
|
/// Allows builtin # foo() syntax
|
||||||
(active, builtin_syntax, "1.71.0", Some(110680), None),
|
(active, builtin_syntax, "1.71.0", Some(110680), None),
|
||||||
/// Allows `c"foo"` literals.
|
/// Allows `c"foo"` literals.
|
||||||
|
|
|
@ -1259,8 +1259,8 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures {
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
/// The `ungated_async_fn_track_caller` lint warns when the
|
/// The `ungated_async_fn_track_caller` lint warns when the
|
||||||
/// `#[track_caller]` attribute is used on an async function, method, or
|
/// `#[track_caller]` attribute is used on an async function
|
||||||
/// closure, without enabling the corresponding unstable feature flag.
|
/// without enabling the corresponding unstable feature flag.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
///
|
///
|
||||||
|
@ -1274,13 +1274,13 @@ declare_lint! {
|
||||||
/// ### Explanation
|
/// ### Explanation
|
||||||
///
|
///
|
||||||
/// The attribute must be used in conjunction with the
|
/// The attribute must be used in conjunction with the
|
||||||
/// [`closure_track_caller` feature flag]. Otherwise, the `#[track_caller]`
|
/// [`async_fn_track_caller` feature flag]. Otherwise, the `#[track_caller]`
|
||||||
/// annotation will function as a no-op.
|
/// annotation will function as a no-op.
|
||||||
///
|
///
|
||||||
/// [`closure_track_caller` feature flag]: https://doc.rust-lang.org/beta/unstable-book/language-features/closure-track-caller.html
|
/// [`async_fn_track_caller` feature flag]: https://doc.rust-lang.org/beta/unstable-book/language-features/async-fn-track-caller.html
|
||||||
UNGATED_ASYNC_FN_TRACK_CALLER,
|
UNGATED_ASYNC_FN_TRACK_CALLER,
|
||||||
Warn,
|
Warn,
|
||||||
"enabling track_caller on an async fn is a no-op unless the closure_track_caller feature is enabled"
|
"enabling track_caller on an async fn is a no-op unless the async_fn_track_caller feature is enabled"
|
||||||
}
|
}
|
||||||
|
|
||||||
declare_lint_pass!(
|
declare_lint_pass!(
|
||||||
|
@ -1300,7 +1300,7 @@ impl<'tcx> LateLintPass<'tcx> for UngatedAsyncFnTrackCaller {
|
||||||
def_id: LocalDefId,
|
def_id: LocalDefId,
|
||||||
) {
|
) {
|
||||||
if fn_kind.asyncness() == IsAsync::Async
|
if fn_kind.asyncness() == IsAsync::Async
|
||||||
&& !cx.tcx.features().closure_track_caller
|
&& !cx.tcx.features().async_fn_track_caller
|
||||||
// Now, check if the function has the `#[track_caller]` attribute
|
// Now, check if the function has the `#[track_caller]` attribute
|
||||||
&& let Some(attr) = cx.tcx.get_attr(def_id, sym::track_caller)
|
&& let Some(attr) = cx.tcx.get_attr(def_id, sym::track_caller)
|
||||||
{
|
{
|
||||||
|
|
|
@ -250,7 +250,7 @@ impl<'a> DecorateLint<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> {
|
||||||
rustc_session::parse::add_feature_diagnostics(
|
rustc_session::parse::add_feature_diagnostics(
|
||||||
diag,
|
diag,
|
||||||
&self.parse_sess,
|
&self.parse_sess,
|
||||||
sym::closure_track_caller,
|
sym::async_fn_track_caller,
|
||||||
);
|
);
|
||||||
diag
|
diag
|
||||||
}
|
}
|
||||||
|
|
|
@ -400,6 +400,7 @@ symbols! {
|
||||||
async_await,
|
async_await,
|
||||||
async_closure,
|
async_closure,
|
||||||
async_fn_in_trait,
|
async_fn_in_trait,
|
||||||
|
async_fn_track_caller,
|
||||||
atomic,
|
atomic,
|
||||||
atomic_mod,
|
atomic_mod,
|
||||||
atomics,
|
atomics,
|
||||||
|
|
30
tests/ui/async-await/track-caller/async-block.afn.stderr
Normal file
30
tests/ui/async-await/track-caller/async-block.afn.stderr
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:8:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:23:17
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
30
tests/ui/async-await/track-caller/async-block.nofeat.stderr
Normal file
30
tests/ui/async-await/track-caller/async-block.nofeat.stderr
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:8:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-block.rs:23:17
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
|
@ -1,9 +1,27 @@
|
||||||
// edition:2021
|
// edition:2021
|
||||||
|
// revisions: afn nofeat
|
||||||
|
|
||||||
#![feature(stmt_expr_attributes)]
|
#![feature(stmt_expr_attributes)]
|
||||||
|
#![cfg_attr(afn, feature(async_fn_track_caller))]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = #[track_caller] async {
|
let _ = #[track_caller] async {
|
||||||
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
async fn foo() {
|
||||||
|
let _ = #[track_caller] async {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
async fn foo2() {
|
||||||
|
let _ = async {
|
||||||
|
let _ = #[track_caller] async {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
error[E0658]: `#[track_caller]` on closures is currently unstable
|
|
||||||
--> $DIR/async-block.rs:6:13
|
|
||||||
|
|
|
||||||
LL | let _ = #[track_caller] async {
|
|
||||||
| ^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
|
||||||
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:8:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:21:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:28:17
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:36:9
|
||||||
|
|
|
||||||
|
LL | #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:45:13
|
||||||
|
|
|
||||||
|
LL | #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
|
@ -0,0 +1,57 @@
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:8:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:15:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] async || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:21:13
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:28:17
|
||||||
|
|
|
||||||
|
LL | let _ = #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:36:9
|
||||||
|
|
|
||||||
|
LL | #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error[E0658]: `#[track_caller]` on closures is currently unstable
|
||||||
|
--> $DIR/async-closure-gate.rs:45:13
|
||||||
|
|
|
||||||
|
LL | #[track_caller] || {
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
||||||
|
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
error: aborting due to 6 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0658`.
|
|
@ -1,9 +1,50 @@
|
||||||
// edition:2021
|
// edition:2021
|
||||||
|
// revisions: afn nofeat
|
||||||
|
|
||||||
#![feature(async_closure, stmt_expr_attributes)]
|
#![feature(async_closure, stmt_expr_attributes)]
|
||||||
|
#![cfg_attr(afn, feature(async_fn_track_caller))]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let _ = #[track_caller] async || {
|
let _ = #[track_caller] async || {
|
||||||
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[track_caller]
|
||||||
|
async fn foo() {
|
||||||
|
let _ = #[track_caller] async || {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn foo2() {
|
||||||
|
let _ = #[track_caller] || {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo3() {
|
||||||
|
async {
|
||||||
|
let _ = #[track_caller] || {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn foo4() {
|
||||||
|
let _ = || {
|
||||||
|
#[track_caller] || {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
fn foo5() {
|
||||||
|
async {
|
||||||
|
let _ = || {
|
||||||
|
#[track_caller] || {
|
||||||
|
//~^ ERROR `#[track_caller]` on closures is currently unstable [E0658]
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +0,0 @@
|
||||||
error[E0658]: `#[track_caller]` on closures is currently unstable
|
|
||||||
--> $DIR/async-closure-gate.rs:6:13
|
|
||||||
|
|
|
||||||
LL | let _ = #[track_caller] async || {
|
|
||||||
| ^^^^^^^^^^^^^^^
|
|
||||||
|
|
|
||||||
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
|
||||||
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
|
||||||
|
|
||||||
error: aborting due to previous error
|
|
||||||
|
|
||||||
For more information about this error, try `rustc --explain E0658`.
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
warning: `#[track_caller]` on async functions is a no-op
|
||||||
|
--> $DIR/panic-track-caller.rs:53:1
|
||||||
|
|
|
||||||
|
LL | #[track_caller]
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
|
LL | / async fn bar_track_caller() {
|
||||||
|
LL | | panic!()
|
||||||
|
LL | | }
|
||||||
|
| |_- this function will not propagate the caller location
|
||||||
|
|
|
||||||
|
= note: see issue #110011 <https://github.com/rust-lang/rust/issues/110011> for more information
|
||||||
|
= help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable
|
||||||
|
= note: `#[warn(ungated_async_fn_track_caller)]` on by default
|
||||||
|
|
||||||
|
warning: `#[track_caller]` on async functions is a no-op
|
||||||
|
--> $DIR/panic-track-caller.rs:67:5
|
||||||
|
|
|
||||||
|
LL | #[track_caller]
|
||||||
|
| ^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
|
LL | / async fn bar_assoc() {
|
||||||
|
LL | | panic!();
|
||||||
|
LL | | }
|
||||||
|
| |_____- this function will not propagate the caller location
|
||||||
|
|
|
||||||
|
= note: see issue #110011 <https://github.com/rust-lang/rust/issues/110011> for more information
|
||||||
|
= help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
|
warning: 2 warnings emitted
|
||||||
|
|
|
@ -1,29 +1,31 @@
|
||||||
warning: `#[track_caller]` on async functions is a no-op
|
warning: `#[track_caller]` on async functions is a no-op
|
||||||
--> $DIR/panic-track-caller.rs:50:1
|
--> $DIR/panic-track-caller.rs:53:1
|
||||||
|
|
|
|
||||||
LL | #[track_caller]
|
LL | #[track_caller]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
LL | / async fn bar_track_caller() {
|
LL | / async fn bar_track_caller() {
|
||||||
LL | | panic!()
|
LL | | panic!()
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_- this function will not propagate the caller location
|
| |_- this function will not propagate the caller location
|
||||||
|
|
|
|
||||||
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
= note: see issue #110011 <https://github.com/rust-lang/rust/issues/110011> for more information
|
||||||
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
= help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable
|
||||||
= note: `#[warn(ungated_async_fn_track_caller)]` on by default
|
= note: `#[warn(ungated_async_fn_track_caller)]` on by default
|
||||||
|
|
||||||
warning: `#[track_caller]` on async functions is a no-op
|
warning: `#[track_caller]` on async functions is a no-op
|
||||||
--> $DIR/panic-track-caller.rs:62:5
|
--> $DIR/panic-track-caller.rs:67:5
|
||||||
|
|
|
|
||||||
LL | #[track_caller]
|
LL | #[track_caller]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
...
|
||||||
LL | / async fn bar_assoc() {
|
LL | / async fn bar_assoc() {
|
||||||
LL | | panic!();
|
LL | | panic!();
|
||||||
LL | | }
|
LL | | }
|
||||||
| |_____- this function will not propagate the caller location
|
| |_____- this function will not propagate the caller location
|
||||||
|
|
|
|
||||||
= note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information
|
= note: see issue #110011 <https://github.com/rust-lang/rust/issues/110011> for more information
|
||||||
= help: add `#![feature(closure_track_caller)]` to the crate attributes to enable
|
= help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable
|
||||||
|
|
||||||
warning: 2 warnings emitted
|
warning: 2 warnings emitted
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
// run-pass
|
// run-pass
|
||||||
// edition:2021
|
// edition:2021
|
||||||
// revisions: feat nofeat
|
// revisions: afn cls nofeat
|
||||||
// needs-unwind
|
// needs-unwind
|
||||||
|
// gate-test-async_fn_track_caller
|
||||||
#![feature(async_closure, stmt_expr_attributes)]
|
#![feature(async_closure, stmt_expr_attributes)]
|
||||||
#![cfg_attr(feat, feature(closure_track_caller))]
|
#![cfg_attr(afn, feature(async_fn_track_caller))]
|
||||||
|
#![cfg_attr(cls, feature(closure_track_caller))]
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
use std::panic;
|
use std::panic;
|
||||||
|
@ -47,7 +50,9 @@ async fn foo() {
|
||||||
bar().await
|
bar().await
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op
|
#[track_caller]
|
||||||
|
//[cls]~^ WARN `#[track_caller]` on async functions is a no-op
|
||||||
|
//[nofeat]~^^ WARN `#[track_caller]` on async functions is a no-op
|
||||||
async fn bar_track_caller() {
|
async fn bar_track_caller() {
|
||||||
panic!()
|
panic!()
|
||||||
}
|
}
|
||||||
|
@ -59,7 +64,9 @@ async fn foo_track_caller() {
|
||||||
struct Foo;
|
struct Foo;
|
||||||
|
|
||||||
impl Foo {
|
impl Foo {
|
||||||
#[track_caller] //[nofeat]~ WARN `#[track_caller]` on async functions is a no-op
|
#[track_caller]
|
||||||
|
//[cls]~^ WARN `#[track_caller]` on async functions is a no-op
|
||||||
|
//[nofeat]~^^ WARN `#[track_caller]` on async functions is a no-op
|
||||||
async fn bar_assoc() {
|
async fn bar_assoc() {
|
||||||
panic!();
|
panic!();
|
||||||
}
|
}
|
||||||
|
@ -71,7 +78,7 @@ async fn foo_assoc() {
|
||||||
|
|
||||||
// Since compilation is expected to fail for this fn when using
|
// Since compilation is expected to fail for this fn when using
|
||||||
// `nofeat`, we test that separately in `async-closure-gate.rs`
|
// `nofeat`, we test that separately in `async-closure-gate.rs`
|
||||||
#[cfg(feat)]
|
#[cfg(cls)]
|
||||||
async fn foo_closure() {
|
async fn foo_closure() {
|
||||||
let c = #[track_caller] async || {
|
let c = #[track_caller] async || {
|
||||||
panic!();
|
panic!();
|
||||||
|
@ -81,7 +88,7 @@ async fn foo_closure() {
|
||||||
|
|
||||||
// Since compilation is expected to fail for this fn when using
|
// Since compilation is expected to fail for this fn when using
|
||||||
// `nofeat`, we test that separately in `async-block.rs`
|
// `nofeat`, we test that separately in `async-block.rs`
|
||||||
#[cfg(feat)]
|
#[cfg(cls)]
|
||||||
async fn foo_block() {
|
async fn foo_block() {
|
||||||
let a = #[track_caller] async {
|
let a = #[track_caller] async {
|
||||||
panic!();
|
panic!();
|
||||||
|
@ -106,21 +113,22 @@ fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
assert_eq!(panicked_at(|| block_on(foo())), 43);
|
assert_eq!(panicked_at(|| block_on(foo())), 46
|
||||||
|
);
|
||||||
|
|
||||||
#[cfg(feat)]
|
#[cfg(afn)]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 56);
|
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 61);
|
||||||
#[cfg(nofeat)]
|
#[cfg(any(cls, nofeat))]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 52);
|
assert_eq!(panicked_at(|| block_on(foo_track_caller())), 57);
|
||||||
|
|
||||||
#[cfg(feat)]
|
#[cfg(afn)]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_assoc())), 69);
|
assert_eq!(panicked_at(|| block_on(foo_assoc())), 76);
|
||||||
#[cfg(nofeat)]
|
#[cfg(any(cls, nofeat))]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_assoc())), 64);
|
assert_eq!(panicked_at(|| block_on(foo_assoc())), 71);
|
||||||
|
|
||||||
#[cfg(feat)]
|
#[cfg(cls)]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_closure())), 79);
|
assert_eq!(panicked_at(|| block_on(foo_closure())), 84);
|
||||||
|
|
||||||
#[cfg(feat)]
|
#[cfg(cls)]
|
||||||
assert_eq!(panicked_at(|| block_on(foo_block())), 89);
|
assert_eq!(panicked_at(|| block_on(foo_block())), 96);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ Respanned: TokenStream [Ident { ident: "$crate", span: $DIR/auxiliary/make-macro
|
||||||
use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*;
|
use core /* 0#1 */::prelude /* 0#1 */::rust_2018 /* 0#1 */::*;
|
||||||
#[macro_use /* 0#1 */]
|
#[macro_use /* 0#1 */]
|
||||||
extern crate core /* 0#1 */;
|
extern crate core /* 0#1 */;
|
||||||
extern crate compiler_builtins /* 443 */ as _ /* 0#1 */;
|
extern crate compiler_builtins /* 444 */ as _ /* 0#1 */;
|
||||||
// Don't load unnecessary hygiene information from std
|
// Don't load unnecessary hygiene information from std
|
||||||
extern crate std /* 0#0 */;
|
extern crate std /* 0#0 */;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ PRINT-BANG INPUT (DEBUG): TokenStream [
|
||||||
use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*;
|
use ::core /* 0#1 */::prelude /* 0#1 */::rust_2015 /* 0#1 */::*;
|
||||||
#[macro_use /* 0#1 */]
|
#[macro_use /* 0#1 */]
|
||||||
extern crate core /* 0#2 */;
|
extern crate core /* 0#2 */;
|
||||||
extern crate compiler_builtins /* 443 */ as _ /* 0#2 */;
|
extern crate compiler_builtins /* 444 */ as _ /* 0#2 */;
|
||||||
// Don't load unnecessary hygiene information from std
|
// Don't load unnecessary hygiene information from std
|
||||||
extern crate std /* 0#0 */;
|
extern crate std /* 0#0 */;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue