Z011: Deprecated function call
Detects calls to functions or methods whose doc comments contain an explicit deprecation marker. Start a doc-comment line with Deprecated:, Deprecated;, Deprecated,, or Deprecated in favor of to mark an API.
The rule also checks the namespaces in a call path. A module deprecation is documented on the module declaration, not on each function it contains, so std.fs.path.basename(path) reports the deprecated std.fs.path module.
Examples
Bad
const MyType = struct {
value: u32 = 0,
/// Deprecated: use newMethod instead
pub fn oldMethod(self: *@This()) void {
_ = self;
}
};
var instance: MyType = .{};
// expect: Z011
pub fn main() void {
instance.oldMethod();
}Good
Use the non-deprecated replacement:
const MyType = struct {
value: u32 = 0,
pub fn newMethod(self: *MyType) void {
_ = self;
}
};
var instance: MyType = .{};
pub fn main() void {
instance.newMethod();
}Rationale
Deprecated functions are marked for removal in future versions. Using them creates technical debt and potential future breakage. This rule helps you find and update deprecated API usage before it becomes a problem.
The rule detects:
- Direct function calls to deprecated functions
- Method calls on types with deprecated methods
- Method calls on a parameter receiver, such as
b.lazyDependency(...)where the enclosing function declaresb: *std.Build - Calls through deprecated stdlib modules, such as
std.fs.path - Aliases to deprecated functions
- Deprecated type functions
The message carries the deprecation line of the doc comment only, so one diagnostic stays on one line even when the comment continues with a description.
Note: This rule requires semantic analysis and may not detect all deprecated calls when type information is unavailable.
Incidental uses such as “this function is not deprecated” or “handles deprecated data formats” do not mark an API as deprecated.