Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e20bb15

Browse files
committed
Remove unnecessary Box in Type::QPath
1 parent b8351c3 commit e20bb15

File tree

4 files changed

+12
-13
lines changed

4 files changed

+12
-13
lines changed

src/librustdoc/clean/auto_trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
545545
match lhs {
546546
Type::QPath { name: left_name, ref self_type, ref trait_, .. } => {
547547
let ty = &*self_type;
548-
let mut new_trait = *trait_.clone();
548+
let mut new_trait = trait_.clone();
549549

550550
if self.is_fn_trait(trait_) && left_name == sym::Output {
551551
ty_to_fn
@@ -592,12 +592,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
592592
// duplicate bound like `T: Iterator + Iterator<Item=u8>`
593593
// on the docs page.
594594
bounds.remove(&GenericBound::TraitBound(
595-
PolyTrait { trait_: *trait_.clone(), generic_params: Vec::new() },
595+
PolyTrait { trait_: trait_.clone(), generic_params: Vec::new() },
596596
hir::TraitBoundModifier::None,
597597
));
598598
// Avoid creating any new duplicate bounds later in the outer
599599
// loop
600-
ty_to_traits.entry(*ty.clone()).or_default().insert(*trait_.clone());
600+
ty_to_traits.entry(*ty.clone()).or_default().insert(trait_.clone());
601601
}
602602
_ => panic!("Unexpected LHS {:?} for {:?}", lhs, item_def_id),
603603
}

src/librustdoc/clean/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ impl<'tcx> Clean<Type> for ty::ProjectionTy<'tcx> {
387387
name: cx.tcx.associated_item(self.item_def_id).ident.name,
388388
self_def_id: self_type.def_id(),
389389
self_type: box self_type,
390-
trait_: box trait_,
390+
trait_,
391391
}
392392
}
393393
}
@@ -1277,16 +1277,16 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
12771277
let segments = if p.is_global() { &p.segments[1..] } else { &p.segments };
12781278
let trait_segments = &segments[..segments.len() - 1];
12791279
let trait_def = cx.tcx.associated_item(p.res.def_id()).container.id();
1280-
let trait_path = self::Path {
1280+
let trait_ = self::Path {
12811281
res: Res::Def(DefKind::Trait, trait_def),
12821282
segments: trait_segments.clean(cx),
12831283
};
1284-
register_res(cx, trait_path.res);
1284+
register_res(cx, trait_.res);
12851285
Type::QPath {
12861286
name: p.segments.last().expect("segments were empty").ident.name,
12871287
self_def_id: Some(DefId::local(qself.hir_id.owner.local_def_index)),
12881288
self_type: box qself.clean(cx),
1289-
trait_: box trait_path,
1289+
trait_,
12901290
}
12911291
}
12921292
hir::QPath::TypeRelative(ref qself, ref segment) => {
@@ -1297,13 +1297,13 @@ fn clean_qpath(hir_ty: &hir::Ty<'_>, cx: &mut DocContext<'_>) -> Type {
12971297
ty::Error(_) => return Type::Infer,
12981298
_ => bug!("clean: expected associated type, found `{:?}`", ty),
12991299
};
1300-
let trait_path = hir::Path { span, res, segments: &[] }.clean(cx);
1301-
register_res(cx, trait_path.res);
1300+
let trait_ = hir::Path { span, res, segments: &[] }.clean(cx);
1301+
register_res(cx, trait_.res);
13021302
Type::QPath {
13031303
name: segment.ident.name,
13041304
self_def_id: res.opt_def_id(),
13051305
self_type: box qself.clean(cx),
1306-
trait_: box trait_path,
1306+
trait_,
13071307
}
13081308
}
13091309
hir::QPath::LangItem(..) => bug!("clean: requiring documentation of lang item"),

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1408,8 +1408,7 @@ crate enum Type {
14081408
name: Symbol,
14091409
self_type: Box<Type>,
14101410
self_def_id: Option<DefId>,
1411-
// FIXME: remove this `Box`; it's unnecessary
1412-
trait_: Box<Path>,
1411+
trait_: Path,
14131412
},
14141413

14151414
// `_`

src/librustdoc/json/conversions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ impl FromWithTcx<clean::Type> for Type {
436436
},
437437
QPath { name, self_type, trait_, .. } => {
438438
// FIXME: should `trait_` be a clean::Path equivalent in JSON?
439-
let trait_ = ResolvedPath { did: trait_.res.def_id(), path: *trait_ }.into_tcx(tcx);
439+
let trait_ = ResolvedPath { did: trait_.res.def_id(), path: trait_ }.into_tcx(tcx);
440440
Type::QualifiedPath {
441441
name: name.to_string(),
442442
self_type: Box::new((*self_type).into_tcx(tcx)),

0 commit comments

Comments
 (0)