From 6d040856df069e0345cc34047c4d21c66021cca9 Mon Sep 17 00:00:00 2001 From: blyxyas Date: Mon, 16 Jun 2025 19:41:12 +0200 Subject: [PATCH] Add a warning to LateContext::get_def_path --- compiler/rustc_lint/src/context.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs index 5679d4566dcd4..c7d59fa283a7a 100644 --- a/compiler/rustc_lint/src/context.rs +++ b/compiler/rustc_lint/src/context.rs @@ -710,6 +710,15 @@ impl<'tcx> LateContext<'tcx> { /// Gets the absolute path of `def_id` as a vector of `Symbol`. /// + /// Note that this is kinda expensive because it has to + /// travel the tree and pretty-print. Use sparingly. + /// + /// If you're trying to match for an item given by its path, use a + /// diagnostic item. If you're only interested in given sections, use more + /// specific functions, such as [`TyCtxt::crate_name`] + /// + /// FIXME: It would be great if this could be optimized. + /// /// # Examples /// /// ```rust,ignore (no context or def id available)