diff options
| author | Waffle Lapkin <waffle.lapkin@gmail.com> | 2025-08-03 17:03:25 +0200 |
|---|---|---|
| committer | Waffle Lapkin <waffle.lapkin@gmail.com> | 2025-08-13 02:26:52 +0200 |
| commit | 85d1c89e0fe2c9db253c6e4e53a19302584a2dfd (patch) | |
| tree | d1f50304add0dc7d890eac4d2831666c7b499c65 /compiler/rustc_lint_defs/src/builtin.rs | |
| parent | 07b7dc90ee4df5815dbb91ef8e98cb93571230f5 (diff) | |
| download | rust-85d1c89e0fe2c9db253c6e4e53a19302584a2dfd.tar.gz rust-85d1c89e0fe2c9db253c6e4e53a19302584a2dfd.zip | |
fix tail calls to `#[track_caller]` functions
Diffstat (limited to 'compiler/rustc_lint_defs/src/builtin.rs')
| -rw-r--r-- | compiler/rustc_lint_defs/src/builtin.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 3b84c6b6110..a258d26c817 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -5100,3 +5100,36 @@ declare_lint! { report_in_deps: true, }; } + +declare_lint! { + /// The `tail_call_track_caller` lint detects usage of `become` attempting to tail call + /// a function marked with `#[track_caller]`. + /// + /// ### Example + /// + /// ```rust + /// #![feature(explicit_tail_calls)] + /// #![expect(incomplete_features)] + /// + /// #[track_caller] + /// fn f() {} + /// + /// fn g() { + /// become f(); + /// } + /// + /// g(); + /// ``` + /// + /// {{produces}} + /// + /// ### Explanation + /// + /// Due to implementation details of tail calls and `#[track_caller]` attribute, calls to + /// functions marked with `#[track_caller]` cannot become tail calls. As such using `become` + /// is no different than a normal call (except for changes in drop order). + pub TAIL_CALL_TRACK_CALLER, + Warn, + "detects tail calls of functions marked with `#[track_caller]`", + @feature_gate = explicit_tail_calls; +} |
