]> git.lizzy.rs Git - rust.git/commitdiff
Remove unnecessary `Box` in `Type::QPath`
authorNoah Lev <camelidcamel@gmail.com>
Fri, 27 Aug 2021 00:36:48 +0000 (17:36 -0700)
committerNoah Lev <camelidcamel@gmail.com>
Thu, 30 Sep 2021 20:52:58 +0000 (13:52 -0700)
src/librustdoc/clean/auto_trait.rs
src/librustdoc/clean/mod.rs
src/librustdoc/clean/types.rs
src/librustdoc/json/conversions.rs

index cbc010698c7d4fac1f2d7b7297fde2f155fc0dcd..20fb91eba39a1cf84a1814f7cc5794358b50a558 100644 (file)
@@ -545,7 +545,7 @@ fn param_env_to_generics(
                     match lhs {
                         Type::QPath { name: left_name, ref self_type, ref trait_, .. } => {
                             let ty = &*self_type;
-                            let mut new_trait = *trait_.clone();
+                            let mut new_trait = trait_.clone();
 
                             if self.is_fn_trait(trait_) && left_name == sym::Output {
                                 ty_to_fn
@@ -592,12 +592,12 @@ fn param_env_to_generics(
                             // duplicate bound like `T: Iterator + Iterator<Item=u8>`
                             // on the docs page.
                             bounds.remove(&GenericBound::TraitBound(
-                                PolyTrait { trait_: *trait_.clone(), generic_params: Vec::new() },
+                                PolyTrait { trait_: trait_.clone(), generic_params: Vec::new() },
                                 hir::TraitBoundModifier::None,
                             ));
                             // Avoid creating any new duplicate bounds later in the outer
                             // loop
-                            ty_to_traits.entry(*ty.clone()).or_default().insert(*trait_.clone());
+                            ty_to_traits.entry(*ty.clone()).or_default().insert(trait_.clone());
                         }
                         _ => panic!("Unexpected LHS {:?} for {:?}", lhs, item_def_id),
                     }
index 3c10fadeff36863df940a468b218f24aeb4e0822..73e56a610fbb3aa4ea280e2ef42b73ef97e2e75c 100644 (file)
@@ -387,7 +387,7 @@ fn clean(&self, cx: &mut DocContext<'_>) -> Type {
             name: cx.tcx.associated_item(self.item_def_id).ident.name,
             self_def_id: self_type.def_id(),
             self_type: box self_type,
-            trait_: box trait_,
+            trait_,
         }
     }
 }
@@ -1277,16 +1277,16 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
             let segments = if p.is_global() { &p.segments[1..] } else { &p.segments };
             let trait_segments = &segments[..segments.len() - 1];
             let trait_def = cx.tcx.associated_item(p.res.def_id()).container.id();
-            let trait_path = self::Path {
+            let trait_ = self::Path {
                 res: Res::Def(DefKind::Trait, trait_def),
                 segments: trait_segments.clean(cx),
             };
-            register_res(cx, trait_path.res);
+            register_res(cx, trait_.res);
             Type::QPath {
                 name: p.segments.last().expect("segments were empty").ident.name,
                 self_def_id: Some(DefId::local(qself.hir_id.owner.local_def_index)),
                 self_type: box qself.clean(cx),
-                trait_: box trait_path,
+                trait_,
             }
         }
         hir::QPath::TypeRelative(ref qself, ref segment) => {
@@ -1297,13 +1297,13 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
                 ty::Error(_) => return Type::Infer,
                 _ => bug!("clean: expected associated type, found `{:?}`", ty),
             };
-            let trait_path = hir::Path { span, res, segments: &[] }.clean(cx);
-            register_res(cx, trait_path.res);
+            let trait_ = hir::Path { span, res, segments: &[] }.clean(cx);
+            register_res(cx, trait_.res);
             Type::QPath {
                 name: segment.ident.name,
                 self_def_id: res.opt_def_id(),
                 self_type: box qself.clean(cx),
-                trait_: box trait_path,
+                trait_,
             }
         }
         hir::QPath::LangItem(..) => bug!("clean: requiring documentation of lang item"),
index da06737394d5373042be8a0737082e55dac04fab..b57e8a0ed2aa8aca53290a2267e6ecfd681c2696 100644 (file)
@@ -1408,8 +1408,7 @@ fn def_id_full(&self, cache: &Cache) -> Option<DefId> {
         name: Symbol,
         self_type: Box<Type>,
         self_def_id: Option<DefId>,
-        // FIXME: remove this `Box`; it's unnecessary
-        trait_: Box<Path>,
+        trait_: Path,
     },
 
     // `_`
index 10320baaf93d07c9e4e9e742fda93b366f0d0695..fda540aa186b08924974fd9a4d383aae4e4a7ffe 100644 (file)
@@ -436,7 +436,7 @@ fn from_tcx(ty: clean::Type, tcx: TyCtxt<'_>) -> Self {
             },
             QPath { name, self_type, trait_, .. } => {
                 // FIXME: should `trait_` be a clean::Path equivalent in JSON?
-                let trait_ = ResolvedPath { did: trait_.res.def_id(), path: *trait_ }.into_tcx(tcx);
+                let trait_ = ResolvedPath { did: trait_.res.def_id(), path: trait_ }.into_tcx(tcx);
                 Type::QualifiedPath {
                     name: name.to_string(),
                     self_type: Box::new((*self_type).into_tcx(tcx)),