From 696d5034b22eea20daaa549f3346672d26708df2 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 27 Jan 2022 11:10:37 +1100 Subject: [PATCH] Clarify the `usage-of-qualified-ty` error message. I found this message confusing when I encountered it. This commit makes it clearer that you have to import the unqualified type yourself. --- compiler/rustc_lint/src/internal.rs | 2 +- .../ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_lint/src/internal.rs b/compiler/rustc_lint/src/internal.rs index 7353cd6b876..d8e1162890c 100644 --- a/compiler/rustc_lint/src/internal.rs +++ b/compiler/rustc_lint/src/internal.rs @@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for TyTyKind { lint.build(&format!("usage of qualified `ty::{}`", t)) .span_suggestion( path.span, - "try using it unqualified", + "try importing it and using it unqualified", t, // The import probably needs to be changed Applicability::MaybeIncorrect, diff --git a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr index 59732cd84e5..a1056cf85d3 100644 --- a/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr +++ b/src/test/ui-fulldeps/internal-lints/qualified_ty_ty_ctxt.stderr @@ -2,7 +2,7 @@ error: usage of qualified `ty::Ty<'_>` --> $DIR/qualified_ty_ty_ctxt.rs:25:11 | LL | ty_q: ty::Ty<'_>, - | ^^^^^^^^^^ help: try using it unqualified: `Ty<'_>` + | ^^^^^^^^^^ help: try importing it and using it unqualified: `Ty<'_>` | note: the lint level is defined here --> $DIR/qualified_ty_ty_ctxt.rs:4:9 @@ -14,7 +14,7 @@ error: usage of qualified `ty::TyCtxt<'_>` --> $DIR/qualified_ty_ty_ctxt.rs:27:16 | LL | ty_ctxt_q: ty::TyCtxt<'_>, - | ^^^^^^^^^^^^^^ help: try using it unqualified: `TyCtxt<'_>` + | ^^^^^^^^^^^^^^ help: try importing it and using it unqualified: `TyCtxt<'_>` error: aborting due to 2 previous errors