Skip to content

Commit d47dc98

Browse files
committed
rustc: avoid using intern_*(it.collect()) when mk_*(it) works better.
1 parent 98686ca commit d47dc98

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/librustc/ty/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2678,11 +2678,11 @@ fn adt_sized_constraint<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
26782678
-> &'tcx [Ty<'tcx>] {
26792679
let def = tcx.adt_def(def_id);
26802680

2681-
let result = tcx.intern_type_list(&def.variants.iter().flat_map(|v| {
2681+
let result = tcx.mk_type_list(def.variants.iter().flat_map(|v| {
26822682
v.fields.last()
26832683
}).flat_map(|f| {
26842684
def.sized_constraint_for_ty(tcx, tcx.type_of(f.did))
2685-
}).collect::<Vec<_>>());
2685+
}));
26862686

26872687
debug!("adt_sized_constraint: {:?} => {:?}", def, result);
26882688

src/librustc/ty/relate.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::rc::Rc;
2424
use std::iter;
2525
use rustc_target::spec::abi;
2626
use hir as ast;
27-
use rustc_data_structures::accumulate_vec::AccumulateVec;
2827

2928
pub type RelateResult<'tcx, T> = Result<T, TypeError<'tcx>>;
3029

@@ -154,6 +153,8 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
154153
-> RelateResult<'tcx, ty::FnSig<'tcx>>
155154
where R: TypeRelation<'a, 'gcx, 'tcx>, 'gcx: 'a+'tcx, 'tcx: 'a
156155
{
156+
let tcx = relation.tcx();
157+
157158
if a.variadic != b.variadic {
158159
return Err(TypeError::VariadicMismatch(
159160
expected_found(relation, &a.variadic, &b.variadic)));
@@ -175,9 +176,9 @@ impl<'tcx> Relate<'tcx> for ty::FnSig<'tcx> {
175176
} else {
176177
relation.relate_with_variance(ty::Contravariant, &a, &b)
177178
}
178-
}).collect::<Result<AccumulateVec<[_; 8]>, _>>()?;
179+
});
179180
Ok(ty::FnSig {
180-
inputs_and_output: relation.tcx().intern_type_list(&inputs_and_output),
181+
inputs_and_output: tcx.mk_type_list(inputs_and_output)?,
181182
variadic: a.variadic,
182183
unsafety,
183184
abi,

0 commit comments

Comments
 (0)