about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2025-04-11 19:44:11 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2025-04-14 16:12:21 +1000
commitabce592029671a2f65e50901ad5fc55e42fdf930 (patch)
tree9996858889627aed05aa470045b01d9346abfa54 /compiler
parent092a284ba0421695f2032c947765429fd7095796 (diff)
downloadrust-abce592029671a2f65e50901ad5fc55e42fdf930.tar.gz
rust-abce592029671a2f65e50901ad5fc55e42fdf930.zip
Use `Symbol` in `LateContext::get_associated_type`.
To avoid unnecessary interning.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_lint/src/context.rs9
-rw-r--r--compiler/rustc_lint/src/deref_into_dyn_supertrait.rs2
2 files changed, 8 insertions, 3 deletions
diff --git a/compiler/rustc_lint/src/context.rs b/compiler/rustc_lint/src/context.rs
index 16c9e08c78d..a2d5ffe256d 100644
--- a/compiler/rustc_lint/src/context.rs
+++ b/compiler/rustc_lint/src/context.rs
@@ -855,11 +855,16 @@ impl<'tcx> LateContext<'tcx> {
         &self,
         self_ty: Ty<'tcx>,
         trait_id: DefId,
-        name: &str,
+        name: Symbol,
     ) -> Option<Ty<'tcx>> {
         let tcx = self.tcx;
         tcx.associated_items(trait_id)
-            .find_by_ident_and_kind(tcx, Ident::from_str(name), ty::AssocKind::Type, trait_id)
+            .find_by_ident_and_kind(
+                tcx,
+                Ident::with_dummy_span(name),
+                ty::AssocKind::Type,
+                trait_id,
+            )
             .and_then(|assoc| {
                 let proj = Ty::new_projection(tcx, assoc.def_id, [self_ty]);
                 tcx.try_normalize_erasing_regions(self.typing_env(), proj).ok()
diff --git a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
index ec8f8441575..5989ef9519c 100644
--- a/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
+++ b/compiler/rustc_lint/src/deref_into_dyn_supertrait.rs
@@ -69,7 +69,7 @@ impl<'tcx> LateLintPass<'tcx> for DerefIntoDynSupertrait {
             && let ty::Dynamic(data, _, ty::Dyn) = self_ty.kind()
             && let Some(self_principal) = data.principal()
             // `<T as Deref>::Target` is `dyn target_principal`
-            && let Some(target) = cx.get_associated_type(self_ty, did, "Target")
+            && let Some(target) = cx.get_associated_type(self_ty, did, sym::Target)
             && let ty::Dynamic(data, _, ty::Dyn) = target.kind()
             && let Some(target_principal) = data.principal()
             // `target_principal` is a supertrait of `t_principal`