diff --git a/compiler/rustc_ast_lowering/src/expr.rs b/compiler/rustc_ast_lowering/src/expr.rs index db0dd2fcc6191..3462e8da504aa 100644 --- a/compiler/rustc_ast_lowering/src/expr.rs +++ b/compiler/rustc_ast_lowering/src/expr.rs @@ -881,15 +881,14 @@ impl<'hir> LoweringContext<'_, 'hir> { } /// Forwards a possible `#[track_caller]` annotation from `outer_hir_id` to - /// `inner_hir_id` in case the `async_fn_track_caller` feature is enabled. + /// `inner_hir_id`. pub(super) fn maybe_forward_track_caller( &mut self, span: Span, outer_hir_id: HirId, inner_hir_id: HirId, ) { - if self.tcx.features().async_fn_track_caller() - && let Some(attrs) = self.attrs.get(&outer_hir_id.local_id) + if let Some(attrs) = self.attrs.get(&outer_hir_id.local_id) && find_attr!(*attrs, TrackCaller(_)) { let unstable_span = self.mark_span_with_reason( diff --git a/compiler/rustc_ast_lowering/src/item.rs b/compiler/rustc_ast_lowering/src/item.rs index d5ef2f9e832dd..6ef1ca22257a5 100644 --- a/compiler/rustc_ast_lowering/src/item.rs +++ b/compiler/rustc_ast_lowering/src/item.rs @@ -1460,7 +1460,6 @@ impl<'hir> LoweringContext<'_, 'hir> { hir::CoroutineSource::Fn, ); - // FIXME(async_fn_track_caller): Can this be moved above? let hir_id = expr.hir_id; this.maybe_forward_track_caller(body.span, fn_id, hir_id); diff --git a/compiler/rustc_ast_lowering/src/lib.rs b/compiler/rustc_ast_lowering/src/lib.rs index 1265bae778601..394e74d0939e0 100644 --- a/compiler/rustc_ast_lowering/src/lib.rs +++ b/compiler/rustc_ast_lowering/src/lib.rs @@ -276,11 +276,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> { ] .into(), allow_pattern_type: [sym::pattern_types, sym::pattern_type_range_trait].into(), - allow_gen_future: if tcx.features().async_fn_track_caller() { - [sym::gen_future, sym::closure_track_caller].into() - } else { - [sym::gen_future].into() - }, + allow_gen_future: [sym::gen_future, sym::closure_track_caller].into(), allow_for_await: [sym::async_gen_internals, sym::async_iterator].into(), allow_async_fn_traits: [sym::async_fn_traits].into(), allow_async_gen: [sym::async_gen_internals].into(), diff --git a/compiler/rustc_feature/src/accepted.rs b/compiler/rustc_feature/src/accepted.rs index a6e6f4f78323c..1901910977072 100644 --- a/compiler/rustc_feature/src/accepted.rs +++ b/compiler/rustc_feature/src/accepted.rs @@ -79,6 +79,8 @@ declare_features! ( (accepted, async_closure, "1.85.0", Some(62290)), /// Allows async functions to be declared, implemented, and used in traits. (accepted, async_fn_in_trait, "1.75.0", Some(91611)), + /// Allows `#[track_caller]` on async functions. + (accepted, async_fn_track_caller, "CURRENT_RUSTC_VERSION", Some(110011)), /// Allows all literals in attribute lists and values of key-value pairs. (accepted, attr_literals, "1.30.0", Some(34981)), /// Allows overloading augmented assignment operations like `a += b`. diff --git a/compiler/rustc_feature/src/unstable.rs b/compiler/rustc_feature/src/unstable.rs index 187ce8d639fb4..9236160966c15 100644 --- a/compiler/rustc_feature/src/unstable.rs +++ b/compiler/rustc_feature/src/unstable.rs @@ -410,8 +410,6 @@ declare_features! ( (incomplete, async_drop, "1.88.0", Some(126482)), /// Allows async functions to be called from `dyn Trait`. (incomplete, async_fn_in_dyn_trait, "1.85.0", Some(133119)), - /// Allows `#[track_caller]` on async functions. - (unstable, async_fn_track_caller, "1.73.0", Some(110011)), /// Allows `for await` loops. (unstable, async_for_loop, "1.77.0", Some(118898)), /// Allows `async` trait bound modifier. diff --git a/compiler/rustc_lint/src/builtin.rs b/compiler/rustc_lint/src/builtin.rs index a2112293df204..dda8035f5fd8c 100644 --- a/compiler/rustc_lint/src/builtin.rs +++ b/compiler/rustc_lint/src/builtin.rs @@ -28,8 +28,7 @@ use rustc_hir::attrs::lang_items::LangItem; use rustc_hir::attrs::{AttributeKind, DocAttribute}; use rustc_hir::def::{DefKind, Res}; use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId}; -use rustc_hir::intravisit::FnKind as HirFnKind; -use rustc_hir::{self as hir, Body, FnDecl, ImplItemImplKind, PatKind, PredicateOrigin, find_attr}; +use rustc_hir::{self as hir, ImplItemImplKind, PatKind, PredicateOrigin, find_attr}; // Lints from rustc_lint_defs pub use rustc_lint_defs::builtin::*; use rustc_lint_defs::{declare_lint, declare_lint_pass, fcw, impl_lint_pass}; @@ -55,10 +54,9 @@ use crate::diagnostics::{ BuiltinIncompleteFeaturesHelp, BuiltinInternalFeatures, BuiltinKeywordIdents, BuiltinMissingCopyImpl, BuiltinMissingDebugImpl, BuiltinMissingDoc, BuiltinMutablesTransmutes, BuiltinNonShorthandFieldPatterns, BuiltinSpecialModuleNameUsed, BuiltinTrivialBounds, - BuiltinTypeAliasBounds, BuiltinUngatedAsyncFnTrackCaller, BuiltinUnpermittedTypeInit, - BuiltinUnpermittedTypeInitSub, BuiltinUnreachablePub, BuiltinUnsafe, BuiltinUnstableFeatures, - BuiltinUnusedDocComment, BuiltinUnusedDocCommentSub, BuiltinWhileTrue, - EqInternalMethodImplemented, InvalidAsmLabel, + BuiltinTypeAliasBounds, BuiltinUnpermittedTypeInit, BuiltinUnpermittedTypeInitSub, + BuiltinUnreachablePub, BuiltinUnsafe, BuiltinUnstableFeatures, BuiltinUnusedDocComment, + BuiltinUnusedDocCommentSub, BuiltinWhileTrue, EqInternalMethodImplemented, InvalidAsmLabel, }; use crate::{EarlyContext, EarlyLintPass, LateContext, LateLintPass, LintContext}; @@ -1042,62 +1040,6 @@ impl<'tcx> LateLintPass<'tcx> for UnstableFeatures { } } -declare_lint! { - /// The `ungated_async_fn_track_caller` lint warns when the - /// `#[track_caller]` attribute is used on an async function - /// without enabling the corresponding unstable feature flag. - /// - /// ### Example - /// - /// ```rust - /// #[track_caller] - /// async fn foo() {} - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// The attribute must be used in conjunction with the - /// [`async_fn_track_caller` feature flag]. Otherwise, the `#[track_caller]` - /// annotation will function as a no-op. - /// - /// [`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, - Warn, - "enabling track_caller on an async fn is a no-op unless the async_fn_track_caller feature is enabled" -} - -declare_lint_pass!( - /// Explains corresponding feature flag must be enabled for the `#[track_caller]` attribute to - /// do anything - UngatedAsyncFnTrackCaller => [UNGATED_ASYNC_FN_TRACK_CALLER] -); - -impl<'tcx> LateLintPass<'tcx> for UngatedAsyncFnTrackCaller { - fn check_fn( - &mut self, - cx: &LateContext<'_>, - fn_kind: HirFnKind<'_>, - _: &'tcx FnDecl<'_>, - _: &'tcx Body<'_>, - span: Span, - def_id: LocalDefId, - ) { - if fn_kind.asyncness().is_async() - && !cx.tcx.features().async_fn_track_caller() - // Now, check if the function has the `#[track_caller]` attribute - && let Some(attr_span) = find_attr!(cx.tcx, def_id, TrackCaller(span) => *span) - { - cx.emit_span_lint( - UNGATED_ASYNC_FN_TRACK_CALLER, - attr_span, - BuiltinUngatedAsyncFnTrackCaller { label: span, session: &cx.tcx.sess }, - ); - } - } -} - declare_lint! { /// The `unreachable_pub` lint triggers for `pub` items not reachable from other crates - that /// means neither directly accessible, nor reexported (with `pub use`), nor leaked through diff --git a/compiler/rustc_lint/src/diagnostics.rs b/compiler/rustc_lint/src/diagnostics.rs index a15eb4c569d03..b5f781eb45570 100644 --- a/compiler/rustc_lint/src/diagnostics.rs +++ b/compiler/rustc_lint/src/diagnostics.rs @@ -14,9 +14,8 @@ use rustc_hir::intravisit::VisitorExt; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_middle::ty::inhabitedness::InhabitedPredicate; use rustc_middle::ty::{Clause, PolyExistentialTraitRef, Ty, TyCtxt}; -use rustc_session::Session; use rustc_span::edition::Edition; -use rustc_span::{Ident, Span, Symbol, sym}; +use rustc_span::{Ident, Span, Symbol}; use crate::LateContext; use crate::builtin::{InitError, ShorthandAssocTyCollector, TypeAliasBounds}; @@ -362,25 +361,6 @@ pub(crate) struct BuiltinMutablesTransmutes; #[diag("use of an unstable feature")] pub(crate) struct BuiltinUnstableFeatures; -// lint_ungated_async_fn_track_caller -pub(crate) struct BuiltinUngatedAsyncFnTrackCaller<'a> { - pub label: Span, - pub session: &'a Session, -} - -impl<'a> Diagnostic<'a, ()> for BuiltinUngatedAsyncFnTrackCaller<'_> { - fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> { - let mut diag = Diag::new(dcx, level, "`#[track_caller]` on async functions is a no-op") - .with_span_label(self.label, "this function will not propagate the caller location"); - rustc_session::diagnostics::add_feature_diagnostics( - &mut diag, - self.session, - sym::async_fn_track_caller, - ); - diag - } -} - #[derive(Diagnostic)] #[diag("unreachable `pub` {$what}")] pub(crate) struct BuiltinUnreachablePub<'a> { diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index a8f4f06aaa4f7..de2e4433742ef 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -273,7 +273,6 @@ late_lint_methods!( TrivialConstraints: TrivialConstraints, TypeAliasBounds: TypeAliasBounds, TypeLimits: TypeLimits::new(), - UngatedAsyncFnTrackCaller: UngatedAsyncFnTrackCaller, UnitBindings: UnitBindings, UnqualifiedLocalImports: UnqualifiedLocalImports, // Depends on effective visibilities @@ -718,6 +717,11 @@ fn register_builtins(store: &mut LintStore) { "dependency_on_unit_never_type_fallback", "the code warned by this lint no longer compiles", ); + store.register_removed( + "ungated_async_fn_track_caller", + "the `async_fn_track_caller` feature has stabilized, see \ + for more information", + ); } fn register_internals(store: &mut LintStore) { diff --git a/tests/ui/async-await/track-caller/async-block.afn.stderr b/tests/ui/async-await/track-caller/async-block.afn.stderr deleted file mode 100644 index b6a7481a4d119..0000000000000 --- a/tests/ui/async-await/track-caller/async-block.afn.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:8:13 - | -LL | let _ = #[track_caller] async { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:15:13 - | -LL | let _ = #[track_caller] async { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:23:17 - | -LL | let _ = #[track_caller] async { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-block.nofeat.stderr b/tests/ui/async-await/track-caller/async-block.nofeat.stderr index b6a7481a4d119..f41641235bba9 100644 --- a/tests/ui/async-await/track-caller/async-block.nofeat.stderr +++ b/tests/ui/async-await/track-caller/async-block.nofeat.stderr @@ -1,7 +1,7 @@ error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:8:13 + --> $DIR/async-block.rs:9:13 | -LL | let _ = #[track_caller] async { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -9,9 +9,9 @@ LL | let _ = #[track_caller] async { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:15:13 + --> $DIR/async-block.rs:16:13 | -LL | let _ = #[track_caller] async { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -19,9 +19,9 @@ LL | let _ = #[track_caller] async { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-block.rs:23:17 + --> $DIR/async-block.rs:24:17 | -LL | let _ = #[track_caller] async { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information diff --git a/tests/ui/async-await/track-caller/async-block.rs b/tests/ui/async-await/track-caller/async-block.rs index 900d5ef25504d..e4e5730a92185 100644 --- a/tests/ui/async-await/track-caller/async-block.rs +++ b/tests/ui/async-await/track-caller/async-block.rs @@ -1,27 +1,28 @@ //@ edition:2021 -//@ revisions: afn nofeat +//@ revisions: cls nofeat +//@[cls] check-pass #![feature(stmt_expr_attributes)] -#![cfg_attr(afn, feature(async_fn_track_caller))] +#![cfg_attr(cls, feature(closure_track_caller))] fn main() { - let _ = #[track_caller] async { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + async {}; } #[track_caller] async fn foo() { - let _ = #[track_caller] async { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + async {}; } #[track_caller] async fn foo2() { let _ = async { - let _ = #[track_caller] async { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + async {}; }; } diff --git a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr b/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr deleted file mode 100644 index 6887a904211ec..0000000000000 --- a/tests/ui/async-await/track-caller/async-closure-gate.afn.stderr +++ /dev/null @@ -1,96 +0,0 @@ -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 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -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 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:21:13 - | -LL | let _ = #[track_caller] || { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:29:17 - | -LL | let _ = #[track_caller] || { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:37:9 - | -LL | #[track_caller] || { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:47:13 - | -LL | #[track_caller] || { - | ^^^^^^^^^^^^^^^ - | - = note: see issue #87417 for more information - = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0308]: mismatched types - --> $DIR/async-closure-gate.rs:27:5 - | -LL | fn foo3() { - | - help: try adding a return type: `-> impl Future` -LL | / async { -LL | | -LL | | let _ = #[track_caller] || { -... | -LL | | } - | |_____^ expected `()`, found `async` block - | - = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 27:10}` - -error[E0308]: mismatched types - --> $DIR/async-closure-gate.rs:44:5 - | -LL | fn foo5() { - | - help: try adding a return type: `-> impl Future` -LL | / async { -LL | | -LL | | let _ = || { -LL | | #[track_caller] || { -... | -LL | | }; -LL | | } - | |_____^ expected `()`, found `async` block - | - = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 44:10}` - -error: aborting due to 8 previous errors - -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr index 6887a904211ec..a5e77a5172a4d 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr +++ b/tests/ui/async-await/track-caller/async-closure-gate.nofeat.stderr @@ -1,7 +1,7 @@ error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:8:13 + --> $DIR/async-closure-gate.rs:9:13 | -LL | let _ = #[track_caller] async || { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -9,9 +9,9 @@ LL | let _ = #[track_caller] async || { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:15:13 + --> $DIR/async-closure-gate.rs:16:13 | -LL | let _ = #[track_caller] async || { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -19,9 +19,9 @@ LL | let _ = #[track_caller] async || { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:21:13 + --> $DIR/async-closure-gate.rs:22:13 | -LL | let _ = #[track_caller] || { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -31,7 +31,7 @@ LL | let _ = #[track_caller] || { error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/async-closure-gate.rs:29:17 | -LL | let _ = #[track_caller] || { +LL | let _ = #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -41,7 +41,7 @@ LL | let _ = #[track_caller] || { error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/async-closure-gate.rs:37:9 | -LL | #[track_caller] || { +LL | #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information @@ -49,48 +49,15 @@ LL | #[track_caller] || { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/async-closure-gate.rs:47:13 + --> $DIR/async-closure-gate.rs:46:13 | -LL | #[track_caller] || { +LL | #[track_caller] | ^^^^^^^^^^^^^^^ | = note: see issue #87417 for more information = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error[E0308]: mismatched types - --> $DIR/async-closure-gate.rs:27:5 - | -LL | fn foo3() { - | - help: try adding a return type: `-> impl Future` -LL | / async { -LL | | -LL | | let _ = #[track_caller] || { -... | -LL | | } - | |_____^ expected `()`, found `async` block - | - = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:27:5: 27:10}` - -error[E0308]: mismatched types - --> $DIR/async-closure-gate.rs:44:5 - | -LL | fn foo5() { - | - help: try adding a return type: `-> impl Future` -LL | / async { -LL | | -LL | | let _ = || { -LL | | #[track_caller] || { -... | -LL | | }; -LL | | } - | |_____^ expected `()`, found `async` block - | - = note: expected unit type `()` - found `async` block `{async block@$DIR/async-closure-gate.rs:44:5: 44:10}` - -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors -Some errors have detailed explanations: E0308, E0658. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/async-closure-gate.rs b/tests/ui/async-await/track-caller/async-closure-gate.rs index e72ce2afa45fd..35f72966820a8 100644 --- a/tests/ui/async-await/track-caller/async-closure-gate.rs +++ b/tests/ui/async-await/track-caller/async-closure-gate.rs @@ -1,52 +1,51 @@ //@ edition:2021 -//@ revisions: afn nofeat +//@ revisions: cls nofeat +//@[cls] check-pass #![feature(stmt_expr_attributes)] -#![cfg_attr(afn, feature(async_fn_track_caller))] +#![cfg_attr(cls, feature(closure_track_caller))] fn main() { - let _ = #[track_caller] async || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + async || {}; } #[track_caller] async fn foo() { - let _ = #[track_caller] async || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + async || {}; } async fn foo2() { - let _ = #[track_caller] || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + || {}; } fn foo3() { - async { - //~^ ERROR mismatched types - let _ = #[track_caller] || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; - } + let _ = async { + let _ = #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + || {}; + }; } async fn foo4() { let _ = || { - #[track_caller] || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + || {}; }; } fn foo5() { - async { - //~^ ERROR mismatched types + let _ = async { let _ = || { - #[track_caller] || { - //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] - }; + #[track_caller] + //[nofeat]~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] + || {}; }; - } + }; } diff --git a/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr b/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr deleted file mode 100644 index 464cbfba2acfe..0000000000000 --- a/tests/ui/async-await/track-caller/panic-track-caller.cls.stderr +++ /dev/null @@ -1,33 +0,0 @@ -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 for more information - = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = 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 for more information - = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: 2 warnings emitted - diff --git a/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr b/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr deleted file mode 100644 index 464cbfba2acfe..0000000000000 --- a/tests/ui/async-await/track-caller/panic-track-caller.nofeat.stderr +++ /dev/null @@ -1,33 +0,0 @@ -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 for more information - = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = 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 for more information - = help: add `#![feature(async_fn_track_caller)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -warning: 2 warnings emitted - diff --git a/tests/ui/async-await/track-caller/panic-track-caller.rs b/tests/ui/async-await/track-caller/panic-track-caller.rs index bd12bf11d6c84..1b39c4af8755e 100644 --- a/tests/ui/async-await/track-caller/panic-track-caller.rs +++ b/tests/ui/async-await/track-caller/panic-track-caller.rs @@ -1,10 +1,8 @@ //@ run-pass //@ edition:2021 -//@ revisions: afn cls nofeat +//@ revisions: cls nofeat //@ needs-unwind -// gate-test-async_fn_track_caller #![feature(stmt_expr_attributes)] -#![cfg_attr(afn, feature(async_fn_track_caller))] #![cfg_attr(cls, feature(closure_track_caller))] #![allow(unused)] @@ -51,8 +49,6 @@ async fn foo() { } #[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() { panic!() } @@ -65,8 +61,6 @@ struct Foo; impl Foo { #[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() { panic!(); } @@ -80,7 +74,8 @@ async fn foo_assoc() { // `nofeat`, we test that separately in `async-closure-gate.rs` #[cfg(cls)] async fn foo_closure() { - let c = #[track_caller] async || { + let c = #[track_caller] + async || { panic!(); }; c().await @@ -90,12 +85,26 @@ async fn foo_closure() { // `nofeat`, we test that separately in `async-block.rs` #[cfg(cls)] async fn foo_block() { - let a = #[track_caller] async { + let a = #[track_caller] + async { panic!(); }; a.await } +#[track_caller] +async fn bar_manual_poll() { + panic!(); +} + +fn foo_manual_poll() { + let future = bar_manual_poll(); + let future = std::pin::pin!(future); + let mut cx = std::task::Context::from_waker(std::task::Waker::noop()); + let res = future.poll(&mut cx); + assert_eq!(res, std::task::Poll::Ready(())); +} + fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { let loc = Arc::new(Mutex::new(None)); @@ -113,22 +122,18 @@ fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { } fn main() { - assert_eq!(panicked_at(|| block_on(foo())), 46 -); + assert_eq!(panicked_at(|| block_on(foo())), 44); - #[cfg(afn)] - assert_eq!(panicked_at(|| block_on(foo_track_caller())), 61); - #[cfg(any(cls, nofeat))] assert_eq!(panicked_at(|| block_on(foo_track_caller())), 57); - #[cfg(afn)] - assert_eq!(panicked_at(|| block_on(foo_assoc())), 76); - #[cfg(any(cls, nofeat))] - assert_eq!(panicked_at(|| block_on(foo_assoc())), 71); + assert_eq!(panicked_at(|| block_on(foo_assoc())), 70); #[cfg(cls)] - assert_eq!(panicked_at(|| block_on(foo_closure())), 84); + assert_eq!(panicked_at(|| block_on(foo_closure())), 81); #[cfg(cls)] - assert_eq!(panicked_at(|| block_on(foo_block())), 96); + assert_eq!(panicked_at(|| block_on(foo_block())), 92); + + // This should be 101 (call site), not 104 (poll site) + assert_eq!(panicked_at(|| foo_manual_poll()), 104); }