Skip to content

Commit 7e4d871

Browse files
committed
rustc: use intern_* instead of mk_* where possible.
1 parent 196b2e0 commit 7e4d871

File tree

6 files changed

+15
-11
lines changed

6 files changed

+15
-11
lines changed

src/librustc/ty/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
26002600
}
26012601

26022602
pub fn mk_goal(self, goal: Goal<'tcx>) -> &'tcx Goal {
2603-
&self.mk_goals(iter::once(goal))[0]
2603+
&self.intern_goals(&[goal])[0]
26042604
}
26052605

26062606
pub fn lint_node<S: Into<MultiSpan>>(self,

src/librustc_codegen_llvm/common.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,10 @@ pub fn ty_fn_sig<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
431431
sig.map_bound(|sig| {
432432
let state_did = tcx.lang_items().gen_state().unwrap();
433433
let state_adt_ref = tcx.adt_def(state_did);
434-
let state_substs = tcx.mk_substs([sig.yield_ty.into(),
435-
sig.return_ty.into()].iter());
434+
let state_substs = tcx.intern_substs(&[
435+
sig.yield_ty.into(),
436+
sig.return_ty.into(),
437+
]);
436438
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
437439

438440
tcx.mk_fn_sig(iter::once(env_ty),

src/librustc_mir/borrow_check/nll/universal_regions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ impl<'cx, 'gcx, 'tcx> UniversalRegionsBuilder<'cx, 'gcx, 'tcx> {
669669
assert_eq!(self.mir_def_id, def_id);
670670
let ty = tcx.type_of(def_id);
671671
let ty = indices.fold_to_region_vids(tcx, &ty);
672-
ty::Binder::dummy(tcx.mk_type_list(iter::once(ty)))
672+
ty::Binder::dummy(tcx.intern_type_list(&[ty]))
673673
}
674674
}
675675
}

src/librustc_mir/shim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn build_drop_shim<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
170170
}
171171

172172
let substs = if let Some(ty) = ty {
173-
tcx.mk_substs(iter::once(ty.into()))
173+
tcx.intern_substs(&[ty.into()])
174174
} else {
175175
Substs::identity_for_item(tcx, def_id)
176176
};

src/librustc_mir/transform/generator.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -861,8 +861,10 @@ impl MirPass for StateTransform {
861861
// Compute GeneratorState<yield_ty, return_ty>
862862
let state_did = tcx.lang_items().gen_state().unwrap();
863863
let state_adt_ref = tcx.adt_def(state_did);
864-
let state_substs = tcx.mk_substs([yield_ty.into(),
865-
mir.return_ty().into()].iter());
864+
let state_substs = tcx.intern_substs(&[
865+
yield_ty.into(),
866+
mir.return_ty().into(),
867+
]);
866868
let ret_ty = tcx.mk_adt(state_adt_ref, state_substs);
867869

868870
// We rename RETURN_PLACE which has type mir.return_ty to new_ret_local

src/librustc_traits/lowering.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ fn program_clauses_for_trait<'a, 'tcx>(
220220
// `Implemented(Self: Trait<P1..Pn>) :- FromEnv(Self: Trait<P1..Pn>)`
221221
let implemented_from_env = ProgramClause {
222222
goal: impl_trait,
223-
hypotheses: tcx.mk_goals(iter::once(from_env)),
223+
hypotheses: tcx.intern_goals(&[from_env]),
224224
};
225225
let clauses = iter::once(Clause::ForAll(ty::Binder::dummy(implemented_from_env)));
226226

@@ -256,7 +256,7 @@ fn implied_bound_from_trait<'a, 'tcx>(
256256
// `FromEnv(WC) :- FromEnv(Self: Trait<P1..Pn>)`
257257
Clause::ForAll(where_clause.lower().map_bound(|goal| ProgramClause {
258258
goal: goal.into_from_env_goal(),
259-
hypotheses: tcx.mk_goals(iter::once(Goal::from(impl_trait))),
259+
hypotheses: tcx.intern_goals(&[Goal::from(impl_trait)]),
260260
}))
261261
}
262262

@@ -290,7 +290,7 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
290290
.map(|wc| Goal::from_poly_domain_goal(wc, tcx)),
291291
),
292292
};
293-
tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause))))
293+
tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))])
294294
}
295295

296296
pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
@@ -344,7 +344,7 @@ pub fn program_clauses_for_associated_type_value<'a, 'tcx>(
344344
.map(|wc| Goal::from_poly_domain_goal(wc, tcx)),
345345
),
346346
};
347-
tcx.mk_clauses(iter::once(Clause::ForAll(ty::Binder::dummy(clause))))
347+
tcx.intern_clauses(&[Clause::ForAll(ty::Binder::dummy(clause))])
348348
}
349349

350350
pub fn dump_program_clauses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {

0 commit comments

Comments
 (0)